Page 1 of 1

Updating XI data programmatically

Posted: Tue Nov 15, 2016 7:03 am
by CWSI
Hi guys,

I have a couple of requirements to update data in XI that from what I can tell cannot be easily done within the UI, for example I want to update the host X/Y coordinates by calling an external API which will return location data when supplied with a hostname/IP, or I want to create some custom variables for hosts etc. At a couple of hundred hosts and needing to refresh this data fairly regularly I think the best way to do this is with an external script that runs on the XI server and writes the data into XI somehow, so my question is what is the best way to do this?

We're on 2014R2.7 at the moment so do not have access to the new APIs, but if that is the mest solution we could certainly upgrade. So I guess the options are write to the config files themselves, but not sure if XI will overwrite those changes and of course dealing with files isn't the cleanest. Then I guess we could write to the mySQL tables that XI is based on.


Any thoughts/suggestions?

Re: Updating XI data programmatically

Posted: Tue Nov 15, 2016 10:18 am
by dwhitfield
CWSI wrote: We're on 2014R2.7 at the moment so do not have access to the new APIs, but if that is the mest solution we could certainly upgrade.
This really is the best option. I prefer the manual upgrade: https://assets.nagios.com/downloads/nag ... nstall.pdf. We get less ambiguous error messages if something does happen to go wrong. Of course, there's the GUI upgrade method as well. As always, test before you run in production.
Then I guess we could write to the mySQL tables that XI is based on.
This is a particularly bad idea, not because we don't trust your MySQL skills, but because it makes it particularly difficult to support.

Re: Updating XI data programmatically

Posted: Tue Nov 15, 2016 10:25 am
by avandemore
I don't see those values in the new API so I don't think that's going to help you at least for the current version.

If you take the host cfg in /usr/local/nagios/etc/hosts/, alter the appropriate setting(ie 2d_coords foo,bar), copy it into /usr/local/nagios/etc/import then do 1 of these 2:

1. Apply Configuration from the GUI
2.

Code: Select all

# cd /usr/local/nagiosxi/scripts/
# ./reconfigure_nagios.sh

Re: Updating XI data programmatically

Posted: Tue Nov 15, 2016 11:02 am
by CWSI
Thanks for the quick replies guys!!

Yeah agree messing with the SQL tables is always risky biscuits :). Though I think I'd be less error prone doing this than editing text files!

Thanks avandemore, I had taken a look at the API documentation a couple of times and reckoned I might have trouble with what was currently available. I think editing those files should be a runner, I'll give it a shot thanks!

Re: Updating XI data programmatically

Posted: Tue Nov 15, 2016 12:28 pm
by avandemore
Sounds good. Let us know if that works for you and if we can lock this thread.