Connect to NagiosXI DB

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Connect to NagiosXI DB

Post by tmcdonald »

Not a problem. I think you'll be pleased with the results, but we will keep this thread open in case you have further related questions.
Former Nagios employee
Sbergonzi
Posts: 127
Joined: Wed Feb 19, 2014 4:21 pm

Re: Connect to NagiosXI DB

Post by Sbergonzi »

For the XML URLs, are there parameters to request data for a specific Host and Service, or a specific Host and/or Service Group?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Connect to NagiosXI DB

Post by tmcdonald »

You can add extra parameters to the URL string to specify certain things. For example with the service status URL you can add "host_name" and "name" (of the service):

Code: Select all

http://192.168.1.100/nagiosxi/backend/?cmd=getservicestatus&username=nagiosadmin&ticket=xxxxxxx&host_name=localhost&name=Current%20Load
Same goes for "host_name" in the host status URL.

As for specifying a hostgroup I wasn't able to find any parameters that would work for that.
Former Nagios employee
Sbergonzi
Posts: 127
Joined: Wed Feb 19, 2014 4:21 pm

Re: Connect to NagiosXI DB

Post by Sbergonzi »

That was helpful. I'm trying to get at a Service Group though, returning data from a specific service of all hosts, which I put in one service group.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Connect to NagiosXI DB

Post by abrist »

I think you may need to clarify. Are you looking for a servicegroups list? Or are you looking for a list of all services that match a certain string? Something else?
The following will get you servicegroups:

Code: Select all

http://<ip>/nagiosxi/backend/?cmd=getservicegroups
The following will get you services that match a specific service description string (for example: "load"):

Code: Select all

http://<ip>/nagiosxi/backend/?cmd=getservicestatus&name=lk:load
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Connect to NagiosXI DB

Post by sreinhardt »

If you wanted the same service name for all hosts, you could do:

Code: Select all

http://192.168.1.100/nagiosxi/backend/?cmd=getservicestatus&username=nagiosadmin&ticket=xxxxxxx&name=Current%20Load
If you wanted it within a specific service group that matches the service name:

Code: Select all

http://192.168.1.100/nagiosxi/backend/?cmd=getservicegroupmembers&username=nagiosadmin&ticket=asmcbj9p&name=linux-servers&service_description=DHCP
Does that get you what you were looking for? the latter command is definitely not the full details like get service, unfortunately the backend api through both those commands does not allow filtering of both a service name and service group name with all service detail output, something specially crafted to query and compare both results would be needed to do the additional filtering, or so it seems.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Sbergonzi
Posts: 127
Joined: Wed Feb 19, 2014 4:21 pm

Re: Connect to NagiosXI DB

Post by Sbergonzi »

Because we have 1 Nagios environment for all our hosts (Prod and Non-prod) I can't run by just the service as I'll get all hosts. I grouped the service I wanted for the Prod hosts in a servicegroup, hence my challenge.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Connect to NagiosXI DB

Post by sreinhardt »

Ya in that case, you are going to have to write a script that queries for the service group host members, then query the api again for all services on those hosts that match your desired service. Finally you will have to merge that data from all services into something usable for you. That is about the only way I can think of doing it, but then again maybe someone will chime in with a different awesome route.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Sbergonzi
Posts: 127
Joined: Wed Feb 19, 2014 4:21 pm

Re: Connect to NagiosXI DB

Post by Sbergonzi »

Yep, working on that approach though I like your alternate idea ... "maybe someone will chime in with a different awesome route" :)
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Connect to NagiosXI DB

Post by sreinhardt »

Sounds good, let us know what you come up with, if you can, I would be interested in seeing an example of it.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked