Operating System - HP-UX
1825766 Members
2079 Online
109687 Solutions
New Discussion

Need system to notify when file system reaches threshold

 
SOLVED
Go to solution
Kevin Khoo
New Member

Need system to notify when file system reaches threshold

Would appreciate if I can get sample of script to notify sys admin whenever any file system reaches threshold in Hp-UX 10.20. Notification can be form of e-mail or system alert
7 REPLIES 7
Stefan Farrelly
Honored Contributor
Solution

Re: Need system to notify when file system reaches threshold

Heres what we use;

#!/usr/bin/sh
# Global settings
#
if [ "$#" -lt "1" ]
then
echo
echo "$0 Usage:"
echo " $0 , comma separated"
echo
echo "Example: $0 sysadmin1@mycompany.com,sysadmin3@mycompany.com"
exit 1
fi
if [ "$1" = "debug" ]
then
DEBUG=/usr/bin/true
else
DEBUG=/usr/bin/false
NOTIFY=$1
fi
MYNAME=$(/usr/bin/hostname)
TEMPFILE=/tmp/diskspace.$$

# Get a bdf of the filesystem(s) into a temp file
# If JFS (vxfs) exists, use the example:
# FSTYPES="hfs vxfs"
#
FSTYPES="hfs vxfs"
for FSYS in $(echo $FSTYPES)
do
bdf -i -t $FSYS >> $TEMPFILE
done
trap "rm $TEMPFILE 2> /dev/null " 0
exec 7< $TEMPFILE
#
# Read through the temp file, skipping header line(s)
#
while read -u7 BDFLINE
do
#
# skip the title line(s)
#
echo "$BDFLINE" | grep -qv ^Filesystem

if [ $? -eq 0 ]
then
#
# Check if this is a 2-line bdf (ie, long device filename)
# Concatenate the next line if so
#
LEN=${#BDFLINE}
if [ $LEN -lt 60 ]
then
read -u7 LINE2
BDFLINE=$(echo "$BDFLINE $LINE2")
fi
#
# translate % to a space...large filesystems will run numbers together
# at HP-UX 9.x so we may need spaces to separate params.
#
echo "$BDFLINE" | tr "%" "\ " | read DEVFILE MAXMEGS USEDMEGS FREEMEGS PERCENT IUSED IFREE IPERCENT MNTPNT
# Special cases for some filesystems that need different limits
#
case $MNTPNT in
/LaserROM ) LIMIT=99 ;;
/teno ) LIMIT=100 ;;
/usr ) LIMIT=85 ;;
/home/uas ) LIMIT=90 ;;
* ) LIMIT=91 ;;
esac
if [ $PERCENT -gt $LIMIT ]
then
if $DEBUG
then
echo "$MYNAME: $MNTPNT is ${PERCENT}% full"
else
echo "$MYNAME: $MNTPNT is ${PERCENT}% full" | mailx $NOTIFY

fi
fi
#
# Same test for inode usage M-^V can specify special limits
#
case $MNTPNT in
/home ) ILIMIT=85 ;;
* ) ILIMIT=90 ;;
esac
if [ $IPERCENT -gt $ILIMIT ]
then
if $DEBUG
then
echo "\n\n$MYNAME: $MNTPNT $IFREE inodes left)"
else
echo "$MYNAME: $MNTPNT $IFREE inodes left)" | mailx $NOTIFY

fi
fi

fi
done
rm $TEMPFILE

This works great. It uses email as its notification. You can replace it or add in xdialog if you want a popup to an X display.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Michael Tully
Honored Contributor

Re: Need system to notify when file system reaches threshold

Attached is a script that we use, courtesy of Bill Hassell. It is brilliant!!!
Anyone for a Mutiny ?
Nick Wickens
Respected Contributor

Re: Need system to notify when file system reaches threshold

Hi Heres the script I have been using for the last couple of years - Replace the Openview NNM ovevent with your sendmail command if you want to send mail directly. This gives you two levels of alert if you want.

LOW=75
HIGH=90
DATE=$(date)
OUTFILE=/tmp/bdfrep
:>$OUTFILE

(bdf |egrep -v '(cdrom)' |sed -e "1d"|sed -e "/^.*:.*$/d"|sed -e "/^[
] [ ]*.*$/d"|
while read LVOL SIZE USED AVAIL PERCENTAGE MOUNT_PT
do
BREAK=PAUSE
PERCENTAGE=$(echo $PERCENTAGE | sed -e "s/%//")

if [ $PERCENTAGE -ge $HIGH ]; then
echo " $DATE - WARNING - The percentage of used space on filesystem $MOU
NT_PT is greater than $HIGH percent"
/opt/OV/bin/ovevent 171.10.10.15 .1.3.6.1.4.1.4530.1.0.8
elif [ $PERCENTAGE -ge $LOW ]; then
echo " $DATE - WARNING - The percentage of used space on filesystem $MO
UNT_PT is greater than $LOW percent"
fi
done
) >> $OUTFILE
Hats ? We don't need no stinkin' hats !!
V. V. Ravi Kumar_1
Respected Contributor

Re: Need system to notify when file system reaches threshold

hi,
try this. add this in crontab to execute every day morning to get a mail of file systems more than 90% full
--------
#!/usr/bin/sh
#To find the FS which are filled more than 90% and to get a mail
bdf|awk '{print $5," ",$6}'|sed 's/%/ /g'|awk '$1>89{print $1," ",$2}'|sed '1d'
-------------
crontab entry
55 8 * * * /tc4sys/cord/cron/fscron.sh > (Script path)> /tmp/fssize;elm -s "FS More Than 90 on (machine name)" (mail id)
Never Say No
Susan Kim
New Member

Re: Need system to notify when file system reaches threshold

I work in Oracle shop.
If you know Oracle, you know that database stops if the archive directory is full.
My script is pretty simple, it just issue bdf and only look at the ones I care about..
then If it's over threshold value of >90%, then it will email me:

script is attached:
Consultant, Impact Innovations Group
Jack C. Mahaffey
Super Advisor

Re: Need system to notify when file system reaches threshold

 
MANOJ SRIVASTAVA
Honored Contributor

Re: Need system to notify when file system reaches threshold

Kevin


Here is a simple script .



bdf | awk '{if ($5 > "90") print $NF,$5 }' > /tmp/test


This will create a file test in /tmp with the files sytems and the values of the usage. You can be creative in using this file as a form of mail , message etc . Run this as a part of script



or, look at this link


http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x3b8fee3e323bd5118fef0090279cd0f9,00.html


Manoj srivastava