Page 1 of 1

How to verify successful application of config via api 5.4.x

Posted: Fri Dec 14, 2018 10:44 am
by andrewatmacys
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?

Re: How to verify successful application of config via api 5

Posted: Fri Dec 14, 2018 10:53 am
by scottwilkerson
If you apply the config with a command like this:

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}
You will get a command_id # such as 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."
    }
]
status_code 2 mean it is completed, the result_code 0 means it completed successfully.

Re: How to verify successful application of config via api 5

Posted: Tue Dec 18, 2018 1:08 pm
by andrewatmacys
Thank you! Sorry for the late replay, but this appears to be exactly what I was looking for!

Re: How to verify successful application of config via api 5

Posted: Tue Dec 18, 2018 2:01 pm
by andrewatmacys
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?

Re: How to verify successful application of config via api 5

Posted: Tue Dec 18, 2018 2:25 pm
by lmiltchev
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.