Updating XI data programmatically

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
CWSI
Posts: 30
Joined: Tue Oct 28, 2014 7:41 am

Updating XI data programmatically

Post 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?
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Updating XI data programmatically

Post 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.
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Updating XI data programmatically

Post 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
Previous Nagios employee
CWSI
Posts: 30
Joined: Tue Oct 28, 2014 7:41 am

Re: Updating XI data programmatically

Post 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!
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Updating XI data programmatically

Post by avandemore »

Sounds good. Let us know if that works for you and if we can lock this thread.
Previous Nagios employee
Locked