Page 2 of 2

Re: Connect to NagiosXI DB

Posted: Fri Jun 27, 2014 11:13 am
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.

Re: Connect to NagiosXI DB

Posted: Fri Jul 11, 2014 5:29 pm
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?

Re: Connect to NagiosXI DB

Posted: Mon Jul 14, 2014 10:59 am
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.

Re: Connect to NagiosXI DB

Posted: Thu Jul 24, 2014 11:51 am
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.

Re: Connect to NagiosXI DB

Posted: Thu Jul 24, 2014 4:54 pm
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

Re: Connect to NagiosXI DB

Posted: Thu Jul 24, 2014 5:03 pm
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.

Re: Connect to NagiosXI DB

Posted: Thu Jul 24, 2014 5:31 pm
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.

Re: Connect to NagiosXI DB

Posted: Fri Jul 25, 2014 12:31 pm
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.

Re: Connect to NagiosXI DB

Posted: Fri Jul 25, 2014 1:15 pm
by Sbergonzi
Yep, working on that approach though I like your alternate idea ... "maybe someone will chime in with a different awesome route" :)

Re: Connect to NagiosXI DB

Posted: Fri Jul 25, 2014 1:36 pm
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.