Operating System - HP-UX
1830931 Members
2094 Online
110017 Solutions
New Discussion

How to verify and send a alarm with file system is 90% ?

 
SOLVED
Go to solution
Ricardo Bassoi
Regular Advisor

How to verify and send a alarm with file system is 90% ?


I want to check using df -k if my FS /var is with 90%. If this is true send an alarm via email.

$ df -k
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/cciss/c0d0p7 379303 119969 239751 34% /
/dev/cciss/c0d0p1 51342 7591 41100 16% /boot
/dev/cciss/c0d0p6 4553920 2532480 1790108 59% /home
/dev/cciss/c0d0p5 1007928 509444 447284 54% /opt
none 1029788 0 1029788 0% /dev/shm
/dev/cciss/c0d0p2 9224520 2224844 6531088 26% /usr
/dev/cciss/c0d0p8 252863 36731 203077 16% /var



Regards,

Ricardo
If you never try, never will work
8 REPLIES 8
John Poff
Honored Contributor
Solution

Re: How to verify and send a alarm with file system is 90% ?

Hi,

One way to do it is with a shell script:

PCT=$(df -k /opt | tail -1 | awk '{print $1}')
if ((PCT>90)); then
echo "/opt is over 90% full" | mailx -s "/opt over 90% full" ricardo
fi


..or something like that.

JP
Robert-Jan Goossens
Honored Contributor

Re: How to verify and send a alarm with file system is 90% ?

Hi Ricardo,

This link will provide you the scripts.

http://bizforums.itrc.hp.com/cm/QuestionAnswer/1,,0x21cd0bce6f33d6118fff0090279cd0f9,00.html

Kind regards,

Robert-Jan.
Jose Mosquera
Honored Contributor

Re: How to verify and send a alarm with file system is 90% ?

Hi,

Try this:

VALUE=`df -k|grep /var|awk '{ print $5 }'|awk -F"%" '{ print $1 }'`
if [ $VALUE -gt 89 ]
then
echo "Subject: /var at $VALUE%"|sendmail user@domain
fi

Rgds.
A. Clay Stephenson
Acclaimed Contributor

Re: How to verify and send a alarm with file system is 90% ?

This should be a very good starting point for you. Check_disk_space.sh should be cron'ed to run every 20 minutes or so. It uses a check_disk_space.cf file in the current directory to allow you to set not only the maximum threshold for critical warnings but also limits for each file system.

If you cron the script, you will probably want to set an absolute path for the .cf file rather than using the current directory.

If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: How to verify and send a alarm with file system is 90% ?

Here's a sample .cf file; edit it to fit your needs.

If it ain't broke, I can fix that.
MANOJ SRIVASTAVA
Honored Contributor

Re: How to verify and send a alarm with file system is 90% ?

Do the following



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 .

Also look here :

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

Manoj Srivastava
harry d brown jr
Honored Contributor

Re: How to verify and send a alarm with file system is 90% ?

Ricardo,

http://www.bb4.com/ is a good source for many other things also.

live free or die
harry
Live Free or Die
Rajeev  Shukla
Honored Contributor

Re: How to verify and send a alarm with file system is 90% ?

There is one real good site called www.hotscripts.com where you'll find a lot of solutions for these kind of issues.

Cheers
Rajeev