Operating System - HP-UX
1824216 Members
3185 Online
109669 Solutions
New Discussion юеВ

Re: script required to monitor disk space usage

 
SOLVED
Go to solution
Jagadesh_2
Regular Advisor

script required to monitor disk space usage

Hi All,

/dev/hd3 1048576 637700 40% 579 1% /tmp
/dev/REMlv01 7340032 2017712 73% 22145 5% /u01
/dev/REMlv02 18874368 7538816 61% 31 1% /u02
/dev/REMlv03 6291456 3622456 43% 27 1% /u03
/dev/REMlv04 12582912 5962408 53% 82 1% /u04
/dev/REMlv00 2097152 1536616 27% 3348 1% /app/remedy

I need a single script which can monitor the following filesystems. If the filesystem usage crosses 65% then it shoud through a mail alert to me. How can i go about in doing the same. I have a script to monitor a single filesystem

while true
do
u04=`df -k|grep REMlv04|awk '{print $4}' | cut -c -2`
if [ $u04 -gt 60 ]
then
echo "/u04 File System is getting full " > /home/in263054/mail
mail -s "Filesystem Warnings" test@test.com < /home/in263054/mail
fi
break
done


Thanks in advance
S.Jagadesh
5 REPLIES 5
Naveej.K.A
Honored Contributor
Solution

Re: script required to monitor disk space usage

Hi Jagadesh,

Pls find attached the perl script taken from :

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=178514

You will find a lot more in Bill's thread.

Regards,
Naveej
practice makes a man perfect!!!
Julio Yamawaki
Esteemed Contributor

Re: script required to monitor disk space usage

Hi,

With this script, you can use a standard limit or you can define a limit for each tablespace:

Script---:
EMAILS="YourEmail@domain.com"
TABSPACO=/usr/local/etc/TabSpaco
TABMSG=/tmp/msg.$$
>${TABMSG}
BDF=/tmp/bdf.$$
>${BDF}
bdf | grep -v Mounted >${BDF}
while read a b c d e f
do
spc=`echo $e|sed 's/%//'`
set `grep $f $TABSPACO` >/dev/null 2>/dev/null
SPC=$1
if [[ $SPC -eq "" ]]
then
SPC=65
fi
if [[ $spc -gt $SPC ]]
then
echo "$f => % occupied = $e" >>${TABMSG}
fi
done <${BDF}
test -s ${TABMSG}
if [[ $? -eq 0 ]]
then
elm -s "FILESYSTEM SPACE" $EMAILS <${TABMSG}
fi
rm ${BDF}
rm ${TABMSG}

-->TabSpaco - modify as required:
80 /
80 /stand
80 /var
95 /usr
80 /usr/local/samba
80 /tmp
80 /sys
99 /opt
80 /home
Steve Steel
Honored Contributor

Re: script required to monitor disk space usage

Hi


You already got some good answers

look at

www.shelldorado.com

for more good scripting info


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Muthukumar_5
Honored Contributor

Re: script required to monitor disk space usage

You can control all file system by redirecting all file system informations into a temporary file as,

#!/bin/ksh
FSFILE=/tmp/fs.log

# Remove first line
# You can also use bdf.
df -k | grep -v 'Mounted' > /tmp/fs.log

while read fs use avail per;
do
if [[ $(echo $per|cut -d% -f 1) -gt 65 ]]
then
mail -s "$fs in $(hostname) is over 65%" test@test.com
fi
done < /tmp/fs.log

# end
exit 0

It is good to put this script in cron schedular to execute per minute.

hth.
Easy to suggest when don't know about the problem!
Andrew Merritt_2
Honored Contributor

Re: script required to monitor disk space usage

You could use the Event Monitoring Service, under Resource Management in SAM to do this.

For each filesystem, you can set the minimum amount of free space (I don't think you can give a percentage, unfortunately), and it can be configured to send you email when it crosses the limit.

See http://www.docs.hp.com/en/B7612-90015/index.html for more details.

Andrew