Trying to find the best way to pull information

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
teh0015
Posts: 59
Joined: Tue Jul 07, 2015 9:07 am

Trying to find the best way to pull information

Post by teh0015 »

What I want is to regularly dump every Host -> Service -> Contact(s) from Nagios servers into a csv.

Seems simple enough but I need to do this on a number of Nagios servers (both XI *and Core [34]).
Access to the Nagios servers ranges from login/sudo to just readonly web access.

I've looked at directly pulling from an XI db, or using check_MK, but ideally I'd like to find a single solution that works across all of them.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Trying to find the best way to pull information

Post by rkennedy »

Assuming you're able to read /usr/local/nagios/var/objects.cache - you should be able to parse data out of here and then export it to CSV.

The other options with XI are using Help -> API, which will allow you to pull information in JSON. OR, use the 'Backend API URL' component from Admin -> Manage Components -> Click the screw driver / wrench icon.

One final thing you might find interesting for Core is the JSON handling which we have a presentation available for here - http://www.slideshare.net/nagiosinc/eri ... -nagios/46

Hopefully that helps - let us know if you have any further questions.
Former Nagios Employee
teh0015
Posts: 59
Joined: Tue Jul 07, 2015 9:07 am

Re: Trying to find the best way to pull information

Post by teh0015 »

Assuming you're able to read /usr/local/nagios/var/objects.cache
I can on some but others I only have readonly level web access.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Trying to find the best way to pull information

Post by dwhitfield »

It's possible this will need to be a feature request, but before we do that, let me ask one more question: on the Nagios servers where you have only read-only access, are you able to see every Host, Service, and Contact? If not, then I don't think there's anything we can do from a security standpoint.
Last edited by dwhitfield on Wed Jan 18, 2017 5:21 pm, edited 1 time in total.
Reason: doesn't need to just be XI servers. Could be a feature request in Core as well
teh0015
Posts: 59
Joined: Tue Jul 07, 2015 9:07 am

Re: Trying to find the best way to pull information

Post by teh0015 »

dwhitfield wrote:It's possible this will need to be a feature request, but before we do that, let me ask one more question: on the Nagios servers where you have only read-only access, are you able to see every Host, Service, and Contact? If not, then I don't think there's anything we can do from a security standpoint.
The account I'm using on those machines can see hosts / services (status) ... they *don't seem to be able to see contacts.
I suppose I can write some sort of web scraper but I was hoping there was something a bit more elegant than that.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Trying to find the best way to pull information

Post by dwhitfield »

Are contacts optional then?
teh0015
Posts: 59
Joined: Tue Jul 07, 2015 9:07 am

Re: Trying to find the best way to pull information

Post by teh0015 »

dwhitfield wrote:Are contacts optional then?
Pulling the contact data isn't *really optional.
I still need that info and on boxes I have access to I can get it but for the others I'll need to track down the admins and try to get them add a cronjob that pulls it.
Obviously it would be best if I had a single way to pull that info via the web (with readonly access) and I could use that single method against *any of them.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Trying to find the best way to pull information

Post by rkennedy »

I filed a feature request for the ability to have read-only users be able to see the object definition. The ID is #10762.

The one concern I have about this though, is that a read-only user will be able to see credentials that could be contained in the check_command - which may not be something a read-only user should have access to.
Former Nagios Employee
jwelch
Posts: 225
Joined: Wed Sep 05, 2012 12:49 pm

Re: Trying to find the best way to pull information

Post by jwelch »

I installed livestatus (from the Check_MK folks) on my Nagios XI server and it's now very easy to pull host/service/status data from Nagios on my server quickly and with low overhead. (YMMV)
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Trying to find the best way to pull information

Post by rkennedy »

Thanks for sharing your way of doing so - that would still require some access to the machine though for the OP I believe. It's a hard bargain with only having limited access.
Former Nagios Employee
Locked