Different notification contents for different users

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
hhlodge
Posts: 206
Joined: Tue Mar 08, 2011 2:13 pm

Different notification contents for different users

Post by hhlodge »

I have a DHCP scope plugin written in bash that outputs the contents of an OID table from an array loaded with an snmpget. I didn't write the script but can post it if needed. Anyway, I always see the Info ($SERVICEOUTPUT$) and Extended Info ($LONGSERVICEOUTPUT$) data, but for the same notification, certain users never see it and some users see it some of the time and other times, they don't. One thing I noted is the other users have a contact template set to xi_generic_contact and I have no template, but if I remove that template from the other users, it doesn't resolve it. This only occurs with this plugin. Here is the data that I always see.

Code: Select all

***** Nagios XI Alert *****

Notification Type: CUSTOM

Service: psmdhcp1 DHCP Scopes
Host: psm-itmon
Address: 127.0.0.1
State: WARNING
Info: Warning: One or more scopes is nearing capacity
Extended info: OK:10.20.0.036% used, 227 used, 391 free.\nOK:10.20.8.02% used, 43 used, 1490 free.\nWarning:10.70.16.0 - 86% used, 974 used, 147 free.\nOK:10.70.32.021% used, 21 used, 79 free.\nOK:10.70.32.12813% used, 12 used, 78 free.\nOK:10.70.33.00% used, 0 used, 100 free.\nOK:10.70.33.1280% used, 0 used, 90 free.\nOK:10.78.2.016% used, 31 used, 158 free.\n\nShowing 8 of 8 configured scopes\n
Date/Time: 2013-06-20 08:39:44

Author: Kyle Tucker
Comment: Checking on Unix mail
Notified: ktucker,hbeadnell,rgoldthwaite,rnebiker,thuff

Respond: http://psm-itmon/nagiosxi//rr.php?uid=1-2740-98959b90c55153160bcc2a388125e37f
Nagios URL: http://psm-itmon/nagiosxi/
And here is the same notification others see.

Code: Select all

***** Nagios XI Alert *****

Notification Type: CUSTOM

Service: psmdhcp1 DHCP Scopes
Host: psm-itmon
Address: 127.0.0.1
State: WARNING
Info:
Warning: One or more scopes is nearing capacity
Date/Time: 2013-06-20 08:39:43

Respond: http://psm-itmon/nagiosxi//rr.php?uid=55-2740-c352b79fcd6a00403e07012637eda572
Nagios URL: http://psm-itmon/nagiosxi/
Any thoughts what may be causing this?
- Kyle
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Different notification contents for different users

Post by slansing »

Hmm, looks like Info: Is completely blank, so you are using contacts not users? For notifications? There are differences between the two. Can you navigate to CCM > Commands > "here, copy the contents of" notify-service-by-email, and xi_service_notification_handler. Thanks!
hhlodge
Posts: 206
Joined: Tue Mar 08, 2011 2:13 pm

Re: Different notification contents for different users

Post by hhlodge »

I think the Info: data has been pushed down to the next line, perhaps by a \n char. As for contacts versus users, not sure what you're implying. From my experience, each user must also have a contact or they never get any notifications. Here is the two commands from CCM.

notify-service-by-email

Code: Select all

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nService Groups: $SERVICEGROUPNAMES$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\nNotified: $NOTIFICATIONRECIPIENTS$\n\nAdditional Info: $SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$\n\nAcknowledged by: $SERVICEACKAUTHOR$\nComment: $NOTIFICATIONCOMMENT$\nURL: $SERVICEACTIONURL$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
xi_service_notification_handler

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --notificationrecipients="$NOTIFICATIONRECIPIENTS$" 
- Kyle
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Different notification contents for different users

Post by scottwilkerson »

My guess would be that some of the users do not have %longserviceoutput% macro in their Notification Messages.

these can be changed on a per user basis by clicking on the username in the top right and then "Notification Messages"

If you have the enterprise version of XI you can change them all (or the default template) under Admin -> Notification Management
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
hhlodge
Posts: 206
Joined: Tue Mar 08, 2011 2:13 pm

Re: Different notification contents for different users

Post by hhlodge »

That did it for the user that never saw the data. The other guy that usually got it didn't have it defined either, so I'm not sure what's up with that. I'll look into the cost of Enterprise. On an aside, is there a way to get multi-line output in the notification for the extended data? All my attempts with sed and tr had no affect. Thanks.
- Kyle
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Different notification contents for different users

Post by abrist »

hhlodge wrote:On an aside, is there a way to get multi-line output in the notification for the extended data?
Is %longserviceoutput% not outputing the extended data for you?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
hhlodge
Posts: 206
Joined: Tue Mar 08, 2011 2:13 pm

Re: Different notification contents for different users

