Configuring email notifications in NEMS

  1. Configure your resource.cfg
    • sudo nano /etc/nagios3/resource.cfg
      Modify all the variables according to your configuration. To save, press CTRL-O, to exit press CTRL-X.
    • If using a port other than 25 for your SMTP server, specify it on the USER7 line with :port. For example: smtp.gmail.com:587
  2. Gmail SMTP Extra Steps
    First, if you are a G Suite user, visit https://admin.google.com/…..email&subtab=filters and configure the SMTP Relay Service like this:

    Of course, if you happen to have a static IP on your NEMS server, go ahead and enable IP filtering for even more security.And then visit https://admin.google.com/…….subtab=lesssecureappsaccess and enable “Allow users to manage their access to less secure apps”.Now that you’ve done that, or if you are not a G Suite user, you’ll need to enable the setting for “less secure apps” here: https://myaccount.google.com/lesssecureapps
  3. Test your settings
    I’ve written an easy-to-use script which will load your settings from resource.cfg and send you a test email. It will also show you in the terminal the results, which may be helpful if you believe there is an error (since you’ll be able to see the output of sendemail).
    To run the test script:  sudo /home/pi/nems-scripts/mailtest.sh youremail@yourdomain.com where youremail@yourdomain.com is your actual recipient email address (must be different than the one you set in resource.cfg).
  4. Setup the target email address
    Login to NEMS-nConf and visit the Contacts section. You’ll see your user there (which you setup with nems-init). Edit it and change the email address to the one you would like.
  5. Setup notifications for each service
    Set Enable Notifications to 1, and Notification Type to whatever you’d like:When you see w,u,c,r,f,n these are the definitions:

    • w Notify if in warning state,
    • u Notify if in unknown state,
    • c Notify if in critical state,
    • f Notify if the service is flapping (on and off and on and off)
    • n None… don’t notify.

    When you see d,u,r,f,s,n these are the definitions:

    • d Notify if host is down,
    • u Notify if host is unreachable (eg. Internet down),
    • r Notify upon recovery,
    • f Notify if the host is flapping,
    • s Notify if a scheduled service downtime begins or ends,
    • n=Never notify.

Leave a Reply

10 Comments on "Configuring email notifications in NEMS"

Notify of
avatar
Sort by:   newest | oldest | most voted
Marek
Guest

Hello,

I have sent e-mail according to your instructions. If I send via console a testmail with sendmail it comes. But NEMS does not send me any news. I have entereda contact the e-mail address. I ask for help.

greeting
Marek

Dan Ellison
Guest

Hello. Very nice distro. I have a small issue that I hope you can assist with.

I don’t seem to be able to get host or service notifications to be delivered via notify-***-by-email command. I have a verified forwarding gateway configured in the mail system. Using postfix. When I send a custom notification to test delivery I get this in the log: NEMS postfix/sendmail[30287]: fatal: nagios(111): No recipient addresses found in message header

I have created a contact and and added that contact to the necessary contact group. Everything appears to be correctly configured but this error persists. Almost like the $CONTACTEMAIL$ macro is not being defined correctly…. Any guidance in resolving this will be greatly appreciated.

Keep up the good work!
Dan

wpDiscuz