Operating System - HP-UX
1833875 Members
1746 Online
110063 Solutions
New Discussion

Script having problem for file system monitoring.

 
SOLVED
Go to solution
Narendra Uttekar
Regular Advisor

Script having problem for file system monitoring.

Hi,
I am using this filesystem monitoring script, But the problem with this script is that it is not sending a mail when the mount point "/oracle/JKD/saparch" and "/oracle/JKD/102_64" exceeds the threshold it is working fine for all other mount points which are in the check.conf file.
Please find the diskspace.sh script as below,
#!/usr/bin/ksh

# This script may be used to check for available disk space on any local server
# To change the configuration use /home/check.conf

# Debugging purposes
#set -x

PATH=/usr/bin:/usr/sbin
CONF_FILE=/home/check.conf

# Source default env vars
. ${CONF_FILE}

# Count number of FS to check
i=${#FS[*]}

# echo max - $MAX_THRESH
# Check each Filesystem
while [ ${i} -gt 0 ]
do
PCT=`bdf ${FS[$i]} | grep -v Filesystem | cut -c 45-47`
if ((PCT>THRESH[$i]))
then
echo " ${THRESH[$i]} "
if (("${PCT}>${MAX_THRESH}"))
then
echo "Out of disk space for `bdf ${FS[$i]}` on `hostname`" |sendmail name@xxxxx.com
else
echo "Threshold exceeded for `bdf ${FS[$i]}` on `hostname`" |sendmail name@xxxxx.com
fi
fi
let i=i-1
done
exit 0

And also check.conf script as below,
# MAX_THRESH is the max thresh before sending out a critical message
MAX_THRESH=91

# THRESH for each FS is the THRESH before sending a message
FS[1]=/ ;THRESH[1]=80
FS[2]=/stand ;THRESH[2]=70
FS[3]=/var ;THRESH[3]=80
FS[4]=/usr ;THRESH[4]=80
FS[5]=/tmp ;THRESH[5]=90
FS[6]=/opt ;THRESH[6]=97
FS[7]=/oracle/JKD/saparch ;THRESH[7]=50
FS[8]=/usr/sap/JKD ;THRESH[8]=70
FS[9]=/sapmnt/JKD ;THRESH[9]=85
FS[10]=/oracle ;THRESH[10]=50
FS[11]=/oracle/JKD ;THRESH[11]=90
FS[12]=/home ;THRESH[12]=50
FS[13]=/oracle/JKD/102_64 ;THRESH[13]=35
FS[14]=/opt/sapbc47 ;THRESH[14]=85
FS[15]=/tmp/sapwork ;THRESH[15]=97
FS[16]=/share ;THRESH[16]=80

Thanks,
Narendra
7 REPLIES 7
Dennis Handly
Acclaimed Contributor

Re: Script having problem for file system monitoring.

What are the "set -x" results for i == 7 and 13?
What does bdf show for each?
Steven E. Protter
Exalted Contributor
Solution

Re: Script having problem for file system monitoring.

Shalom Narenda,

I don't see anything wrong with the script. If it works for other file systems it should work for those. It could be Oracle isn't cutting an extent at a convenient time and when it does, it jumps the file system from 89% to 101% capacity.

You might want to have the dba change the size of oracle extents to a smaller number. Its not possible for me to test your script in a realistic condition here.

There are other scripts for this purpose that might work, but that won't help if what I suspect is happening is true.

If I am right about oracle trying to cut a large extent, then perhaps simply setting the threshold lower will do the job.

Also oracle database has a built in limit, maybe 100 extents after which it won't cut new extents. It gives an out of space message after that, when in fact it is not out of space, and a dba needs to modify the maximum number of extents permitted on the tablespace.

For your convenience:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=5827

My answer in this thread links to hundreds of syadmin scripts you might find helpful.

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1336882

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
OldSchool
Honored Contributor

Re: Script having problem for file system monitoring.

As Dennis alluded to above, I'd suspect that the output of bdf isn't what you think it is for the two filesystems in question (i.e. wrapped output / different format.)
James R. Ferguson
Acclaimed Contributor

Re: Script having problem for file system monitoring.

Hi Narendra:

The big red flag that I see in scanning your script is this:

# PCT=`bdf ${FS[$i]} | grep -v Filesystem | cut -c 45-47`

Do you believe that the percent used for every filesystem is always going to be in columns 45-47? I don't. You should use a shell 'read' or something like 'awk' to pluck the fields in the line as seperated by whitespace. What you get with your 'cut' isn't probably what you think.

Regards!

...JRF...
Tingli
Esteemed Contributor

Re: Script having problem for file system monitoring.

I think it is bdf problem as it sometimes with two lines or sometimes with only one line output. Suggest using df -k to do the job as its output is consistent.
Roopesh Francis_1
Trusted Contributor

Re: Script having problem for file system monitoring.

You can use Bill Hassellâ bdf script instead of bdf command.hope that will solve your issue
https://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1048509&admit=109447626+1246933165093+28353475
Narendra Uttekar
Regular Advisor

Re: Script having problem for file system monitoring.

Thanks for the solution.