Nagios API Notifications Enable/Disable

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
vy3734
Posts: 109
Joined: Tue Sep 29, 2015 4:48 pm

Nagios API Notifications Enable/Disable

Post by vy3734 »

How to enable/disable notifications per host via the Nagios API?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios API Notifications Enable/Disable

Post 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.
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

Post 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)
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Nagios Enterprises
Senior Developer
Locked