Advertisement
mayankjoin3

low_disk_space_email_90

Sep 15th, 2022
1,234
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. ADMIN="jausten@adomain.com,another@adomain.com"
  8. THRESHOLD=90
  9.  
  10. df -PkH | grep -E '^/dev/sda1' | awk '{ print $5 " " $6 }' | while read output;
  11. do
  12.   usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
  13.   partition=$(echo $output | awk '{print $2}' )
  14.   if [ $usep -ge $THRESHOLD ]; then
  15.     echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
  16.     #mail -s "Alert: Almost out of disk space $usep%" $ADMIN
  17.     php /root/cronjob_scripts/sendmail_script_90.php
  18.   fi
  19. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement