Re: Set threshold for email with smartd.conf

Christian Franke <[email protected]>
Newsgroups gmane.linux.utilities.smartmontools
Message-ID <[email protected]>
Jake Moore wrote:
> I'm using smartd.conf to monitor the performance of a few Ubuntu 8 and
> Ubuntu 12 servers. There is a line in the file that will notify when the
> Reallocated_Sector_Ct changes. I want to do this, but to only email when
> the raw value passes a certain threshold.
>
> My initial thought was to write a script that greps the output of
> smartctl and sends an email when the RAW column reaches a number, but it
> seems like using the daemon would be much cleaner.

Specifying a warning threshold for a raw value is not possible.

Try "-R 5! -r 5!" and send email through some wrapper script with "-M 
exec SCRIPT". The script could suppress the email if (and only if) the 
message reports a Reallocated_Sector_Ct value below some threshold.

This may work for threshold 100:

#! /bin/sh
n=$(echo "$SMARTD_MESSAGE" | sed -n \
  's,^.* Reallocated_Sector_Ct changed .* to .*\[Raw \([0-9]*\).*$,\1,p')

[ -n "$n" ] && [ "$n" -lt 100 ] && exit 0

exec /usr/bin/mail "$@"
##

Thanks,
Christian


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.