REST API and disabling active and passive checks

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nortonhealthcare
Posts: 33
Joined: Thu Aug 10, 2017 8:22 am

REST API and disabling active and passive checks

Post by nortonhealthcare »

Is there a way within the REST API to disable active and passive checks for a host.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: REST API and disabling active and passive checks

Post by lmiltchev »

It can be done, but you would not be modifying the config file. Basically, you would be re-adding (replacing) the host object. Here's a simple example.

I have an existing "test" host, called "MyHost". See the config below:

Code: Select all

define host {
	host_name			MyHost
	use				xiwizard_generic_host
	address				127.0.0.1
	check_command			check_dummy!0!!!!!!!
	active_checks_enabled		1
	passive_checks_enabled		0
	register			1
	}
If I wanted to disable active checks on this host, and enable passive checks, I would run:

Code: Select all

[root@main-nagios-xi ~]# curl -XPOST "http://192.168.5.151/nagiosxi/api/v1/config/host?apikey=LTltbjobR0X3V5ViDIitYaI8hjsjoFBaOcWYukamF7oAsD8lhJRvSPWq8I3PjTf7&pretty=1" -d "host_name=MyHost&address=127.0.0.1&check_command=check_dummy\!0\!&use=xiwizard_generic_host&active_checks_enabled=0&passive_checks_enabled=1&force=1&applyconfig=1"
{
    "success": "Successfully added MyHost to the system. Config applied, Nagios Core was restarted."
}
The "new" config would be:

Code: Select all

define host {
	host_name			MyHost
	use				xiwizard_generic_host
	address				127.0.0.1
	check_command			check_dummy!0!
	active_checks_enabled		0
	passive_checks_enabled		1
	register			1
	}
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked