Page 1 of 1
RRD graph api
Posted: Mon Apr 08, 2013 10:16 pm
by tlawson
Hello,
I would like to view RRD graphs on a remote server.
Does Nagios XI have an API? The only solution i have found is rsync the data to the other server
Re: RRD graph api
Posted: Tue Apr 09, 2013 10:56 am
by abrist
1. If you can access the XI web ui frontend, you could always look at the graphs that way.
2. You could also look at the graph explorer component. There is a fetch_rrd php function that could be snipped and altered.
3. You can access the graphs directly through a url:
For example:
Code: Select all
https://XI_SERVER_IP/nagiosxi/includes/components/perfdata/graphApi.php?host=HOST_IP&service=_HOST_&source=1&view=1&start=&end=&rand=1365528046
Replace XI_SERVER_IP with the address of your nagios server and HOST_IP with the host you want to view. There are also some timeframe parameters that you can pass at the end. If you are curious what the direct urls for your hosts and services are, go into XI --> host or service details --> Click an host/service --> go to the performance graphs tab --> Right click and copy the image url for a graph --> paste it into your browser and you should have the direct url for the graph.
Re: RRD graph api
Posted: Tue Apr 09, 2013 6:46 pm
by tlawson
abrist,
Thank you for your fast responce.
Is there any way to authenticate from URL?
I get "Your session has timed out." if i view it from a computer that is not logged into Nagios XI
Re: RRD graph api
Posted: Wed Apr 10, 2013 1:37 pm
by sreinhardt
Yes using a series of post and get requests it would look similar to:
Client request Server Response
GET nagiosxi/login.php -> nagiosxi/login.php cookie nagiosxi=[string]
GET nagiosxi/ajaxhelper.php... -> param nsp=[string]
POST nagiosxi/login.php &page=auth&debug=&pageopt=login&username=[Nagiosuser]&password=[NagiosPassword]&loginButton=Login
You will request login.php for the initial cookie identified by the string nagiosxi=
After a few automate redirects and requests through pages provided by the server, your browser or script provides the cookie and gets a response including an nsp token.
Finally, you can post to login.php with the additional parameters of:
nsp=[string]
page=auth
debug=
pageopt=login
username=[NagiosUser]
password=[NagiosPassword]
loginButton=Login
Once this post is made successfully, you will only need to pass the nagiosxi cookie id and tag to continue with the same session.
Re: RRD graph api
Posted: Wed Apr 10, 2013 1:37 pm
by mguthrie
@sreinhart: There's an easier way
Yes, you can use the Backend API URl component to fetch a user's backend ticket. So if you added to that URL:
&username=myuser&ticket=knaonj808an
You should be able to fetch the graph that way.
Re: RRD graph api
Posted: Thu Apr 18, 2013 12:31 am
by tlawson
sreinhardt,
i have been trying your method with curl but i am getting the message "NSP: Sorry Dave, I can't let you do that" on screen.
What am i doing wrong?
Re: RRD graph api
Posted: Thu Apr 18, 2013 12:00 pm
by mguthrie
The auth is failing because the URL is missing an additional session token. Try the backend ticket method and see if that works.