1827808 Members
1992 Online
109969 Solutions
New Discussion

Re: need a script

 
SOLVED
Go to solution
Maaz
Valued Contributor

need a script

Hi Gurus

need a script that reports/informs via email to imv@xyz.org if any of the filesystem is 90%(or more) used

Regards
Maaz
5 REPLIES 5
labadie_1
Honored Contributor

Re: need a script

See Nagios or such tool, or just parse the output of a
df -k
or
df - h
TwoProc
Honored Contributor
Solution

Re: need a script

It's not quite what you're asking for - but I mail myself this every morning...

----< script start> -------------------
#!/bin/ksh
disk_ck()
{
echo "\n DISK SYSTEMS"
echo " ------------\n"
echo " Disk Utilization sorted by percent utilization"
echo " - - - - - - - - - - - - - - - - - - - - - - - "
export stat_tmp="/var/tmp/statck.disk.$$"
bdf > $stat_tmp
head -1 $stat_tmp
grep -v ^Filesystem $stat_tmp | sort -k 5

echo "\n Disks Over 90% Full "
echo " - - - - - - - - - - "
integer FULLCT=`grep -v ^Filesystem $stat_tmp | \
grep -e "9.%" -e "1..%" | sort -k 5 | wc -l `
if [ $FULLCT -gt 0 ]
then
head -1 $stat_tmp
grep -v ^Filesystem $stat_tmp | grep -e "9.%" -e "1..%" | sort -k 5
else
echo " ... No filesystems found over 90 percent full"
fi
rm $stat_tmp
}

disk_ck | sendmail imv@xyz.org

--- < script end >----------------------

You could make a few changes to this to send mail only when needed. Send all of the output to a tmp file, and use the last "if else" statement above as a basis of whether or not to use sendmail at that point in the execution to send and email to you.

We are the people our parents warned us about --Jimmy Buffett
TwoProc
Honored Contributor

Re: need a script

Well Maaz, I just realized that script I put is for HPUX, not Linux, because it uses "bdf" instead of "df". You'd have to do some work to make it work in Linux. Sorry about the posting error.
We are the people our parents warned us about --Jimmy Buffett
Ivan Ferreira
Honored Contributor

Re: need a script

Please check:

http://forums12.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1212609819425+28353475&threadId=419106
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Maaz
Valued Contributor

Re: need a script

nice help, thanks ;)
Regards