Advertisement
mayankjoin3

low_disk_space_email_90

Sep 15th, 2022
1,251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #low_disk_space_email_90.sh
  2. #!/bin/sh
  3. # this script was initially written for Redhat/CentOS
  4. # file is /etc/cron.daily/diskAlert.cron
  5. # requires enabling outgoing sendmail from localhost to a valid
  6. # smtp server, which is usually disabled by default
  7. THRESHOLD=90
  8.  
  9. df -PkH | grep -E '^/dev/sda1' | awk '{ print $5 " " $6 }' | while read output;
  10. do
  11.   usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
  12.   partition=$(echo $output | awk '{print $2}' )
  13.   if [ $usep -ge $THRESHOLD ]; then
  14.     echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
  15.     #mail -s "Alert: Almost out of disk space $usep%" $ADMIN
  16.     php /root/cronjob_scripts/sendmail_script_90.php
  17.   fi
  18. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement