Page 1 of 2

Create new user with notifications disabled

Posted: Mon Apr 08, 2019 1:50 pm
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?

Re: Create new user with notifications disabled

Posted: Mon Apr 08, 2019 2:39 pm
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.

Re: Create new user with notifications disabled

Posted: Mon Apr 08, 2019 2:48 pm
by hbouma
If I reboot, will it keep the notifications to that user disabled?

Re: Create new user with notifications disabled

Posted: Mon Apr 08, 2019 3:03 pm
by lmiltchev
Yes, it should.

Re: Create new user with notifications disabled

Posted: Mon Apr 08, 2019 3:13 pm
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.

Re: Create new user with notifications disabled

Posted: Mon Apr 08, 2019 3:19 pm
by hbouma
Thank you. This will be exactly what I need.

Re: Create new user with notifications disabled

Posted: Mon Apr 08, 2019 3:31 pm
by ssax
That's great to hear, are we okay to lock the topic and mark it as resolved?

Re: Create new user with notifications disabled

Posted: Tue Apr 09, 2019 7:17 am
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.

Re: Create new user with notifications disabled

Posted: Tue Apr 09, 2019 2:06 pm
by ssax
No problem, we'll leave it open.

Re: Create new user with notifications disabled

Posted: Wed Apr 10, 2019 7:37 am
by hbouma
Everything looks good. You may close this topic.

Thank you for the help.