Post by hhlodge »

Yes, but it's on a single line despite having newline characters. I tried change to DOS CR/LF with tr, sed and piping through unix2dos but it remains one line, so it's hard to read in Outlook.
- Kyle
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Different notification contents for different users

Post by slansing »

Can you show us how you have the command and message format defined?
hhlodge
Posts: 206
Joined: Tue Mar 08, 2011 2:13 pm

Re: Different notification contents for different users

Post by hhlodge »

The output is in the original post above. Here is the verbose bash output from command line and an od dump of the output from command line. Is that sufficient?

Code: Select all

+ /bin/echo -e 'OK:\tAll scopes fine'
OK:	All scopes fine
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.10.0.0\t55%' used, 393 used, 310 free.
OK:	10.10.0.0	55% used, 393 used, 310 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.11.8.0\t3%' used, 30 used, 732 free.
OK:	10.11.8.0	3% used, 30 used, 732 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.20.16.0\t3%' used, 5 used, 146 free.
OK:	10.20.16.0	3% used, 5 used, 146 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.20.18.0\t26%' used, 12 used, 33 free.
OK:	10.20.18.0	26% used, 12 used, 33 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.30.0.0\t43%' used, 156 used, 199 free.
OK:	10.30.0.0	43% used, 156 used, 199 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.40.0.0\t69%' used, 136 used, 60 free.
OK:	10.40.0.0	69% used, 136 used, 60 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.78.1.0\t70%' used, 161 used, 69 free.
OK:	10.78.1.0	70% used, 161 used, 69 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.78.3.0\t70%' used, 161 used, 69 free.
OK:	10.78.3.0	70% used, 161 used, 69 free.
+ for I in '${!STAT[*]}'
+ /bin/echo -e 'OK:\t10.78.4.0\t50%' used, 116 used, 114 free.
OK:	10.78.4.0	50% used, 116 used, 114 free.
+ /bin/echo -e '\nShowing 9 of 11 configured scopes'

Showing 9 of 11 configured scopes

Code: Select all

[root@psm-itmon libexec]# ./check_dhcp_scopes 1.1.1.1 community 85 90 | od -c
0000000   O   K   :  \t   A   l   l       s   c   o   p   e   s       f
0000020   i   n   e  \n   O   K   :  \t   1   0   .   1   0   .   0   .
0000040   0  \t   5   5   %       u   s   e   d   ,       3   9   3    
0000060   u   s   e   d   ,       3   1   0       f   r   e   e   .  \n
0000100   O   K   :  \t   1   0   .   1   1   .   8   .   0  \t   3   %
0000120       u   s   e   d   ,       3   0       u   s   e   d   ,    
0000140   7   3   2       f   r   e   e   .  \n   O   K   :  \t   1   0
0000160   .   2   0   .   1   6   .   0  \t   3   %       u   s   e   d
0000200   ,       5       u   s   e   d   ,       1   4   6       f   r
0000220   e   e   .  \n   O   K   :  \t   1   0   .   2   0   .   1   8
0000240   .   0  \t   2   6   %       u   s   e   d   ,       1   2    
0000260   u   s   e   d   ,       3   3       f   r   e   e   .  \n   O
0000300   K   :  \t   1   0   .   3   0   .   0   .   0  \t   4   3   %
0000320       u   s   e   d   ,       1   5   6       u   s   e   d   ,
0000340       1   9   9       f   r   e   e   .  \n   O   K   :  \t   1
0000360   0   .   4   0   .   0   .   0  \t   6   9   %       u   s   e
0000400   d   ,       1   3   6       u   s   e   d   ,       6   0    
0000420   f   r   e   e   .  \n   O   K   :  \t   1   0   .   7   8   .
0000440   1   .   0  \t   7   0   %       u   s   e   d   ,       1   6
0000460   1       u   s   e   d   ,       6   9       f   r   e   e   .
0000500  \n   O   K   :  \t   1   0   .   7   8   .   3   .   0  \t   7
0000520   0   %       u   s   e   d   ,       1   6   1       u   s   e
0000540   d   ,       6   9       f   r   e   e   .  \n   O   K   :  \t
0000560   1   0   .   7   8   .   4   .   0  \t   5   0   %       u   s
0000600   e   d   ,       1   1   6       u   s   e   d   ,       1   1
0000620   4       f   r   e   e   .  \n  \n   S   h   o   w   i   n   g
0000640       9       o   f       1   1       c   o   n   f   i   g   u
0000660   r   e   d       s   c   o   p   e   s  \n
- Kyle
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Different notification contents for different users

Post by slansing »

Hey Kyle,

Can you post the text output in the Service Notifications section for the user who does not always receive the extended data?:

Click their name in the upper right hand corner, then navigate to "Notification Messages"
Locked