Hi.
Can you verify our approach on this method to obtain the availability report data via the API?
Are these the API and parameter settings to pull the same content the current CSV extract is gathering for the server availability reporting? It appears that it is running the exact same report, though I would like you to verify and confirm. The start/end times are seconds since the Epoch for the selected time period. We are planning to load this information daily (each day pulls yesterday's info) so we can see the current month trends as well as prior months.
url = (nagios_server + '/nagios/cgi-bin/archivejson.cgi?'+
'query=availability' +
'&availabilityobjecttype=servicegroups' +
'&statetypes=hard'+
'&servicegroup=SLA-Compliance-Server-Availability-Check.TCP-Ping-and-Agent-Activity'+
'&assumeinitialstate=true' +
'&assumestateretention=true' +
'&assumestatesduringnagiosdowntime=true'+
'&assumedinitialhoststate=up' +
'&assumedinitialservicestate=ok' +
'&backtrackedarchives=4'+
'&starttime={}'.format(long(time.mktime(sync_from.timetuple()))) +
'&endtime={}'.format(long(time.mktime(sync_to.timetuple()))))
We built up the info on this URL from the JSON query page: https://ourserver/nagios/jsonquery.html
Thanks!
Obtaining Availability Report Data Via API
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Obtaining Availability Report Data Via API
Hi, @awilson. If you wanted to download the availability report from the command line you could use this command:
Backend ticket needs to be enabled from the System Settings in XI -> Backward Compatibility tab. Then you can get the actual ticket by clicking on the username at the top right corner. It should be at the bottom of the page.
Replace the IP address with XI IP address. And replace my ticket with your "insecure backend API ticket".[root@centos7x64 init.d]# curl "http://192.168.3.3/nagiosxi/reports/ava ... t=clj4c5Ri"
Backend ticket needs to be enabled from the System Settings in XI -> Backward Compatibility tab. Then you can get the actual ticket by clicking on the username at the top right corner. It should be at the bottom of the page.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Obtaining Availability Report Data Via API
Would this give us the report or the data seen in the report in JSON format?
I see that it says CSV. We are on 5.4.4. I don't see a Backward Compatibility tab.
Thanks.
I see that it says CSV. We are on 5.4.4. I don't see a Backward Compatibility tab.
Thanks.
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Obtaining Availability Report Data Via API
@awilson, Here is the instruction on how to enable backend API on your version of XI. You can copy backend api ticket from the backend API URL(page 3 of this tutorial).
https://assets.nagios.com/downloads/nag ... nd_API.pdf
The output is not in json format.
The json query you suggested seems valid as well. The output repeats the legacy availability report.
https://assets.nagios.com/downloads/nag ... nd_API.pdf
The output is not in json format.
The json query you suggested seems valid as well. The output repeats the legacy availability report.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Obtaining Availability Report Data Via API
We are using Nagios XI 5.4.4
We notice that running the legacy Availability report avail.cgi gives different results from archivejson.cgi. Is this due to our being on an older release? Is this the same issue analyzed in out ticket #191120?
Thanks!
We notice that running the legacy Availability report avail.cgi gives different results from archivejson.cgi. Is this due to our being on an older release? Is this the same issue analyzed in out ticket #191120?
Thanks!
You do not have the required permissions to view the files attached to this post.
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Obtaining Availability Report Data Via API
@awilson, I ran JSON and legacy reports on XI 5.4.12 and both matched. I suggest checking the arguments like "assume initial state", "assume state retention" and similar. If some of them are different on 2 reports that can cause differences in the data. Also, make sure that the timestamp you're using in the JSON report exactly corresponds with the time you chose on the legacy report.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Obtaining Availability Report Data Via API
Thanks. I'll check
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Obtaining Availability Report Data Via API
Sounds good.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Obtaining Availability Report Data Via API
Can archivejson.cgi or avail.cgi exclude scheduled downtime? Is there a way to pull the same exact availability reports from the api as from the UI?
Thanks
Thanks
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: Obtaining Availability Report Data Via API
@awilson, No it's not possible to exclude downtime. But there's an option to exclude downtime in the command I gave you earlier. This command is using the new availability report in XI.
But yes, this command is not using JSON. JSON command does not have the functionality to exclude downtime.
One easy way to find a curl command for the report you like is to run a developer tool in chrome while you're generating a new report from the GUI. It will show you the command+arguments that you can reuse later.
But yes, this command is not using JSON. JSON command does not have the functionality to exclude downtime.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.