Setting notification_commands Via Template

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Setting notification_commands Via Template

Post by Deantwo »

When I first started setting up this Nagios server I kinda deleted a lot of the standard templates and such. I found it easier to learn from an empty configuration, so no issue there.
Now that I feel comfortable working with templates and everything, I am trying to add new users to the server. But because the xi_contact_generic contact template was deleted I ended up having issues with the XI notification user options.

I got it to work by adding xi_host_notification_handler and xi_service_notification_handler directly onto XI created contacts, but this is getting tiresome to manage as more and more users are added.
Attempting to recreate the xi_contact_generic contact template is however causing me some issues.
I check if it is working using http://SERVER-IP/nagiosxi/account/notifymethods.php, since it gives an error if it is not working.

Found some code around on the forum in an attempt to recreate it, so currently I have:

Code: Select all

define contact {
    name                             xi_contact_generic
    contactgroups                    +xi_contactgroup_all
    host_notification_period         xi_timeperiod_24x7
    service_notification_period      xi_timeperiod_24x7
    host_notification_commands       xi_host_notification_handler
    service_notification_commands    xi_service_notification_handler
    retain_status_information        1
    retain_nonstatus_information     1
    register                         0
    }
The problem is that the xi_host_notification_handler and xi_service_notification_handler don't seem to be applied to contacts correctly through the use of the template.

My contact:

Code: Select all

define contact {
    contact_name                      dean
    alias                             Dean
    host_notification_period          dean_notification_times
    service_notification_period       dean_notification_times
    host_notification_options         d,u,r,f,s,
    service_notification_options      w,u,c,r,f,s,
    email                             [email protected]
    use                               xi_contact_generic,another_template,yetanother_template
    }
According to my understanding and reading of "Nagios XI – Understanding Users and Contacts" it should be working.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Setting notification_commands Via Template

Post by rkennedy »

Can you post your /usr/local/nagios/var/objects.cache file for us to look at? This will show us how your configuration is compiled together.
Former Nagios Employee
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Re: Setting notification_commands Via Template

Post by Deantwo »

rkennedy wrote:Can you post your /usr/local/nagios/var/objects.cache file for us to look at? This will show us how your configuration is compiled together.
Ooh! This is a very handy file to know. Could have saved me a lot of head scratching when I started learning this.

Code: Select all

define contact {
    contact_name                     dean
    alias                            Dean
    service_notification_period      dean_notification_times
    host_notification_period         dean_notification_times
    service_notification_options     r,w,u,c,f,s
    host_notification_options        r,d,u,f,s
    service_notification_commands    xi_service_notification_handler
    host_notification_commands       xi_host_notification_handler
    email                            [email protected]
    minimum_importance               0
    host_notifications_enabled       1
    service_notifications_enabled    1
    can_submit_commands              1
    retain_status_information        1
    retain_nonstatus_information     1
    }

define contactgroup {
    contactgroup_name                xi_contactgroup_all
    alias                            All XI contacts
    members                          dean,another_user,yetanother_user,users_everywhere
    }
All users seem to correctly have xi_service_notification_handler and xi_host_notification_handler configured, but still doesn't work.
Don't know if there are any other specif parts of the file you need to see.
The file is 133338 lines long with a total length of 3273933, so sanitizing the whole file would take a while.

All the other contact templates only add a contactgroup, so there are no conflicts to worry about there, which is also why I added "+" to the xi_contact_generic template's contactgroups directive (not sure if that is default).

PS: Just out of curiosity, why isn't the minimum_importance directive listed in the Nagios Core Object Definitions document.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Setting notification_commands Via Template

Post by rkennedy »

Deantwo wrote:
rkennedy wrote:Can you post your /usr/local/nagios/var/objects.cache file for us to look at? This will show us how your configuration is compiled together.
Ooh! This is a very handy file to know. Could have saved me a lot of head scratching when I started learning this.

Code: Select all

define contact {
    contact_name                     dean
    alias                            Dean
    service_notification_period      dean_notification_times
    host_notification_period         dean_notification_times
    service_notification_options     r,w,u,c,f,s
    host_notification_options        r,d,u,f,s
    service_notification_commands    xi_service_notification_handler
    host_notification_commands       xi_host_notification_handler
    email                            [email protected]
    minimum_importance               0
    host_notifications_enabled       1
    service_notifications_enabled    1
    can_submit_commands              1
    retain_status_information        1
    retain_nonstatus_information     1
    }

define contactgroup {
    contactgroup_name                xi_contactgroup_all
    alias                            All XI contacts
    members                          dean,another_user,yetanother_user,users_everywhere
    }
All users seem to correctly have xi_service_notification_handler and xi_host_notification_handler configured, but still doesn't work.
Don't know if there are any other specif parts of the file you need to see.
The file is 133338 lines long with a total length of 3273933, so sanitizing the whole file would take a while.

All the other contact templates only add a contactgroup, so there are no conflicts to worry about there, which is also why I added "+" to the xi_contact_generic template's contactgroups directive (not sure if that is default).

PS: Just out of curiosity, why isn't the minimum_importance directive listed in the Nagios Core Object Definitions document.
The objects.cache is my first go to all the time!

