sábado, 28 de noviembre de 2015

adding a path to list

export PATH=$PATH:/root/

domingo, 15 de noviembre de 2015

Monitor UNIX / Linux Server Disk Space with Shell Script


Shell script to monitor or watch the disk space and send an email alert if the (free avilable) percentage of space is >= 90%
  1. #!/bin/sh
  2. # Shell script to monitor or watch the disk space
  3. # It will send an email to $ADMIN, if the (free avilable) percentage
  4. # of space is >= 90%
  5. # -------------------------------------------------------------------------
  6. # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
  7. # This script is licensed under GNU GPL version 2.0 or above
  8. # -------------------------------------------------------------------------
  9. # This script is part of nixCraft shell script collection (NSSC)
  10. # Visit http://bash.cyberciti.biz/ for more information.
  11. # ----------------------------------------------------------------------
  12. # Linux shell script to watch disk space (should work on other UNIX oses )
  13. # SEE URL: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
  14. # set admin email so that you can get email
  15. ADMIN="me@somewher.com"
  16. # set alert level 90% is default
  17. ALERT=90
  18. df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
  19. do
  20. #echo $output
  21. usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
  22. partition=$(echo $output | awk '{ print $2 }' )
  23. if [ $usep -ge $ALERT ]; then
  24. echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
  25. mail -s "Alert: Almost out of disk space $usep" $ADMIN
  26. fi
  27. done