Operating System - Linux
1827603 Members
3185 Online
109966 Solutions
New Discussion

script for checking fs usage

 
SOLVED
Go to solution
mjos
Super Advisor

script for checking fs usage

Hi,

Need help in configuring a simple script for cheking the file-system usage which will send alerts to e-mails listed in the script whenever the file system usage reaches 80% as warning alerts & 90% as critical alerts. The script should have by default be scanning all the file-systems configured in the system along with the nfs file-systems.
6 REPLIES 6
Matt Palmer_2
Respected Contributor

Re: script for checking fs usage

Hi,

if you have SMH installed you can go to the filesystem section there, and set you watermark for when you want SMH to send you alerts when filesys is n% full.

Its under 'File System Space Used'. It can send you a warning based on the watermark you set and a 'critical' based on your second watermark choice.

hope that helps

regards

Matt

mjos
Super Advisor

Re: script for checking fs usage

Sorry, I am not familiar with SMH & I dont know whetehr it is installed or not. How do I check that?
Matt Palmer_2
Respected Contributor

Re: script for checking fs usage

Hi,

the System Management Homepage comes as part of the Proliant Support Pack(PSP)/installed by default when you install the PSP.

Assuming you are on HP kit? you can install that, and all the work is already done for you.

Its a free download on the HP site.

regards

Matt
mjos
Super Advisor

Re: script for checking fs usage

Well, I dont have that kit now & the server is hosted remotely. I would be fine if somebody could provide me a simple script.
Mel Burslan
Honored Contributor
Solution

Re: script for checking fs usage

since I am not quite sure what you meant by "sending alerts" I am leaving that part to you by simply providing echo statements, in this script below. If you are just going to send an email, use mailx to send it with proper subject and text, or if you are going to send an alert to OV, use the opcmsg or whatever else it is today. Here is the simplest script I could come up with:

#!/bin/bash
df | grep ^"/" > /tmp/filesystem_names

for fs in `cat /tmp/filesystem_names`
do
df $fs > /tmp/currFS
ln=`cat /tmp/currFS |grep -v ^Filesystem| wc -l`
case $ln in
2) perctg=`tail -1 /tmp/currFS|awk {'print $4'}|cut -d"%" -f1` ;;
1) perctg=`tail -1 /tmp/currFS|awk {'print $5'}|cut -d"%" -f1` ;;
*) echo "There was an error with volume ${fs}. Check manually" ;;
esac

if [ $perctg -ge 80 ] && [ $perctg -lt 90 ]
then
echo "replace this line with your WARNING action for volume $fs"
fi

if [ $perctg -ge 90 ]
then
echo "replace this line with your CRITICAL action for volume $fs"
fi
done

Last but not the least, please take a few minutes of your time and assign points to the answers you have received so far.
________________________________
UNIX because I majored in cryptology...
mjos
Super Advisor

Re: script for checking fs usage

Thanks.