Custom API - Apply Config needed
Posted: Wed Mar 31, 2021 2:12 am
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:
This will return:
{"ApplyConfigNeeded":"0"}
Happy coding
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