Page 1 of 1

Back End Queries: Best Practices

Posted: Fri Oct 14, 2011 10:37 am
by dhruvaps
Hello,

We need to access the back end. I have been looking at services provided by the Backend API URL plugin, but we need more finely-grained queries than appear to be provided.

For example, we need to be able to query the current host status, returning only those with a certain command:

http://nagiosxi/nagiosxi/backend/?cmd=g ... _host_ping[/b]

Does this plugin offer a way to do that that I may have missed? Failing that, what is the best away to achieve this functionality?

Thanks,
Dhruva

Re: Back End Queries: Best Practices

Posted: Fri Oct 14, 2011 4:55 pm
by mguthrie
Currently we don't have a feature like this built into the API of XI. I know some users have actually written their own, but if that's not an option you can post it as a feature request on tracker.nagios.com.

Re: Back End Queries: Best Practices

Posted: Tue Feb 21, 2012 5:50 am
by pesho318i
Hello,
I would also need to make more fine-grained queries to the back-end. Say we're monitoring 50,000 servers and I need the status of only a single one at a time. Getting the humongous xml would not be the best way I guess...
I know some users have actually written their own...
What would be the way (flow) to write such functionality?

Thank you!

Re: Back End Queries: Best Practices

Posted: Tue Feb 21, 2012 10:35 am
by scottwilkerson
In the newest version of the backend API (with XI 2011R2.1) you can add filters to the URL string on some calls.

For example, on a gethost status call, you can add &host_id=12345 to the url and only get info on that item.
you can also use &host_name=MYHOST

For example, this

Code: Select all

https://192.168.5.69/nagiosxi/backend/?cmd=gethoststatus&username=nagiosadmin&ticket=XXXXXXXX&host_name=localhost
will only give you the status of a host with a host_name

Re: Back End Queries: Best Practices

Posted: Wed Feb 22, 2012 4:50 am
by pesho318i
That's great! Thanks for the info!

Code: Select all

For example, on a gethost status call, you can add &host_id=12345 to the url and only get info on that item.
you can also use &host_name=MYHOST
But where can I see the API's documentation with a list of possible queries?
The API Component I installed a couple of days ago by default does not offer such info in its settings.

Cheers!

Re: Back End Queries: Best Practices

Posted: Wed Feb 22, 2012 10:29 am
by scottwilkerson
Unfortunately, we don't have documentation on this yet, it is currently an undocumented/unadvertised feature but it is on the TODO list.