Operating System - Linux
1829143 Members
1974 Online
109986 Solutions
New Discussion

Re: script for file system alert

 
gab_in
Regular Advisor

script for file system alert

Hi,

Do you have any script which I can use on RedHat Linux system to get the e-mail notification, once the file system reaches the threshhold limit (e.g. /opt is 97%).

Thanks in advance
Gab
4 REPLIES 4
Sameer Kelkar
Advisor

Re: script for file system alert

Steven E. Protter
Exalted Contributor

Re: script for file system alert

Shalom,

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

Its a HP-UX thread but the code will work for Linux.

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
Steven McCoy
Valued Contributor

Re: script for file system alert

If you're running an HP Proliant server, the Proliant Support Pack (more specifically, the System Management Homepage) supports filesystem threshold notifications:

http://h20000.www2.hp.com/bizsupport/TechSupport/DriverDownload.jsp?prodNameId=3716247〈=en&cc=us&prodTypeId=18964&prodSeriesId=3716246&taskId=135

Note: It by default sends the email to 'root' on the local system. I typically just setup an alias to my email address for root in /etc/aliases for sendmail.

HTH
Fredrik.eriksson
Valued Contributor

Re: script for file system alert

If you just want something that is a simple notifier,

#!/bin/bash
threshold="85"
used=$(df -h $1 | grep "\%" | awk '{print $5}' | sed -e "s/\%//)
[ $used -lt $threshold ] || mail -s blahblah and all the other things you want to do

Something like that would do (untested thou) I believe. This looks at the procentages the device supplied.
Usage is, ./script.sh /home

I would use some other program to handle this thou, should be alot of programs out there able to do this. Maybe Cacti or Nagios would be an idea depending on how big your environment is.

Best regards
Fredrik Eriksson