How do i add the acknowledge username to email notifications

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
dennis.kn
Posts: 2
Joined: Thu Jan 03, 2013 3:26 pm

How do i add the acknowledge username to email notifications

Post by dennis.kn »

Hello,

I'm trying to add the user name of the person acknowledging a service check. Right now if you acknowledge a check you get a email like this:

From: nagios@abc.com [mailto:nagios@abc.com]
Sent: Thursday, January 03, 2013 12:32 PM
To: Me
Subject: ACKNOWLEDGEMENT:Server-name/Ping Check is CRITICAL

T:Thu Jan 3 12:31:43 EST 2013
I:PING CRITICAL - Packet loss = 100%

I want it changed to add the last line:

From: nagios@abc.com [mailto:nagios@abc.com]
Sent: Thursday, January 03, 2013 12:32 PM
To: Me
Subject: ACKNOWLEDGEMENT:Server-name/Ping Check is CRITICAL

T:Thu Jan 3 12:31:43 EST 2013
I:PING CRITICAL - Packet loss = 100%
ACK by:User-acknowledging-this-check

In my /etc/nagio/commands.cfg i have:

define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "T:$LONGDATETIME$\nI:$SERVICEOUTPUT$" | /bin/mail -s "$NOTIFICATIONTYPE$:$HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTEMAIL$
}

What would I add or am i looking in the wrong place?

Dennis
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: How do i add the acknowledge username to email notificat

Post by jsmurphy »

Here's a list of the macros available in Nagios: http://nagios.sourceforge.net/docs/3_0/macrolist.html

The ones you are probably looking for are:
$SERVICEACKAUTHOR$
$HOSTACKAUTHOR$

As an example you would update it like:
define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "T:$LONGDATETIME$\nI:$SERVICEOUTPUT$\nACK by:$SERVICEACKAUTHOR$" | /bin/mail -s "$NOTIFICATIONTYPE$:$HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTEMAIL$
}
dennis.kn
Posts: 2
Joined: Thu Jan 03, 2013 3:26 pm

Re: How do i add the acknowledge username to email notificat

Post by dennis.kn »

jsmurphy,

You are the man! Thanks for the great answer, for showing me where to look( I feel so dumb for missing that) and an example on what to do. That made it really easy to update and test and also show me a little more of what Nagios could do.

If i could rate this you would got 5 out of 5 stars,
if i could like this I would!
:D
Locked