Results 1 to 1 of 1

Thread: Disk Space Monitoring Script

  1. #1
    brumdo is offline Trained Alumni
    Join Date
    Nov 2009
    Location
    Columbus, Ohio
    Posts
    9
    Rep Power
    5

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Daily mail report always reports "No messages found"
    By McPringle in forum Installation
    Replies: 42
    Last Post: 06-13-2011, 08:57 AM
  2. change disk space pointing directory
    By gfpoow in forum Administrators
    Replies: 0
    Last Post: 04-01-2011, 07:57 PM
  3. Disk Space being eaten up
    By Paul_Pittsburgh in forum Administrators
    Replies: 12
    Last Post: 10-27-2010, 10:34 AM
  4. /tmp/convert folder fill up disk space
    By det in forum Administrators
    Replies: 2
    Last Post: 10-21-2010, 11:46 PM
  5. how much physical disk space Zimbara will use ?
    By raj in forum Administrators
    Replies: 3
    Last Post: 10-06-2006, 11:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •