Re: script for df-k filesystem alerts...

From: Rod Jenkins (RodJ@IOWATELECOM.COM)
Date: Wed Sep 11 2002 - 11:31:50 EDT


Here is what I use.

Rod.

#!/bin/ksh
###########################################################################
## script: check_fs.ksh ##
## purpose: monitor filesystem space. mails to alert when exceeded. ##
## Note: this script could probably use some re-integration ##
## as it may have become out of sync across the platforms. ##
###########################################################################
HOSTNAME=`uname -n`
OSTYPE=`uname`

function check_cap {
$DF_CMD|grep -iv cdrom|tail +2|while read FS_LINE
do
KB_AVL=`echo $FS_LINE|awk '{print $'$DF_KB_AVL'}'`
PCT_USD=`echo $FS_LINE|awk '{print $'$DF_PCT_USD'}'|sed -e 's/%//g'`
FS_NAME=`echo $FS_LINE|awk '{print $'$DF_FS_NAME'}'`
if [ $PCT_USD -ge 98 ]
then
echo $FS_NAME","$KB_AVL","$PCT_USD|mailx alert
fi
done

}

case $OSTYPE in
        AIX)
            DF_CMD='df -Ik'
            DF_KB_AVL="4"
            DF_PCT_USD="5"
            DF_FS_NAME="6"
            check_cap
        ;;
        SunOS,OSF1)
            DF_KB_AVL=4
            DF_PCT_USD=5
            DF_FS_NAME=6
            ;;
        HP-UX)
            DF_KB_AVL=4
            DF_PCT_USD=5
            DF_FS_NAME=6
            ;;
        Linux)
            DF_KB_AVL=4
            DF_PCT_USD=5
            DF_FS_NAME=6
            ;;
esac

-----Original Message-----
From: Barnhart, Troy [mailto:TBarnhart@RCRH.ORG]
Sent: Wednesday, September 11, 2002 10:13 AM
To: aix-l@Princeton.EDU
Subject: script for df-k filesystem alerts...

Just a request to see if someone out there already has a
simple script I could setup in cron that runs a df -k and
then parses the output to find anything over a certain percentage in the
%used column. I could use a little help on the parsing part. I'm going to
then push that line of output to an alert email.

thanks in advance,
troy

Troy Barnhart, Sr. Systems Programmer,
tbarnhart@rcrh.org
Rapid City Regional Hospital,
Rapid City, South Dakota, 57701
ph: 605-719-8068 / fax: 605-719-4206



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:12 EDT