2

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!

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940

1 Answers1

5

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)

Henry
  • 51
  • 1
  • 2
  • Henry, I would have preferred a more "centralized" solution, that would enable me to add ``top``'s output in the ``mail-format`` parameter, so that I would get it in every mail alert sent. From what I read though, this is impossible. Your solution is an excellent workaround though! – Charalambos Paschalides Feb 28 '12 at 15:19