If you're on a Linux server, consider
using an local SMTP relay (eg: nullmailer); this way, your
program only needs to worry about using sendmail and the
relay is the only point where you need to supply credentials.
However, does monit support sending mail through sendmail?
If not, then this wouldn't help...
Sorry; I don't use monit enough to know if it works this
way or not, but I do use the nullmailer trick on most of
my local systems.
On 07/24/2013 04:54 AM, Callum Macdonald wrote:
You can use the first 255 chars of the output on an exec test if it fails, but that probably won't offer you enough customisation in this case.
The downside is that you're now reliant on your script being able to successfully send email AND monit being able to send email, so you potentially have two copies of your SMTP credentials, etc.
For example, I use monit to monitor mysql replication lag with the exec feature. The script I've written exits with an error if the delay is above a threshold, and writes the delay to stderr, that way I get a regular monit email which contains the number of seconds behind master, and I get a matching SUCCEEDED email once the issue has sorted itself out.
Cheers - Callum.
|