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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
almitov
Posts: 3
Joined: Fri Jun 23, 2017 3:22 am

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

Post 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?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
almitov
Posts: 3
Joined: Fri Jun 23, 2017 3:22 am

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

Post 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...
almitov
Posts: 3
Joined: Fri Jun 23, 2017 3:22 am

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

Post 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...
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

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

Post 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
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post by tgriep »

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked