2

I have this in a monit script (lines 11-13):

check program foo with
    path "/usr/local/bin/foo.sh" with timeout 300 seconds
       if status != 0 then alert dan@example.com

monit reload says:

/etc/monit/conf.d/example:13: Error: syntax error 'dan@example.com'

None of the examples show an email with the alert, but I need one. Why can I not give one here?

I'm using Monit 5.5.

1

Uncomment/Add these lines in your monit config file:

set mailserver localhost
set alert me@mycompany.com

Then do something like the following. Notice that there is nothing after "alert".

check program list-files with path "/bin/ls -lrt /tmp/"
     if status != 0 then alert
| improve this answer | |
0

Check the documentation at http://mmonit.com/monit/documentation/monit.html#setting_a_local_alert_statement it has the following example

check process mybar with pidfile /var/run/mybar.pid
  alert foo@bar only on { timeout }
| improve this answer | |
  • I saw that example, but how does it relate to this? That example says "each service can have its own recipient list." How is this statement a service? And it also shows that a legal alert in that context has only an email address, no "only on { timeout }". – dfrankow Apr 4 '13 at 14:02
0

Look specifically at: https://mmonit.com/monit/documentation/monit.html#Setting-an-alert-recipient (new link), the way I read this, for a local alert (if you want an additional email for just this alert), you would add it to the end of the current section.

From the link above:

Local alert example:

   check host myhost with address 1.2.3.4  
     if failed port 3306 protocol mysql then alert  
     if failed port 80 protocol http then alert  
     alert foo@baz # Local service alert

You will note, the failed check and alert notification are on the second and third lines, then a local email address is added to the final line.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.