Monitor AIX filesystems
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.
September 22nd, 2009 at 10:43 pm
hi,kewl script,are you from .au?