System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Filesystem monitoring script

SOLVED
Go to solution
Narendra Uttekar
Regular Advisor

Filesystem monitoring script

Hi,
I am running this script in cron job...but the problem is that even if the threshold doesn't exceed i am getting an blank e-mail for this script and if the threshold exceed i am getting the mail for the alerts which is fine. But i don't want any blank mail if threshold doesn't exceed as this unnecessary full my inbox.
bdf /oracle/TCP/saparch |awk 'NF==1{f=$0;getline;$0=f$0}{if($5+0>65)print}' > mailx -s"FileSystem on HOSTNAME" narendra@xxxxx.com

Thanks,
Narendra
15 REPLIES
Kapil Jha
Honored Contributor
Solution

Re: Filesystem monitoring script

You are getting this mail because everytime cron is running its sending output of the command to you mail as u asked it to do.
When ur filesystem is not >65 output of bdf /oracle/TCP/saparch |awk 'NF==1{f=$0;getline;$0=f$0}{if($5+0>65)print}' is balnk and its going to ut mailbox.

If you do not want blank mails you have to guide it using if else statment
if output >65
mail
else
nothing ;)

Let us know if you need exact statments.

BR,
Kapil+
I am in this small bowl, I wane see the real world......
Suraj K Sankari
Honored Contributor

Re: Filesystem monitoring script

Hi,

Please download this file (bdfmesg) from below link you will find this is a great tool written by Mr.Bill Hassell.

http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1326767

Just give

#bdfmesg -P 80 ##to find all file system which is using 80 or more then 80

Like so many output you can take from bdfmesg

Many Thanks to Mr.Bill Hassell to create a nice and useful tool.

Suraj
Narendra Uttekar
Regular Advisor

Re: Filesystem monitoring script

Hi,
Kapil thanks for the info...But please can you send me the exact syntax, so that i can modify the same.

Thanks,
Narendra
Dennis Handly
Acclaimed Contributor

Re: Filesystem monitoring script

There are a bunch of scripts to handle thresholds in this thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1324214
Kapil Jha
Honored Contributor

Re: Filesystem monitoring script

you may have to put this line in some scripts say..abc.sh
#!/usr/bin/sh
abc=`bdf /oracle/TCP/saparch |awk 'NF==1{f=$0;getline;$0=f$0}{if($5+0>65)print}'`

if [ abc != null ] ; then
abc > mailx -s"FileSystem on HOSTNAME" narendra@xxxxx.com
else
echo "free" >/dev/null
fi


BR,
Kapil+
I am in this small bowl, I wane see the real world......
Narendra Uttekar
Regular Advisor

Re: Filesystem monitoring script

Hi,
Kapil i tried your script but while running gives an error [./disk2.sh[4]: abc: not found.]
I don't know much of the scripting, please let me know what to correct.

Thanks,
Narendra
Narendra Uttekar
Regular Advisor

Re: Filesystem monitoring script

Hi,
Kapil for monitoring the file system i am using this 2 scripts. But the problem with this script is that it doesn't sent me the alert for /oracle/TCP/saparch , /oracle/TCP/102_64 and /usr/sap/TCP. For all other file systems i am getting alerts. I don't know why it is not working as expected. That's why i thought i will run other script to monitor this file system.
Please find the attached scipts, please let me know if any correction required so that i can modify the same, so that i can start receiving the alerts for this file system as well.
Narendra Uttekar
Regular Advisor

Re: Filesystem monitoring script

The second script is attached now...
Viktor Balogh
Honored Contributor

Re: Filesystem monitoring script

hi narenda,

this line has bad syntax:
if (("${PCT}>${MAX_THRESH}"))

the correct way to check if the percent is larger than allowed is:

if [ "${PCT[$i]}" -gt "${MAX_THRESH[$i]}" ]
then
.... do some useful things
fi


the '[ ]' symbols after the if statement are abbreviations for the test command, try 'man test' for more info...
( -gt is for "greater than" )


mark that you should use the arrays this way:

${VARIABLE[$index]}

****
Unix operates with beer.
Viktor Balogh
Honored Contributor

Re: Filesystem monitoring script

here is a possible solution in the attachment, just modify the ${CONF_FILE} variable to your needs!

****
Unix operates with beer.
Viktor Balogh
Honored Contributor

Re: Filesystem monitoring script

and this is the conf file with the thresholds...


****
Unix operates with beer.
Narendra Uttekar
Regular Advisor

Re: Filesystem monitoring script

Hi,
Viktor thanks for the info...i modified the scripts as you suggested, but while executing i am getting an error as below,
./disk.sh[17]: /tmp/sapwork: syntax error
./disk.sh[17]: /opt/sapbc47: syntax error
./disk.sh[17]: /sapmnt/TCP: syntax error
./disk.sh[17]: /usr/sap/TCP: syntax error

But /var /opt /home /tmp are excuting properly without an error but it gives an error /opt/sapbc47
Please advise what syntax correction needs to do...Thanks
Dennis Handly
Acclaimed Contributor

Re: Filesystem monitoring script

>./disk.sh[17]: /tmp/sapwork: syntax error

The config file should look like this:
FS[0]=/ ; TRESH[0]=40
...
Prashantj
Valued Contributor

Re: Filesystem monitoring script

Hi Narendra,

Pls try attached script. hope this will help u.

Thanks
Prashant
Good judgment comes from experience and experience comes from bad judgment.
Narendra Uttekar
Regular Advisor

Re: Filesystem monitoring script

Thanks for the solution.