Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-2011, 03:09 PM
Trained Alumni
 
Posts: 8
Default Disk Space Monitoring Script

I'm just sharing.

We run this script every 5 min via cron on our Zimbra servers. It checks the disk usage on our Zimbra volumes, and then emails us when those thresholds are reached.

I've left in all the comments so you can see what we use and don't use anymore. I'm sure that there are better ways to do this, so by all means let me know.

Code:
#! /bin/ksh
#

##  ALTERED 03/14/2005 by NRC to catch any file system
##      ALTERED 11/17/2004 for use at Franklin University by D.Morgenstern, A.Kelly and F.S.

########### Function SENDMAIL will send mail to sys admins regarding disk capacity ##############

SENDMAIL () {
                         mail -s "$HOST Disk Space Alert" $INTERESTED<<EOF
             $HOST Disk Space Alert
             Filesystem $FILESYSTEM has reached $PERC% of its capacity.
EOF
return
}

########## VARIABLES ###########
# phone page phonenumber1/ fs;  phonenumber2/ak;  phonenumber3/dm;  phonenumber4/rc
INTERESTED=emailaddress1,distributionlist1
HOST=`uname -n`


######### Run df -kl and extract filesystem and disk usage amount to temporary holding file ########

df -Plk | grep -iv filesystem | awk '{ print $6"\t "$5}'|cut -d"%" -f1  >holding


######### reasign standard input to temporary holding file#######

exec < holding


######### Read FILESYSTEM and PERCentage, for each line execute the case test  ########

while read FILESYSTEM PERC
do


######## Test each FILESYSTEM PERCentage against it's threshold amount. If PERCentage is
######## greater than threshold amount execute the SENDMAIL function.

case "$FILESYSTEM" in
     /) if [[ $PERC -gt 90 ]]; then
         SENDMAIL
         fi;;
     /var/run) if [[ $PERC -gt 70 ]]; then
         SENDMAIL
         fi;;
     /tmp) if [[ $PERC -gt 80 ]]; then
         SENDMAIL
         fi;;
     /var) if [[ $PERC -gt 90 ]]; then
         SENDMAIL
         fi;;
     /usr) if [[ $PERC -gt 90 ]]; then
         SENDMAIL
         fi;;
     /ZimbraBackup) if [[ $PERC -gt 97 ]]; then
         SENDMAIL
         fi;;
     /zimbraPrimary) if [[ $PERC -gt 90 ]]; then
         SENDMAIL
         fi;;
     /zimbraRedolog) if [[ $PERC -gt 75 ]]; then
         SENDMAIL
         fi;;
     /zimbraIndex) if [[ $PERC -gt 95 ]]; then
         SENDMAIL
         fi;;
     /zimbraHSM1) if [[ $PERC -gt 98 ]]; then
         SENDMAIL
         fi;;
     /opt) if [[ $PERC -gt 94 ]]; then
         SENDMAIL
         fi;;
    *) if [[ $PERC -gt 90 ]]; then
         SENDMAIL
         fi;;


#       mail -s 'Invalid FILESYSTEM! found' $INTERESTED<<EOF
#
#             Filesystem $FILESYSTEM has been discovered by the Diskmonitor Process.
#EOF
#
esac
done

Last edited by phoenix; 04-06-2011 at 09:47 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.