Operating System - HP-UX
1836607 Members
1948 Online
110102 Solutions
New Discussion

Re: Script to monitor the filesystem effectively

 
bruceedgar
Occasional Advisor

Script to monitor the filesystem effectively

I would like to write a script to monitor the file system effectively , from the bdf output we have to collect the file system names and percentage then we have to get the file sytem which you want to monitor at the time of running script and limmits as arguments .
als o it has to send mail with hostname.

EX: ./moniotr /tmp 80 90
It has to send warning mail if it reaches 80%
It has to send Alert mail if it reaches 90%
I have refered
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=51050
so pls try to help over it.
Thanks to all .
4 REPLIES 4
Robert-Jan Goossens
Honored Contributor

Re: Script to monitor the filesystem effectively

Doug Burton
Respected Contributor

Re: Script to monitor the filesystem effectively

If you look at the script I gave on the thread you mentioned above you could change the line:

$percent -ge 90 to $percent -ge 80

and the line

$percent -ge 95 to $percent -ge 90

You will need to change the pager email to whatever you like to use.

NOTE: It's an old script which I'm sure has been put together a lot "gooder" by others but what the heck, it works.
Bill Hassell
Honored Contributor

Re: Script to monitor the filesystem effectively

This script (diskspace.sh) will do everything for you. It also avoids the problem of an email storm that happens when a filesystem grows and it takes a few hours to fix it. Rather than endlessly send notices because a filesystem has exceeded a limit, it sends only one notice, then waits until it has grown by some additional percent and sends another. It can send email, add a note to syslog, even notify OpenView OpCenter.


Bill Hassell, sysadmin
Ernesto Cappello
Trusted Contributor

Re: Script to monitor the filesystem effectively

Hi Bruce

#################################################
#!/bin/sh
# Check filesystem /tmp

DIR=/tmp
EMAIL_ADDRESS="name.surname@company.com"

df -k $DIR > /tmp/df_info

cat /tmp/df_info | awk '$0 !~ /^F/' | sed 's/'%'/''/' > /tmp/df_out

PERCENT=`cat /tmp/df_out | awk '{print $5}' `

if [ "$PERCENT" -ge "80" ]
then
mailx -s "WARNING Filesystem $DIR (`hostname`): $DIR is at $PERCENT%" $EMAIL_ADDRESS <
/tmp/df_info
fi

if [ "$PERCENT" -ge "90" ]
then
mailx -s "ALERT Filesystem $DIR (`hostname`): $DIR is at $PERCENT%" $EMAIL_ADDRESS <
/tmp/df_info
fi

rm /tmp/df_info
rm /tmp/df_out

#################################################

Best Regards,
Erenesto