Operating System - HP-UX
1833863 Members
2180 Online
110063 Solutions
New Discussion

find a simply way to monitor the fs size

 
SOLVED
Go to solution
emily_3
Frequent Advisor

find a simply way to monitor the fs size

Hello,

I would like to monitor one fs size every day so that once it beyond 90%, it can send a notification to the person. Do you have any good simple way? Thanks.

12 REPLIES 12
Bharat Katkar
Honored Contributor

Re: find a simply way to monitor the fs size

Hi,

I can just line out the script for you:

var1=`bdf|grep lvol3|cut -d " " -f 11|cut -c 1,2`
while true
do
if [ $var -gt 90 ]
then
echo " File System is getting full "
==> Use sendmail command to send notification <===
fi

That's it.
Regards,

You need to know a lot to actually know how little you know
Bharat Katkar
Honored Contributor

Re: find a simply way to monitor the fs size

assuming that your filesystem is on lvol3

also in if statment read var as var1 .. typo

Regards,
You need to know a lot to actually know how little you know
Hoang Chi Cong_1
Honored Contributor

Re: find a simply way to monitor the fs size

Hi emily

Here's a script that we use to notify us if any filesystems have exceeded 90% usage.
It runs every 15 minutes, but the script is setup to only e-mail you once per hour.

Gooluck
Regard,
HoangChiCong
Looking for a special chance.......
Nguyen Anh Tien
Honored Contributor
Solution

Re: find a simply way to monitor the fs size



I have some slightly modify Bharat Katkar's scipt.
Like this:
=========================================
while true
do
var=`bdf|grep lvol3|awk '{print $5}'|cut -f 1 -d "%"`
if [ $var -gt 50 ]
then
echo " File System is getting full "
#==> Use sendmail command to send notification <===
fi
done
=========================================
PAY ATTENTION ON
var=`bdf|grep lvol3|awk '{print $5}'|cut -f
MUST BE PUT IN WHILE LOOP.
HTH
tienna
HP is simple
Bharat Katkar
Honored Contributor

Re: find a simply way to monitor the fs size

Hi tein,
Thanks for correcting.... It was all in hurry
Also "done" was missed out.
Regards,
You need to know a lot to actually know how little you know
Fred Martin_1
Valued Contributor

Re: find a simply way to monitor the fs size

Here's a script that I wrote for this purpose. It actually watches all the file systems. You can define two limits - a limit for critical file systems and a limit for non-critical file systems. And you can define which file systems are critical, and which are not (any file system not defined as non-critical is considered critical).

For example, /var can be defined as a critical system that will warn you if it goes over 75%, but /test could be non-critical and warn you if it goes over 95%

All is defined in variables at the top, the limits and systems are up to you.

It also can ignore some file systems (CD_ROM for example).

The script can send email and/or an email page as well, and continues to do so until the issue is fixed.

I run this script every 15 mins in root cron.
fmartin@applicatorssales.com
Bill Hassell
Honored Contributor

Re: find a simply way to monitor the fs size

I have attached a script which looks complicated but that's because what you're asking is a lot more complicated than it sounds. Most bdf-based scripts become a nightmare when a filesystem fills up because there are no limits on the number of messages. If your script runs every 5 minutes and you're out of town, your pager ends up with hundreds of messages. The attached script allows you to exclude cdfs (always 100% full) and NFS by specifying only certain filesystem types. Then it has a default setting for the percentage full limit, and most important, the next growth value when another message is sent.

This is the key to preventing a pager meltdown. The growth value, say 3%, means that a filesystem can be at 90% (which is over the selected limit) and you'll get no additional pager messages until it grows to 93%, then nothing until it hits 96%. So worst case, 90% limit, 3% growth means that you'll only get 4 messages max if the filesystem grows to 100%. Also, the script won't send anything if the filesystem shrinks a bit even though it's well over the base limit.

But before you implement this, verify that you can mail a simple message to your pager or email address:

mailx -s "test msg" me@mycompany.com < /etc/issue


Bill Hassell, sysadmin
Fred Martin_1
Valued Contributor

Re: find a simply way to monitor the fs size

Somehow I dropped the attachment referenced in my post, above. Hopefully it will be on this one...
fmartin@applicatorssales.com
KapilRaj
Honored Contributor

Re: find a simply way to monitor the fs size

This takes an fs as an argument

#!/usr/bin/sh
if [ $# -lt 1 ]
then
echo "Usage : $0
exit 8
fi

MESG=`bdf |grep $1|awk '{if ( $5 >= 90 ) print "FSFULL" }'`
if [ $MESG = "FSFULL" ] 2>/dev/null
then
echo "Filesystem full"
echo "Filesystem full" |mail -s PANIC kaps@kaps.com
fi


Regds,

Kaps
Nothing is impossible
Geoff Wild
Honored Contributor

Re: find a simply way to monitor the fs size

Or,...if you want to monitor disk space and a whole lot more, look at OVO or BigBrother:

http://www.bb4.org/

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.
David Nixon
Valued Contributor

Re: find a simply way to monitor the fs size

For this I would use the Event Monitoring System. You can set up monitoring from under the Resource Management section of SAM.
EMS can monitor for the event
of a file systems available MB falling below
a threshhold value. The notifications go
to email, or logs. It is often useful to set up an "emswarn" email alias.

David.


Florian Heigl (new acc)
Honored Contributor

Re: find a simply way to monitor the fs size

Most SNMP Agents can do that automatically - using EMS as already stated might be even easier.
yesterday I stood at the edge. Today I'm one step ahead.