Kristijan.org

I’m back!

Posted by Kristijan on Sunday, December 21st, 2008

How could I stay away? From the shear number of e-mails flooding my inbox daily for updates to my infamous blog, I couldn’t keep the fans in the dark no more!
*cough*
Back to reality…I’m not reviving my old blog, but starting a new one. I’ve been working as a systems administrator for about 4 years now, [...]

continue reading

Monitor AIX filesystems

Posted by Kristijan on Wednesday, February 25th, 2009

If you’re looking for something cheap and nasty to monitor your filesystem usage while you’re setting up something more robust, here is a cheap and very nasty script to do just that.

#!/usr/bin/ksh
# This script monitors various filesystems and emails
# notifications when they hit a set limit
#
MAILTO='your@email.com'
HOSTNAME=`hostname`

ROOT=`df -k|grep "/dev/hd4"|awk '{print $4}'|sed "s/%//"`
USR=`df -k|grep "/dev/hd2"|awk '{print $4}'|sed "s/%//"`
VAR=`df -k|grep "/dev/hd9var"|awk '{print $4}'|sed "s/%//"`
HOME=`df -k|grep "/dev/hd1"|grep -v opt|awk '{print $4}'|sed "s/%//"`
OPT=`df -k|grep "/opt"|awk '{print $4}'|sed "s/%//"`
TMP=`df -k|grep "/dev/hd3"|awk '{print $4}'|sed "s/%//"`

if [ $ROOT -gt 79 ]
then
   echo "We have hit ${ROOT}% on / on $HOSTNAME"|mailx -s "WARNING on $HOSTNAME" $MAILTO
fi
if [ $USR -gt 79 ]
then
   echo "We have hit ${USR}% on /usr on $HOSTNAME"|mailx -s "WARNING on $HOSTNAME" $MAILTO
fi
if [ $VAR -gt 79 ]
then
   echo "We have hit ${VAR}% on /var on $HOSTNAME"|mailx -s "WARNING on $HOSTNAME" $MAILTO
fi
if [ $HOME -gt 79 ]
then
   echo "We have hit ${HOME}% on /home on $HOSTNAME"|mailx -s "WARNING on $HOSTNAME" $MAILTO
fi
if [ $OPT -gt 79 ]
then
   echo "We have hit ${OPT}% on /opt on $HOSTNAME"|mailx -s "WARNING on $HOSTNAME" $MAILTO
fi
if [ $TMP -gt 79 ]
then
   echo "We have hit ${TMP}% on /tmp on $HOSTNAME"|mailx -s "WARNING on $HOSTNAME" $MAILTO
fi

exit

The above script is running on an AIX operating environment, so you’ll need to modify the variables to suit. It’s not all that far to figure out, but if you need a hand…shout out.

Posted in: Shell Scripting.

One Response to “Monitor AIX filesystems”

  1. r0ny Says:

    hi,kewl script,are you from .au?

Leave a Reply