Operating System - HP-UX
1833780 Members
2591 Online
110063 Solutions
New Discussion

Re: Auto email when mountpoint exceeds 90%

 
SOLVED
Go to solution
Peter A. Berger Jr.
Regular Advisor

Auto email when mountpoint exceeds 90%

HP-UX newbie here. Was wondering how it would be possible to have UX auto-sense/send me an email when a mountpoint exceeds 90% utilization. Perhaps pulling info from a BDF?
Any help/utilities/suggestions would be awesome. Thanks. :)
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor
Solution

Re: Auto email when mountpoint exceeds 90%

Hi Peter:

This question was asked just this morning. There are various scripts in this thread:

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

Regards!

...JRF...
Helen French
Honored Contributor

Re: Auto email when mountpoint exceeds 90%

I have this script, which runs from cron every day:

#!/bin/sh
THRESHHOLD="9[0-9]%"
THRESHHOLD1="100%"
NOTIFY="sysadmins"
HOSTNAME=`hostname`
for FILESYSTEM in `bdf -l | grep -e $THRESHHOLD -e $THRESHHOLD1| awk -v HOSTNAME =\`hostname\` '{print $6":"HOSTNAME":"$5}'`
do
MESSAGE=`echo $FILESYSTEM | awk -F: '{print "The " $1 " file system on "
$2 " is at " $3 " utilization"}'`
mailx -s "$MESSAGE" my_mail_address.com < /dev/null
done
Life is a promise, fulfill it!
Sridhar Bhaskarla
Honored Contributor

Re: Auto email when mountpoint exceeds 90%

Hi,

Put this simple script in cron. Man "cron" for more details. Depending on how often you want to check the usage, you will need to decide the interval. Run it manually and see if it works as it is supposed to.

#!/usr/bin/ksh
#Add the mount points below
MOUNTS="/db001 /db002 /home /perf"

#Replace this with your id
MYMAIL=your_id@yourmail.com

THRESHOLD=90

STAMP=0

for MOUNT in $MOUNTS
do
USED=$(df -k $MOUNT |awk '/% allocation used/ {print $1}')
if [ $USED -ge $THRESHOLD ]
then
echo $MOUNT: $USED >> /tmp/mount$$
STAMP=1
fi
done

if [ $STAMP = 1 ]
then
mail /tmp/mount$$
fi
mailx -s "Filesystem Usage Report" $MYMAIL < /tmp/mount$$

rm -f /tmp/mount$$


-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ian Dennison_1
Honored Contributor

Re: Auto email when mountpoint exceeds 90%

Peter,

Various ways,

1. Glance / Measureware - Very good monitoring and trending product, that can be used to set alarms for Disk Space used and to alert based on these.

2. Scripting - As in the above posting, you can write a script to monitor space and report. However, you need to judge how quickly you need to know about the lvol reaching the limit. You also need to cater for exceptions (database filesystems can be exempted, as can other static filesystems like copies of CDs, etc).

Bdf can be used to good effect for scripting, but you have to watch the double-line effect

eg. /dev/vgXXX/lvol22 # End line 1
222222 3333333 444444 59% /mntpt1 # End Line 2

Share and Enjoy! Ian

Building a dumber user
Ian Dennison_1
Honored Contributor

Re: Auto email when mountpoint exceeds 90%

bdf| grep -v "Filesystem" | awk 'BEGIN { } NF == 1 { first=$1 ;break} NF != 6 { print first" "$1" "$2" "$3" "$4" "$5 }
NF == 6 { print $1" "$2" "$3" "$4" "$5" "$6 }' |awk '$1 !~ /:/ { print $0 }'

Sorry, here's the code to bring bdf back to single lines for each entry (excluding NFS Mounts).

Share and Enjoy! Ian
Building a dumber user
Jack C. Mahaffey
Super Advisor

Re: Auto email when mountpoint exceeds 90%