Got it, it looks to be inheriting it properly. XI actually uses another barrier when sending notifications using the xi_host_notification_handler. Click the username you're logged in as for example, then click 'Notification Preferences'. It will use this over the regular 'contacts' that the notify_host_by_email will use. Then, click Notification Methods to make sure they are turned on that location as well.

Were they previously turned off by any chance? This will stop the notifications from firing.

As for the minimum_importance part, I've brought it up internally so we'll see what happens!
Former Nagios Employee
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Re: Setting notification_commands Via Template

Post by Deantwo »

rkennedy wrote:The objects.cache is my first go to all the time!
I see why, it is super useful.
I am a little sad there is no way to see this in XI.
rkennedy wrote:Got it, it looks to be inheriting it properly. XI actually uses another barrier when sending notifications using the xi_host_notification_handler. Click the username you're logged in as for example, then click 'Notification Preferences'. It will use this over the regular 'contacts' that the notify_host_by_email will use. Then, click Notification Methods to make sure they are turned on that location as well.

Were they previously turned off by any chance? This will stop the notifications from firing.
Notification Preferences.PNG
Notification preferences are set as I want them, I unchecked a few that I don't really need to be notified about.
But yes notifications are enabled, I am however not totally sure that I am getting e-mails, but that is not really my issue at the moment.
Notification Methods.PNG
This is my real problem. I am unable to change "Notification Methods" and "Notification Messages".

If I apply the xi_host_notification_handler and xi_service_notification_handler directly to the contact, it works as it should, but when I try to add it using the template it just gives me that error.
My user has admin Authorization Level and Enable Notifications checked, so doubt it has anything to do with that.
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Setting notification_commands Via Template

Post by rkennedy »

Can you post your objects.cache file once again for us to look at once again?

The reason being is I did some testing on my end, and I had no problem applying a template that contact the xi_host_notification_handler, and xi_service_notification_handler. The only way I was able to replicate this, was by removing the template, and then assigning generic notification commands to the contact. (otherwise apply configuration was failing due to no commands defined for the contact)
Former Nagios Employee
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Re: Setting notification_commands Via Template

Post by Deantwo »

rkennedy wrote:Can you post your objects.cache file once again for us to look at once again?
Don't think it has changed since last time I posted it, but ok.

Code: Select all

define contact {
    contact_name                     dean
    alias                            Dean
    service_notification_period      dean_notification_times
    host_notification_period         dean_notification_times
    service_notification_options     r,w,u,c,f,s
    host_notification_options        r,d,u,f,s
    service_notification_commands    xi_service_notification_handler
    host_notification_commands       xi_host_notification_handler
    email                            [email protected]
    minimum_importance               0
    host_notifications_enabled       1
    service_notifications_enabled    1
    can_submit_commands              1
    retain_status_information        1
    retain_nonstatus_information     1
    }

define contactgroup {
    contactgroup_name                xi_contactgroup_all
    alias                            All XI contacts
    members                          dean,another_user,yetanother_user,users_everywhere
    }
Making a new template with only xi_host_notification_handler and xi_service_notification_handler defined gives the same result as the current template I am using.

Removing the template from the contact prevents the configuration from being applied because host_notification_commands and service_notification_commands are not defined, as expected.
Last edited by Deantwo on Tue Jul 12, 2016 9:40 am, edited 2 times in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Setting notification_commands Via Template

Post by lmiltchev »

This issue would be probably resolved faster during a remote session. Is opening a new ticket in our email ticketing system an option for you? If it is, send us an email at [email protected]. Type "Setting notification_commands Via Template" in the email's subject field, and provide a URL link to this post in the email's body. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Setting notification_commands Via Template

Post by rkennedy »

For the record, I tried to re-create this as well. I was able to access the Notification Preferences pages if ONLY the template was assigned (after I removed notify-host-by-email and notify-service..). When I had both notify-host and xi_notification_ assigned, the page still blocks you out because of the notify-host being part.

In your testing now, do you have both the notify-host and xi_notification assigned to the contact? If not, as @lmiltchev mentioend - it's probably worth moving this into a remote as it sounds like a bug.
Former Nagios Employee
Deantwo
Posts: 52
Joined: Thu Mar 03, 2016 8:39 am

Re: Setting notification_commands Via Template

Post by Deantwo »

rkennedy wrote:For the record, I tried to re-create this as well. I was able to access the Notification Preferences pages if ONLY the template was assigned (after I removed notify-host-by-email and notify-service..). When I had both notify-host and xi_notification_ assigned, the page still blocks you out because of the notify-host being part.

In your testing now, do you have both the notify-host and xi_notification assigned to the contact?
I do not have notify-host-by-email or notify-service-by-email anywhere, I only have what is in the template shown in the first post. The other templates aren't adding anything but contact groups, not really a need for them to be templates anymore so I may change that.
I will fiddle a little more with it in the morning.

By the way, nothing prevents the use of "Notification Preferences", it is "Notification Methods" (and "Notification Messages") that give an error.
See: http://SERVER-IP/nagiosxi/account/notifymethods.php

Maybe you can tell me exactly how the original/standard xi_contact_generic template looks.
Locked