Page 1 of 1

Nagios API Notifications Enable/Disable

Posted: Tue Apr 12, 2016 1:25 pm
by vy3734
How to enable/disable notifications per host via the Nagios API?

Re: Nagios API Notifications Enable/Disable

Posted: Tue Apr 12, 2016 2:01 pm
by tmcdonald
That's not built into the XI API yet, but Core still supports this via the command file:

http://old.nagios.org/developerinfo/ext ... mand_id=16

More commands can be found here:

http://old.nagios.org/developerinfo/ext ... ndlist.php

You can also send in commands through NRDP if you have that set up. I am going into a remote session at the moment so I don't have time for a full write-up, but I did a project a while back that does this sort of thing:

https://github.com/tmcnag/nagduino/blob ... gduino.cpp

If you or someone on your team knows C you can build up a command from there, otherwise post back here and I'll see about some example code.

Re: Nagios API Notifications Enable/Disable

Posted: Tue Apr 12, 2016 2:01 pm
by bheden
No proper API call for this exists as of now, but there are ways around that ;)

If you haven't changed your default timeperiods in Nagios XI, you should still have 1 labeled "none". As a workaround, you can use the POST config/host to update the host to use the "none" timeperiod as the notification_period. This would look something like:

Code: Select all

curl -XPOST "http://[YOURNAGIOSXIURL]/api/v1/config/host?apikey=[YOURAPIKEY]&pretty=1" -d "host_name=[HOST_NAME]&address=[ADDRESS]&check_command=[CHECK_COMMAND]&max_check_attempts=[MAX_CHECK_ATTEMPTS]&check_period=[CHECK_PERIOD]&contacts=[CONTACTS]&notification_interval=[NOTIFICATION_INTERVAL]&notification_period=none&applyconfig=1"
Make sure you fill out all the required fields (host_name, address, max_check_attempts, check_period, notification_interval, notification_period, contacts OR contact_groups)