Recipients of a notification be in the To: header
-
anil_kumarv
- Posts: 50
- Joined: Thu Oct 17, 2013 2:00 am
Recipients of a notification be in the To: header
I want to achieve the following :
To have all the recipients of a notification be in the To: header so people can "reply all" to issues, yet each notification from Nagios only go the one intended recipient.
We have all the contacts under static folder : /usr/local/nagios/etc/static/global/contacts/individuals/
Can someone help me in this.
-- Anil Kumar V
To have all the recipients of a notification be in the To: header so people can "reply all" to issues, yet each notification from Nagios only go the one intended recipient.
We have all the contacts under static folder : /usr/local/nagios/etc/static/global/contacts/individuals/
Can someone help me in this.
-- Anil Kumar V
Re: Recipients of a notification be in the To: header
I would take a look at this recent thread where we just dealt with this sort of thing in February:
http://support.nagios.com/forum/viewtop ... =7&t=25758
That solution might not be exactly what you want but it's close.
http://support.nagios.com/forum/viewtop ... =7&t=25758
That solution might not be exactly what you want but it's close.
Former Nagios employee
-
anil_kumarv
- Posts: 50
- Joined: Thu Oct 17, 2013 2:00 am
Re: Recipients of a notification be in the To: header
okay, I'm trying to list all the recipients of a particular service/host alert in the body. The host/service can have multiple contact groups.
Something like the following :
----------------------------------------------
Notification Type: PROBLEM
Host: abcdb
State: DOWN
Address: 10.10.10.1
Info: CRITICAL - Host Unreachable (10.10.10.1)
Date/Time: Thu Feb 27 04:54:45 GMT 2014
Recipients: Tom, Ryan, DL-Global-Operations
Monitoring Host: nagios-01
----------------------------------------------
I'm doing the following :
1)Adding
--contactgroups=$CONTACTGROUPMEMBERS$
To the end of xi_host_notification_handler command.
2) Then Adding
Recipients: %contactgroups%
To the email notification message body.
But this does not seem to be working and I get the below line
Recipients: %contactgroups%
Am I doing it the right way..
-- Anil Kumar V
Something like the following :
----------------------------------------------
Notification Type: PROBLEM
Host: abcdb
State: DOWN
Address: 10.10.10.1
Info: CRITICAL - Host Unreachable (10.10.10.1)
Date/Time: Thu Feb 27 04:54:45 GMT 2014
Recipients: Tom, Ryan, DL-Global-Operations
Monitoring Host: nagios-01
----------------------------------------------
I'm doing the following :
1)Adding
--contactgroups=$CONTACTGROUPMEMBERS$
To the end of xi_host_notification_handler command.
2) Then Adding
Recipients: %contactgroups%
To the email notification message body.
But this does not seem to be working and I get the below line
Recipients: %contactgroups%
Am I doing it the right way..
-- Anil Kumar V
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Recipients of a notification be in the To: header
Nope...anil_kumarv wrote:
Am I doing it the right way..
-- Anil Kumar V
Change it to the following:
1)Add
--recipients=$NOTIFICATIONRECIPIENTS$
2) Then Add
Recipients: %recipients%
The first thig you tries would just list the name of contact groups assigned to the item you were monitoring.
-
anil_kumarv
- Posts: 50
- Joined: Thu Oct 17, 2013 2:00 am
Re: Recipients of a notification be in the To: header
Thanks It did work. Right now its showing contact_name of the recipients. Anyway we can get Alias of the recipients instead of contact_name ..? e.g: Anil Kumar instead of akumar16 and so on..
--------------------------------------------
Notification Type: CUSTOM
Host: 10.213.161.201
State: DOWN
Address: 10.213.161.201
Info: PING CRITICAL - Packet loss = 100%
Date/Time: 2014-05-23 10:24:52
Host Duration: 0d
Hostgroups: os-windows,mon-mon22,loc-bangalore,env-development
Recipients: akumar16,mkumarkr,dl-dev-akumar6
--------------------------------------------
How we have defined contact..
--------------------------------------------
[root@mon01 etc]# cat akumar16.cfg
define contact {
contact_name akumar16
alias Anil Kumar
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,s
host_notification_options d,u,r,s
service_notification_commands xi_service_notification_handler
host_notification_commands xi_host_notification_handler
email [email protected]
}
--------------------------------------------
-- Anil Kumar V
--------------------------------------------
Notification Type: CUSTOM
Host: 10.213.161.201
State: DOWN
Address: 10.213.161.201
Info: PING CRITICAL - Packet loss = 100%
Date/Time: 2014-05-23 10:24:52
Host Duration: 0d
Hostgroups: os-windows,mon-mon22,loc-bangalore,env-development
Recipients: akumar16,mkumarkr,dl-dev-akumar6
--------------------------------------------
How we have defined contact..
--------------------------------------------
[root@mon01 etc]# cat akumar16.cfg
define contact {
contact_name akumar16
alias Anil Kumar
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,s
host_notification_options d,u,r,s
service_notification_commands xi_service_notification_handler
host_notification_commands xi_host_notification_handler
email [email protected]
}
--------------------------------------------
-- Anil Kumar V
Re: Recipients of a notification be in the To: header
I don't believe this is possible as this is what it is in the macro...
$NOTIFICATIONRECIPIENTS$ A comma-separated list of the short names of all contacts that are being notified about the host or service.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
anil_kumarv
- Posts: 50
- Joined: Thu Oct 17, 2013 2:00 am
Re: Recipients of a notification be in the To: header
Thanks. I'm trying to add more details like how long the service or host has been in critical state. I've done the following :
1)Added "--hostduration=$HOSTDURATION$" in host notification handler and
2)Added "Host Duration: %hostduration%" in the email template
But i'm only getting the days info in the email template, and no mins or sec. The same applies to Service duration also.
-----------------------------------------------------------
Notification Type: PROBLEM
Host: banav1esx17.corp.avertlabs.internal
State: DOWN
Address: 10.10.10.1
Info: PING CRITICAL - Packet loss = 100%
Date/Time: 2014-05-26 08:18:59
Host Duration: 0d
-----------------------------------------------------------
Service: Disk
Host: ban-gti-rep03.corp.avertlabs.internal
Address: ban-gti-rep03.corp.avertlabs.internal
State: CRITICAL
Info:
Connection refused by host
Date/Time: 2014-05-26 08:29:19
Service Duration: 194d
-----------------------------------------------------------
-- Anil Kumar V
1)Added "--hostduration=$HOSTDURATION$" in host notification handler and
2)Added "Host Duration: %hostduration%" in the email template
But i'm only getting the days info in the email template, and no mins or sec. The same applies to Service duration also.
-----------------------------------------------------------
Notification Type: PROBLEM
Host: banav1esx17.corp.avertlabs.internal
State: DOWN
Address: 10.10.10.1
Info: PING CRITICAL - Packet loss = 100%
Date/Time: 2014-05-26 08:18:59
Host Duration: 0d
-----------------------------------------------------------
Service: Disk
Host: ban-gti-rep03.corp.avertlabs.internal
Address: ban-gti-rep03.corp.avertlabs.internal
State: CRITICAL
Info:
Connection refused by host
Date/Time: 2014-05-26 08:29:19
Service Duration: 194d
-----------------------------------------------------------
-- Anil Kumar V
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Recipients of a notification be in the To: header
Change this
To this
Code: Select all
"--hostduration=$HOSTDURATION$"Code: Select all
--hostduration="$HOSTDURATION$"-
anil_kumarv
- Posts: 50
- Joined: Thu Oct 17, 2013 2:00 am
Re: Recipients of a notification be in the To: header
My notification handler is as follows :
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostduration="$HOSTDURATION$" --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
My email template as follows :
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%alertsummary%
Notification Type: %type%
Host: %host%
State: %hoststate% since %hostduration%
Address: %hostaddress%
Info: %hostoutput%
Date/Time: %datetime%
Host Duration: %hostduration%
Hostgroups: %hostgroups%
Recipients: %recipients%
Respond: %responseurl%
Nagios URL: %xiserverurl%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I still get only days in the hostduration. Example alert below :
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
.
.
Host: 10.213.161.201
State: DOWN since 0d
Address: 10.213.161.201
Info: PING CRITICAL - Packet loss = 100%
Date/Time: 2014-05-28 06:50:51
Host Duration: 0d
.
.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Anything wrong ..?
-- Anil Kumar V
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostduration="$HOSTDURATION$" --hostgroups=$HOSTGROUPNAMES$ --recipients=$NOTIFICATIONRECIPIENTS$
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
My email template as follows :
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%alertsummary%
Notification Type: %type%
Host: %host%
State: %hoststate% since %hostduration%
Address: %hostaddress%
Info: %hostoutput%
Date/Time: %datetime%
Host Duration: %hostduration%
Hostgroups: %hostgroups%
Recipients: %recipients%
Respond: %responseurl%
Nagios URL: %xiserverurl%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I still get only days in the hostduration. Example alert below :
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
.
.
Host: 10.213.161.201
State: DOWN since 0d
Address: 10.213.161.201
Info: PING CRITICAL - Packet loss = 100%
Date/Time: 2014-05-28 06:50:51
Host Duration: 0d
.
.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Anything wrong ..?
-- Anil Kumar V
Re: Recipients of a notification be in the To: header
Is this a regular email alert or a sms (email-to-text) notification? If this is a text, it is possible some of the output is "cut off" by your carrier...
Try modifying the "Notification Messages" like this:
and see of the "Date/Time" will be cut off now.
Try modifying the "Notification Messages" like this:
Code: Select all
%alertsummary%
Notification Type: %type%
Host: %host%
State: %hoststate% since %hostduration%
Address: %hostaddress%
Info: %hostoutput%
Host Duration: %hostduration%
Date/Time: %datetime%
Hostgroups: %hostgroups%
Recipients: %recipients%
Respond: %responseurl%
Nagios URL: %xiserverurl%Be sure to check out our Knowledgebase for helpful articles and solutions!