Operating System - HP-UX
1821801 Members
3195 Online
109637 Solutions
New Discussion юеВ

Re: File System Monitor Script

 
SOLVED
Go to solution
hpuxrox
Respected Contributor

File System Monitor Script

Hi,

Im looking for a nice clean way to monitor file systems and if the file system exceeds a threshold of, lets say, 90% full, an email is sent out notifying me of the problem.

10 REPLIES 10
Mark Grant
Honored Contributor

Re: File System Monitor Script

This one allows different thresholds for different filesystems

You might need to tweak it a bit for your environment.

A configuration file looks like the following

default
warning=94
critical=95
rearm=59
actioned=unix

*/arch
actioned=database


# Follwing entry is to match datbase filesystems and not /usr
/u[0-9]*
warning=99
critical=99
actioned=database

/cdrom
warning=101
critical=101
Never preceed any demonstration with anything more predictive than "watch this"
hpuxrox
Respected Contributor

Re: File System Monitor Script

Thanks, but im looking for something with no real hooks into anything like OVO. If it hooked in EMS, that would be ok, but Im looking for something that is very basic unix command level stuff that I can put in a cron job.
Sridhar Bhaskarla
Honored Contributor
Solution

Re: File System Monitor Script

Hi,

This is a very simple script that can notify you if the filesystem reaches a certain threshold.

#!/usr/bin/ksh
LIMIT=90
STAMP=0
EMAIL=your_id@yourdomain.com

cleanup()
{
rm -f /tmp/fs$$ /tmp/fsreport$$
}

trap cleanup 0 1 2

for FS in $(df -l|awk '{print $1}')
do
USED=$(df -k $FS|awk '/allocation used/ {print $1}')
if [ $USED -ge $LIMIT ]
then
echo "$FS: $USED" >> /tmp/fs$$
STAMP=1
fi
done

if [ $STAMP = 1 ]
then
echo "Below are the Filesystems that exceeded the capacity\n\n" > /tmp/fsreport$$
cat /tmp/fs$$ >> /tmp/fsreport$$
mailx -s "Filesystem Warnings" $EMAIL < /tmp/fsreport$$
fi

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
hpuxrox
Respected Contributor

Re: File System Monitor Script

Thanks Sridhar!! That was what I was looking for.

BTW: Are you still with PCS? Or are you the same Sridhar?
Mark Grant
Honored Contributor

Re: File System Monitor Script

Yates,

The OVO thing is an option. If you don't do "-opc" then it alerts to your screen. You can then do whatever you like. However, I do appreciate that it's a bit old and craggy loooking now :)
Never preceed any demonstration with anything more predictive than "watch this"
Sridhar Bhaskarla
Honored Contributor

Re: File System Monitor Script

Hey Yates!!!

Is that you?. Yeah I am the same Sridhar at the same place. How are you?.

Cheers,
Sri

PS: Please don't make me feel guilty by giving points to this message. :-)
You may be disappointed if you fail, but you are doomed if you don't try
Steven E. Protter
Exalted Contributor

Re: File System Monitor Script

My version:

late, but possibly useful

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
hpuxrox
Respected Contributor

Re: File System Monitor Script

Sridhar,

Doing good, yourself?

Brain still there? If so, tell him I said Hi.

Yates
Mark Ellzey
Valued Contributor

Re: File System Monitor Script

Yeates,

Here's one I wrote that will check remote hosts from your local host. Just create a text file of the hosts you want to check and provide that file path to the script. You can modify it to send you email only if the filesystems are over 90%, or as I do, have it email me every day. Works with HP and Sun.

Regards,
Mark
Geoff Wild
Honored Contributor

Re: File System Monitor Script

If you want to do some nice monitoring, and can't afford OVO, have a look at Big Brother:

http://bb4.com/

The disk monitoring is very customizable - you can set different thresholds for different filesystems.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.