Page 2 of 2

Re: Nagios XI Mail delivery

Posted: Thu Mar 26, 2015 9:35 am
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?

Re: Nagios XI Mail delivery

Posted: Fri Mar 27, 2015 11:42 am
by emartine
If you have a contacts Email address and Pager fields filled out. An alert should be sent to both is this correct?

Re: Nagios XI Mail delivery

Posted: Fri Mar 27, 2015 12:02 pm
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?

Re: Nagios XI Mail delivery

Posted: Sun Mar 29, 2015 2:18 pm
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] '

Re: Nagios XI Mail delivery

Posted: Mon Mar 30, 2015 10:24 am
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.

Re: Nagios XI Mail delivery

Posted: Mon Mar 30, 2015 10:27 am
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.

Re: Nagios XI Mail delivery

Posted: Mon Mar 30, 2015 11:15 am
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.

Re: Nagios XI Mail delivery

Posted: Mon Mar 30, 2015 11:18 am
by cmerchant
Let us know if that works for you. We'll leave this thread open for now.

Re: Nagios XI Mail delivery

Posted: Mon Apr 06, 2015 6:09 pm
by emartine
Yes. Seems to have worked. Please close. Thank you!