Re: script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Mad Unix wrote:

I suggest make it a little bit lighter:
inline corrections:
#!/bin/sh
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free avilable) percentage
# of space is >= 90%
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# Linux shell script to watch disk space (should work on other UNIX oses )
# SEE URL: http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
# set admin email so that you can get email
ADMIN="me@xxxxxxxxxxxx <mailto:me@xxxxxxxxxxxx>"
# set alert level 90% is default
ALERT=90
df -HP | grep -vE '^Filesystem|tmpfs|cdrom' |
 while read partition size used free perc mnt ;
 do
   usep=$(echo $perc | tr -d '%' )
   if [ $usep -ge $ALERT ]; then
     echo "Running out of space \"$partition ($usep%)\" on $(hostname) as
 on $(date)" |
      mail -s "Alert: Almost out of disk space $usep" $ADMIN
   fi
 done


it works for me.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux