How to verify successful application of config via api 5.4.x
-
andrewatmacys
- Posts: 114
- Joined: Tue Feb 06, 2018 9:25 am
How to verify successful application of config via api 5.4.x
Is there a way to verify a config was applied successfully via the api when the config apply command is sent via api in Nagios XI 5.4.x?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: How to verify successful application of config via api 5
If you apply the config with a command like this:
You will get a command_id # such as 8169
Then you can call the following to get the results
status_code 2 mean it is completed, the result_code 0 means it completed successfully.
Code: Select all
# curl -XPOST "http://XXX.XXX.XXX.XXX/nagiosxi/api/v1/system/applyconfig?apikey=APIKEY"
{"success":"Apply config command has been sent to the backend.","command_id":8169}Then you can call the following to get the results
Code: Select all
# curl -XGET "http://XXX.XXX.XXX.XXX/nagiosxi/api/v1/system/command/8169?apikey=APIKEY&pretty=1"
[
{
"command_id": "8169",
"submitter_id": "18",
"command": "17",
"submission_time": "2018-12-14 09:46:44.686784",
"event_time": "2018-12-14 09:46:44.686784",
"processing_time": "2018-12-14 09:46:48.075133",
"status_code": "2",
"result_code": "0",
"result": "Starting nagios: done."
}
]-
andrewatmacys
- Posts: 114
- Joined: Tue Feb 06, 2018 9:25 am
Re: How to verify successful application of config via api 5
Thank you! Sorry for the late replay, but this appears to be exactly what I was looking for!
-
andrewatmacys
- Posts: 114
- Joined: Tue Feb 06, 2018 9:25 am
Re: How to verify successful application of config via api 5
Upon trying the above I don't seem to be getting the command_id back. Is there some setting I should change to be able to get that back?
You do not have the required permissions to view the files attached to this post.
Re: How to verify successful application of config via api 5
What is the exact version of Nagios XI that you are currently using? The solution, posted by @scottwilkerson works in Nagios XI 5.5.8. There have been some new functionality, added to the REST API since Nagios XI 5.4.x. It's possible that in order to use these commands, you would need to upgrade your Nagios XI to the latest.
Be sure to check out our Knowledgebase for helpful articles and solutions!