Page 1 of 2

query NagiosXI alarms

Posted: Thu Jun 14, 2018 1:18 am
by elinagios
Hello

Are the Nagiosxi alarms written to database also so you can query those, when alarm happened and when it was corrected? If yes, where is that exactly?
Or this is only written to /var/log/messages and /usr/local/nagios/var/nagios.log log files?

Re: query NagiosXI alarms

Posted: Thu Jun 14, 2018 9:02 am
by scottwilkerson
It is, but the correct place to get the info from is the API
Help -> REST API Docs

Most the information you need for this is in the Introduction and Objects Reference sections

Re: query NagiosXI alarms

Posted: Fri Jun 15, 2018 12:35 am
by elinagios
I looked at the API but i dint find the place where you could use GET method to get all alarms and the resolved state. I dont want to query a specific host or hostgroup, but all of the alarms.

Thank you.

Re: query NagiosXI alarms

Posted: Fri Jun 15, 2018 12:00 pm
by cdienger
The objects/logentries and objects/statehistory endpoints should give you what you're looking for.

Re: query NagiosXI alarms

Posted: Mon Jun 18, 2018 4:50 am
by elinagios
At the moment the objects/logentries and objects/statehistory give last 24h alarms, is there a way to get longer time period?

Re: query NagiosXI alarms

Posted: Mon Jun 18, 2018 10:48 am
by cdienger
Yes. At the top of the "REST API - Objects Reference" are instructions for building queries with the starttime and endtime parameters.

Re: query NagiosXI alarms

Posted: Tue Jun 19, 2018 2:33 am
by elinagios
This doesnt work for me. If i use the default 24h query i get result for example logentries or statehistory. If i add the starttime i get empty results in both browser and with command line curl. Even the nagiosxi own example "Displays the last week of data until now." link gives me empty result. Any ideas?

Re: query NagiosXI alarms

Posted: Tue Jun 19, 2018 10:40 am
by cdienger
It seems to be working on my 5.4.13 system. What version are you working with? What are the curl commands you are using?

Re: query NagiosXI alarms

Posted: Wed Jun 20, 2018 1:58 am
by elinagios
I have also 5.4.13 version.
Working queries:
curl -XGET "https://servername/nagiosxi/api/v1/obje ... y&pretty=1" -k
curl -XGET "https://servername/nagiosxi/api/v1/obje ... y&pretty=1" -k

Now if i try to add start-endtime, then empty result, i have tried with:
curl -XGET "https://servername/nagiosxi/api/v1/obje ... key=apikey" -k
curl -XGET "https://servername/nagiosxi/api/v1/obje ... key=apikey" -k
curl -XGET "https://servername/nagiosxi/api/v1/obje ... key=apikey" -k
curl -XGET "https://servername/nagiosxi/api/v1/obje ... key=apikey" -k

Re: query NagiosXI alarms

Posted: Wed Jun 20, 2018 4:14 pm
by cdienger
Not sure why these are failing but try it like so(keeping the epoch times and replacing apikey and server name accordingly):

curl -XGET "https://servername/nagiosxi/api/v1/obje ... key=apikey" -k
curl -XGET "https://servername/nagiosxi/api/v1/obje ... key=apikey" -k


If it is still failing, please open a ticket(https://support.nagios.com/ticket) and attach a profile(Admin > System Config > System Profile > Download System Profile).