Linux – Monit: Customize alert message to include command output

linuxmonitmonitoring

I would like to customize the Monit's alert message, so that whenever I get an alert, the email also includes the output of a command like top, so that I will already know more details about what might have caused the problem.

Is there a way to do this? The documentation doesn't include anything relevant, and searching wasn't helpful either.

Thanks for the help!

Best Answer

How about something like this, from the monit wiki?

# Getting top otput by mail on event
check file myfile with path /tmp/fo.bar
  if changed timestamp then exec "/bin/bash -c 'top -bn1 | mail -s top admin@foo.bar'"

Link: http://mmonit.com/wiki/Monit/ConfigurationExamples (scroll to very bottom)

Related Topic