Custom API - Apply Config needed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
IPOInS
Posts: 25
Joined: Tue Jan 14, 2020 6:08 am

Custom API - Apply Config needed

Post by IPOInS »

Another feature request for the API. But if not, or in the meantime, here's a custom API call for Nagios XI which allows you to determine if 'Apply Config' is required. This uses the same method the UI performs when you see that big red banner in CCM.
This is ideal if you want to know if the Nagios XI server is using the current configuration before making any further changes via the API.

The API command is as follows:

https://<YOUR_NAGIOS_SERVER>/nagiosxi/api/v1/custom/applyconfigneeded?apikey=<APIKEY>

The function for adding into your existing custom API php script is:

Code: Select all

register_custom_api_callback('custom', 'applyconfigneeded', 'custom_applyconfigneeded');

function custom_applyconfigneeded() {
	$ac_needed = get_option("ccm_apply_config_needed", 0);
    $xml = "<xml>
		<ApplyConfigNeeded>{$ac_needed}</ApplyConfigNeeded>
	</xml>";
	$data = simplexml_load_string($xml);
    return json_encode($data);
}

This will return:

{"ApplyConfigNeeded":"0"}

Happy coding :)
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: Custom API - Apply Config needed

Post by gsmith »

Hi

I can submit a feature request on your behalf if you'd like. Please keep in mind that the decision to implement the enhancement is at the discretion of our development team.

Thank you for including your code that provides for this functionality!

Thank you
Locked