Page 1 of 2
Get stats programmatically
Posted: Thu Nov 03, 2016 3:02 pm
by maltman
I am trying to pull down some service stats and parse the results into a report. I can pull down the data I want from the cgi-bin, but the result is a file that is downloaded to my computer. Is there anyway to read the data directly without creating the file? Or is there a way to pull the same information in JSON format? We are on XI 2012R2.8c.
Thanks
Re: Get stats programmatically
Posted: Thu Nov 03, 2016 3:54 pm
by maltman
So I found this when looking at the backend API.
http://<nagios server>/nagiosxi/backend/?cmd=getservicestatus&username=user&ticket=number
The results are in XML but it gives me every service. This there a way to pass different parameters to the backend API?
Re: Get stats programmatically
Posted: Thu Nov 03, 2016 4:02 pm
by maltman
One more thing. I see everything I need except for availability. Can this be pulled from a different URL?
Re: Get stats programmatically
Posted: Thu Nov 03, 2016 4:40 pm
by dwhitfield
maltman wrote:We are on XI 2012R2.8c.
There are a lot of new features in 2014, and of course we just released 5.3.2. Any reason keeping you from upgrading?
Also, since your system is old, what OS are you running? CentOS 5 runs out of support in March. When you upgrade your OS might be a good time to upgrade Nagios.
Re: Get stats programmatically
Posted: Thu Nov 03, 2016 4:49 pm
by maltman
I noticed that the version was really old as well. I have brought this up but I am not sure when we will upgrade it. The OS is 6.3. Not sure why Nagios wasn't updated when the OS was.
I will continue to try getting it updated so I can use the REST API but until then, is there anything that I can do with the backend API? getservicestatus is good except I need availability data for my services. I can parse the XML also if there is no possibility of JSON.
Re: Get stats programmatically
Posted: Thu Nov 03, 2016 5:05 pm
by rkennedy
You can append &name= to specify exactly which data set you are looking for. As an example -
http://192.168.3.115/nagiosxi/backend/? ... escalation
Re: Get stats programmatically
Posted: Fri Nov 04, 2016 9:03 am
by maltman
It looks like that gives the same type of information. It is good as it contains execution time, latency, performance data, etc. but I was hoping to find something with availability percentage of the services.
We have it set up with a host and several services under that host which we can then pull into a report. We are achieving this right now with a call to cgi-bin but I don't like this as it triggers a file download and the file is in HTML format. But the availability data is stored in there.
I guess, long story short, is there a way to get the availability report through the backend API?
Re: Get stats programmatically
Posted: Fri Nov 04, 2016 10:47 am
by avandemore
JSON query generator has some of this capability: http://<Your Nagios Host>/nagios/jsonquery.html
The new api also You can do something like XI > Help > GET objects/statehistory and roll your own availability report.
The API is extendable, you are able to pursue that option as well. See Help > Custom API Endpoints.
Also we offer custom development services for a fee. Let us know if you are interested in that option.
Re: Get stats programmatically
Posted: Fri Nov 04, 2016 11:01 am
by maltman
Thank you for the reply. I do not see the Custom API Endpoints in the Help screen from our portal. Is there another way to access this?
Re: Get stats programmatically
Posted: Fri Nov 04, 2016 11:07 am
by avandemore
I believe the version you're using doesn't support the newer API. You would need to upgrade.