|
From: | Martin Pala |
Subject: | Re: Alert format question/feature request |
Date: | Wed, 7 Sep 2011 14:27:39 +0200 |
It is possible to use the "exec" action to run custom script when the event occurs. That script can then assemble the alert message including "top" output and send it using the "mail" command. Example usage: --8<-- if cpu usage > 90% for 5 cycles then exec "/usr/loca/bin/send_top.sh address@hidden" --8<-- where the /usr/loca/bin/send_top.sh script may look something like this: --8<-- #!/bin/bash OUTPUT="/tmp/top.out" exec 1>$OUTPUT; exec 2>&1 # monit event description echo "Host: $MONIT_HOST" > echo "Service: $MONIT_SERVICE" echo "Event: $MONIT_EVENT" echo "Description: $MONIT_DESCRIPTION" echo "Date: $MONIT_DATE " echo # append the top output /usr/bin/top -d1 -ocpu 10 #send the alert to users in the script arguments ($1, $2,
) cat $OUTPUT | /usr/bin/mail -s "$MONIT_SERVICE: $MONIT_EVENT" $@ --8<-- (note: i didn't tested the script, may need some modifications) Regards, Martin On Sep 6, 2011, at 11:33 PM, Daniel Rich wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |