Connect to NagiosXI DB
Re: Connect to NagiosXI DB
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
Re: Connect to NagiosXI DB
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
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):
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.
Code: Select all
http://192.168.1.100/nagiosxi/backend/?cmd=getservicestatus&username=nagiosadmin&ticket=xxxxxxx&host_name=localhost&name=Current%20LoadAs for specifying a hostgroup I wasn't able to find any parameters that would work for that.
Former Nagios employee
Re: Connect to NagiosXI DB
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
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:
The following will get you services that match a specific service description string (for example: "load"):
The following will get you servicegroups:
Code: Select all
http://<ip>/nagiosxi/backend/?cmd=getservicegroupsCode: Select all
http://<ip>/nagiosxi/backend/?cmd=getservicestatus&name=lk:loadFormer 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.
"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
If you wanted the same service name for all hosts, you could do:
If you wanted it within a specific service group that matches the service name:
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.
Code: Select all
http://192.168.1.100/nagiosxi/backend/?cmd=getservicestatus&username=nagiosadmin&ticket=xxxxxxx&name=Current%20LoadCode: Select all
http://192.168.1.100/nagiosxi/backend/?cmd=getservicegroupmembers&username=nagiosadmin&ticket=asmcbj9p&name=linux-servers&service_description=DHCPNagios-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.
Re: Connect to NagiosXI DB
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
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.
Re: Connect to NagiosXI DB
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
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.