Nagios XI Mail delivery

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios XI Mail delivery

Post by jdalrymple »

Entity 1:
Account userAaccount
Contact userAacount
Which uses:
use xi_service_notification_handler
use xi_host_notification_handler

and

Entity2:
Contact userBcontactonly
Should be using
notify-service-by-email
notify-host-by-email
This should work.

How did you test it from the command line? Did you use the same command specified in the command definition for notifiy-service-by-email?
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Nagios XI Mail delivery

Post by emartine »

If you have a contacts Email address and Pager fields filled out. An alert should be sent to both is this correct?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios XI Mail delivery

Post by jdalrymple »

It could - but it won't by default. Notifications are just commands. The field where you put in a pager number (or E-mail or anything) just assigns a macro to be used in a command. The macro in question is $CONTACTPAGER$. What is done with that macro is defined on the alert settings tab with the notification commands.

It's worth noting that you can have multiple notification commands for a contact.

Does this make sense?
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Nagios XI Mail delivery

Post by emartine »

I looked deeper into the command issue and it seems that the commands were modified. Which is the reason why it wasn't sending out. So I worked on this one and attached it to the contact. Seems to work but I need a second pair of eyes.

notify-service-by-epager
/usr/bin/printf "%b" *Alert*\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$ \nInfo:$SERVICEOUTPUT$ | /bin/mail -s "* $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ *" $CONTACTEMAIL$ $CONTACTPAGER$


notify-host-by-epager
/usr/bin/printf "%b" *Alert*\nNotification Type: $HOSTSTATE$ \nHost: $HOSTNAME$ \nAddress: $HOSTADDRESS$ \nInfo: $HOSTOUTPUT$ | /bin/mail -s "Alert" $CONTACTPAGER$ $CONTACTEMAIL$


I tested this by submitting passive check results for critical for the service and I received them without issue. However when NagiosXI was doing the paging.... I got this on the occasion:

[1427642733] wproc: host=servername; service=printqueue name; contact=billings
[1427642733] wproc: stderr line 02: /bin/sh: -c: line 0: `/usr/bin/printf "%b" *Alert*\nNotification Type: PROBLEM\nService: printqueue name\nHost: servername\nAddress: printerip\nState: CRITICAL \nInfo:CRITICAL: \\Print Queue\\Jobs: 13 critical | /bin/mail -s "* PROBLEM Service Alert: servername is CRITICAL *" [email protected] '
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios XI Mail delivery

Post by jdalrymple »

emartine wrote: [1427642733] wproc: host=servername; service=printqueue name; contact=billings
[1427642733] wproc: stderr line 02: /bin/sh: -c: line 0: `/usr/bin/printf "%b" *Alert*\nNotification Type: PROBLEM\nService: printqueue name\nHost: servername\nAddress: printerip\nState: CRITICAL \nInfo:CRITICAL: \\Print Queue\\Jobs: 13 critical | /bin/mail -s "* PROBLEM Service Alert: servername is CRITICAL *" [email protected] '

The command looks OK (and incidentally works). What do the infrequent occurrences of the message have in common? Maybe some macro expansion is blowing up the command?

The leading backtick and trailing single quote look funky, but I'll assume that's either funky logging or copy/paste weirdness.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios XI Mail delivery

Post by ssax »

Looks like you are missing the quotes:

Code: Select all

notify-service-by-epager
/usr/bin/printf "%b" "*Alert*\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$ \nInfo:$SERVICEOUTPUT$" | /bin/mail -s "* $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ *" $CONTACTEMAIL$ $CONTACTPAGER$


notify-host-by-epager
/usr/bin/printf "%b" "*Alert*\nNotification Type: $HOSTSTATE$ \nHost: $HOSTNAME$ \nAddress: $HOSTADDRESS$ \nInfo: $HOSTOUTPUT$" | /bin/mail -s "Alert" $CONTACTPAGER$ $CONTACTEMAIL$
Try those and let us know.
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Nagios XI Mail delivery

Post by emartine »

Ok. Seems like the service check that is going through when it is critical is causing this error. The oncall person confirmed that they were only receiving recovery and not critical alerts.


The service check in question is this:

$USER1$/check_nrpe -H $HOSTADDRESS$ -c CheckCounter -a $ARG1$ MaxWarn=$ARG2$ MaxCrit=$ARG3$
ARG1: '\Print Queue(printername)\Jobs'
ARG2:6
ARG3:10

Seems like the \ ( ) \ are being interpreted when mail is sending it out hence the error.

I will try those commands.
cmerchant
Posts: 546
Joined: Wed Sep 24, 2014 11:19 am

Re: Nagios XI Mail delivery

Post by cmerchant »

Let us know if that works for you. We'll leave this thread open for now.
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Nagios XI Mail delivery

Post by emartine »

Yes. Seems to have worked. Please close. Thank you!
Locked