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.

On 24 Jul 2013, at 12:50, Thorsten Kampe <[email protected]> wrote:

> * Callum Macdonald (Wed, 24 Jul 2013 12:30:43 +0200)
> 
>> I'd suggest the simplest approach is probably to use `if failed then exec 
>> script` and `if succeeded then exec script`, where the two scripts send the 
>> email and then copy the file.
> 
> You're probably right. I couldn't see any option to attach files to an 
> alert email or to modify the body with output from an external command.
> 
> Thorsten
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to