Page 1 of 1
How to detect if 'Apply Config' has failed?
Posted: Fri Apr 28, 2017 2:56 pm
by MrWoodward
Currently, my team is leveraging the NagiosXI REST API to get a lot of our work done programmatically. Lately, we've been using it to add Hosts and Services in bulk. After adding the Hosts/Services, we call the "apply config" API and it theoretically applies the configuration.
Currently, we can check the status thru the GUI and even check the 'View Command Output' to see why it failed.
Unfortunately, we get no error message when it fails to apply via the REST API. Is there an API call that we can use to check on the applied config and if it failed or not and why?
Thanks.
Re: How to detect if 'Apply Config' has failed?
Posted: Fri Apr 28, 2017 3:47 pm
by cdienger
prior to applying changes, check the process_id with:
http://w.x.y.z/nagiosxi/api/v1/system/s ... y&pretty=1
The process_id will update when the configuration is successfully applied.
Re: How to detect if 'Apply Config' has failed?
Posted: Mon May 01, 2017 3:26 pm
by MrWoodward
Ok, I'll test this out and get back to you.
Re: How to detect if 'Apply Config' has failed?
Posted: Mon May 01, 2017 3:31 pm
by cdienger
Sounds like a plan! Let us know how it works out for you.
Re: How to detect if 'Apply Config' has failed?
Posted: Mon May 01, 2017 3:48 pm
by MrWoodward
From my testing, when the config is successfully applied, a new process is started and thus a new process ID is listed. When it fails, the process does not restart nor does the process ID change.
So how can I tell when it has failed? No other flags are listed as "failed" or anything of that nature. Also, presumably, I'll have to poll this API call until I see a change or it passes a timeout, but how long do I need to poll for?
Also, how to I obtain the "error log" of why the apply failed?
Thanks.
Re: How to detect if 'Apply Config' has failed?
Posted: Mon May 01, 2017 4:53 pm
by ssax
I've reached out to the developers to see if they have any ideas, if you don't hear from us by mid-day tomorrow respond to the thread so it pops up on our dashboard.
Thank you
Re: How to detect if 'Apply Config' has failed?
Posted: Wed May 03, 2017 10:19 am
by MrWoodward
*nudge*
Any updates on this?
Thanks.
Re: How to detect if 'Apply Config' has failed?
Posted: Wed May 03, 2017 2:14 pm
by dwhitfield
The devs are certainly aware of the issue. I don't know if there will be a 5.4.5, but either there or in 5.5.0 would be the first place you might see it. There is no release date set yet for 5.5. I would say mark your calendar for Sept 1, and if there isn't anything about this in the 5.5.0 changelog or 5.5.0 isn't out, then we can give you an update.
Re: How to detect if 'Apply Config' has failed?
Posted: Wed May 03, 2017 3:32 pm
by MrWoodward
Well, good news, bad news, okay news.
It's good that the devs know it and are planning a fix; bad news that it is so far out; okay news because I've figured out a work-around.
Our code will run on the Nagios instance itself, so it should be able to monitor /usr/local/nagiosxi/nom/checkpoints/nagioscore and /usr/local/nagiosxi/nom/checkpoints/nagioscore/error subdirectories and if a new file shows up in one or the other, then it should be easy to determine whether it was successful or failed and why (since the logs are text files in the same folder.)
Thanks for the help. You can close this ticket.
Re: How to detect if 'Apply Config' has failed?
Posted: Wed May 03, 2017 3:50 pm
by dwhitfield
No problem. As far as I understand it, the chief concern among the devs was making sure the right apply config status was showed. Like, if someone applied the config from UI or the command line, they didn't want to display *that* failure.
I don't anticipate 5.5.0 will be *that* far out, but it partially depends on if there is a 5.4.5. 5.2 went up to .9 while 5.3 only went up to .4. Listing the variables would be a pretty boring read. I suppose I should have said once you see the 5.5.0 changelog you should post back in here, but hard to set a calendar entry for an unknown date, so I picked what I suspect is a safe date.
All of that said, locking it up.