how to prevent multiple email notifications from monitoring script

Hi everyone,

I am in the process of trying to decide the correct way to solve a particular scripting/email issue I have and would appreciate any advice.

We have a cronjob running every 10 mins to check disk size on the server and if this exceeds a certain percentage then it will email a notification warning out to relevant people.

However once the first email has been sent I would like it to refrain from sending a fresh email every 10 mins until the disk size have been resolved - maybe then just send a reminder every hour or two.

The only way I can think of (with my limited scripting knowledge) would be to create a separate file which would be used as a 'checking' file to see when the last email was sent. So if the checking file indicates that an email was sent in the last hour then no emails will be sent etc.

Hope this makes sense as did not want to write a long expanse of details. Also this is to run on Solaris 9.

Any suggestions gratefully received.

Thanks

Si

I had an HTTP monitoring Perl script written some years ago driven by cron once every 5 minutes with similar reporting facility. What I did was even simpler - to create a state file with just "0" or "1" to indicate whether an alert mail has been sent before. When a later run sees "1", it will not send the mail again (but will still log the error). When the service is up again, the next run will reset the file content to "0". Basically, if there was no file or the file content is "0", a mail will be sent and overwrite the file with a "1" if some tests failed.

As a simple monitoring facility, it worked for me. Of course, you may wish to also save a checksum of the error message and compare against the current message to see whether the error message has changed, in which case I think another message should be sent even though some trouble mail has been sent in the past.

Hi cbkihong,

Thank you very much for the swift reply!

I had not thought of that method using the error state of the command. Thinking about it this should work fine and will save me from having so many emails.

Thanks again.

Si