Nagios API Notifications Enable/Disable
Nagios API Notifications Enable/Disable
How to enable/disable notifications per host via the Nagios API?
Re: Nagios API Notifications Enable/Disable
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.
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.
Former Nagios employee
-
bheden
- Product Development Manager
- Posts: 179
- Joined: Thu Feb 13, 2014 9:50 am
- Location: Nagios Enterprises
Re: Nagios API Notifications Enable/Disable
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:
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)
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]¬ification_interval=[NOTIFICATION_INTERVAL]¬ification_period=none&applyconfig=1"As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Nagios Enterprises
Senior Developer
Nagios Enterprises
Senior Developer