Page 1 of 1

REST API: How to query performance data for multiple hosts?

Posted: Thu Jun 29, 2017 5:07 am
by almitov
Is it possible to use the new REST API of Nagios XI to export the historical performance data for more then 1 host at a time?
I see that the GET objects/rrdexport option provides the historical performance data but only for a single host. Is there an option to get the data for multiple hosts at the same time?

Re: REST API: How to query performance data for multiple hos

Posted: Thu Jun 29, 2017 2:57 pm
by tgriep
It looks like you can only supply one host name in the API command line call to you cannot do multiple hosts at one time.
When I added more host names to the call, it only returned data on the first one in the list.

Re: REST API: How to query performance data for multiple hos

Posted: Mon Jul 03, 2017 1:37 am
by almitov
Hi, thanks for the reply!
And is there any suggestion on how to collect the performance data for all hosts?
I am considering the option for developing a plugin which will expose the data through HTTP requests...

Re: REST API: How to query performance data for multiple hos

Posted: Mon Jul 03, 2017 2:00 am
by almitov
And are there any recommendations on how I should collect performance data from Nagios?
The goal that I have is to collect the performances data for all the hosts and services configured on the Nagios instance on every 5 minutes for example.
I started to investigate the option to develop a plugin which will collect the data maybe through NEB and make it available for quering or directly send it somewhere...

Re: REST API: How to query performance data for multiple hos

Posted: Wed Jul 05, 2017 2:07 pm
by tgriep
I don't have any recommendations on gathering the data you are looking for but you can search the Exchange site to see if there is something that is already been published.
https://exchange.nagios.org/

Be very careful when polling the server every 5 minutes with the API, especially if there are a lot of host and service checks, it could overload the system so start small and work your way up.

Re: REST API: How to query performance data for multiple hos

Posted: Wed Jul 05, 2017 5:12 pm
by SteveBeauchemin
I use a direct DB query to get this information. We run this every 5 minutes and the result is absorbed by our log server.

Not an API call, but still, can be accessed remotely same as an API call. See if this syntax works for you.

Code: Select all

SELECT
    `nagios_hosts`.`display_name` AS Hostname,
    `nagios_services`.`display_name` AS Servicename,
    `nagios_servicestatus`.`status_update_time`,
    `nagios_servicestatus`.`output`,
    `nagios_servicestatus`.`long_output`,
    `nagios_servicestatus`.`perfdata`
FROM
    `nagios_hosts`,
    `nagios_services`
LEFT JOIN nagios_servicestatus ON 
    `nagios_services`.`service_object_id` = `nagios_servicestatus`.`service_object_id`
WHERE
    `nagios_hosts`.`host_object_id` = `nagios_services`.`host_object_id`
ORDER BY 
    `nagios_servicestatus`.`status_update_time`
Just a suggestion...

Thanks

Steve B

Re: REST API: How to query performance data for multiple hos

Posted: Thu Jul 06, 2017 12:52 pm
by tgriep