Notification Formatting

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Notification Formatting

Post by derekb »

Hey there,
Running latest XI on CentOS6. As of now, I've been creating a user account for each person I want to sent notifications to, but I'm realizing this is just asking for a security risk since alot of these 'users' don't need access to XI and only want the email notifications.

I've modified xi_host_notification_handler to have all of the fields I'd like, and formatted the notifications via the user settings. This part is OK.

With notify-host-by-email, I'm not able to get the formatting the same as xi_host_notification handler. Wondering if I could get a hand in getting for formatting correct?

xi_host_notification_handler

Code: Select all

/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$" --notes="$HOSTNOTES$" --hostgroup="$HOSTGROUPNAME$" --hostgroupnotes="$HOSTGROUPNOTES$" --hostgroupnotesurl="$HOSTGROUPNOTESURL$" --hostgroupalias="$HOSTGROUPALIAS$"
This is what an email notification looks like for a valid user account in XI:

Code: Select all

***** Empire Monitoring Alert *****

Nagios has detected a problem with this host.

Notification Type: PROBLEM

Customer Information:
Hostgroup: Linux Servers
Site Address: Linux Servers
Sharepoint URL: 
Notes: 

Host Information:
Host: hostname
State: DOWN
Address: 192.168.10.10
Info: CRITICAL - 192.168.10.10: rta nan, lost 100%
Date/Time: 2015-12-28 11:49:50

Respond: respond-url
Nagios URL: url-to-xi
This is what I have in 'notify-host-by-email':

Code: Select all

/usr/bin/printf "%b" "***** Empire Monitoring Alert *****\n\nComments: $NOTIFICATIONCOMMENT$\n\nNotification Type: $NOTIFICATIONTYPE$\n\nCustomer Information:\nHostgroup: $HOSTGROUPNAME$ \nSite Address: $HOSTGROUPALIAS$ \nSharepoint URL: $HOSTGROUPNOTESURL$ \nNotes: $HOSTGROUPNOTES$\n\nHost Information:\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
The idea behind this is that we will start adding our clients to the NAGIOS notifications -- if we just add them as a 'user', then I have to manually copy/paste the formatting to their user settings. With the notify-host-by-email option, once we have the formatting set it should be simple to add a new 'email address' to receive notifications.

If you can think of a simpler way, I'm definitely open to it! We don't have the 'Enterprise' version of XI.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Notification Formatting

Post by rkennedy »

To better understand what you're trying to accomplish, what information from the 'xi_host_notification_handler' would you like added to your template that goes out for regular contacts?
Former Nagios Employee
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Re: Notification Formatting

Post by derekb »

rkennedy wrote:To better understand what you're trying to accomplish, what information from the 'xi_host_notification_handler' would you like added to your template that goes out for regular contacts?
The exact same information, minus the "respond URL" and nagios XI URL. I think from that point I can modify it enough on my own once I see how the proper formatting is done.

I may or may not remove the SharePoint URL, but am not sure yet as sometimes we give clients access to their data in our SharePoint library.

Same goes for the service notification -- I'll be able to tweak that my own once I see the proper formatting of the text.

Thank you!!
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Notification Formatting

Post by gormank »

Why not create a group in your email system w/ all the user mail addresses, and then a contact in Nagios with that mail address?
As far as I know Nagios sends notifications to contacts and contacts may or may not be attached to users.
You may even be able to create a mail alias on the Nagios server and put the user addresses in there, bypassing creating a group on an external mail system.
derekb
Posts: 177
Joined: Wed Jun 10, 2015 1:54 pm

Re: Notification Formatting

Post by derekb »

gormank wrote:Why not create a group in your email system w/ all the user mail addresses, and then a contact in Nagios with that mail address?
As far as I know Nagios sends notifications to contacts and contacts may or may not be attached to users.
You may even be able to create a mail alias on the Nagios server and put the user addresses in there, bypassing creating a group on an external mail system.
That is not what I want to do.

Making a distribution list in Exchange and adding all customer emails to it would send alerts for all hosts to all my customers. Not a good idea.... Sticking to my original idea
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Notification Formatting

Post by gormank »

Sorry, I must have misunderstood what you're trying to do.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Notification Formatting

Post by ssax »

Is this what you're looking for?

Code: Select all

/usr/bin/printf "%b" "***** Empire Monitoring Alert *****\n\nNagios has detected a problem with this host.\n\nNotification Type: $NOTIFICATIONTYPE$\n\nCustomer Information:\nHostgroup: $HOSTGROUPNAME$\nSite Address: $HOSTGROUPALIAS$ \nSharepoint URL: $HOSTGROUPNOTESURL$ \nNotes: $NOTIFICATIONCOMMENT$\n\nHost Information:\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
Locked