Create new user with notifications disabled

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Create new user with notifications disabled

Post by hbouma »

I am attempting to use the API to pump in new users, but want to set their contact to have host and service notifications disabled.

I see the API has an option of enable_notifications, and when I set that option to 0, the contacts.cfg file still shows host_notifications_enabled and service_notifications_enabled as 1.

Is there a way to create a user in the API and set their host_notifications_enabled and service_notifications_enabled to be 0?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Create new user with notifications disabled

Post by lmiltchev »

This is normal - the contact always has notifications enabled, it's XI that handles whether or not XI sends notifications. If you wanted to disable host/service notifications of a contact, you could use the core commands with the REST API, for example:

Code: Select all

curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/corecommand?apikey=xxxx" -d "cmd=DISABLE_CONTACT_HOST_NOTIFICATIONS;contactname"
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/corecommand?apikey=xxxx" -d "cmd=DISABLE_CONTACT_SVC_NOTIFICATIONS;contactname"
where you substitute "contactname" with the actual name of your contact.

Keep in mind that these commands won't change the configs. They will disable the notifications at the moment (change the currently running core setup). You could verify the changes by opening the /usr/local/nagios/var/status.dat, and viewing your contact's config in there. Hope this makes sense.
Be sure to check out our Knowledgebase for helpful articles and solutions!
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Create new user with notifications disabled

Post by hbouma »

If I reboot, will it keep the notifications to that user disabled?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Create new user with notifications disabled

Post by lmiltchev »

Yes, it should.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Create new user with notifications disabled

Post by ssax »

lmiltchev is correct, I labbed this up and it did indeed stay disabled after a reboot.

The caveat being that your commands MUST have been executed X seconds ago before rebooting, where X is larger than both your status_update_interval and your retention_update_inteval from your /usr/local/nagios/etc/nagios.cfg so that they will be retained and remembered on the startup next time.
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Create new user with notifications disabled

Post by hbouma »

Thank you. This will be exactly what I need.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Create new user with notifications disabled

Post by ssax »

That's great to hear, are we okay to lock the topic and mark it as resolved?
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Create new user with notifications disabled

Post by hbouma »

Can we keep this open until tomorrow? I plan to test this later today in my environment and with my script that automatically adds the needed new contacts.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Create new user with notifications disabled

Post by ssax »

No problem, we'll leave it open.
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: Create new user with notifications disabled

Post by hbouma »

Everything looks good. You may close this topic.

Thank you for the help.
Locked