query NagiosXI alarms

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

query NagiosXI alarms

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: query NagiosXI alarms

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

Re: query NagiosXI alarms

Post 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.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: query NagiosXI alarms

Post by cdienger »

The objects/logentries and objects/statehistory endpoints should give you what you're looking for.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

Re: query NagiosXI alarms

Post by elinagios »

At the moment the objects/logentries and objects/statehistory give last 24h alarms, is there a way to get longer time period?
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: query NagiosXI alarms

Post by cdienger »

Yes. At the top of the "REST API - Objects Reference" are instructions for building queries with the starttime and endtime parameters.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

Re: query NagiosXI alarms

Post 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?
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: query NagiosXI alarms

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
elinagios
Posts: 146
Joined: Thu Feb 16, 2017 3:45 am

Re: query NagiosXI alarms

Post 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
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: query NagiosXI alarms

Post 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).
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked