Page 1 of 1
Nagios Notifications
Posted: Mon Jul 14, 2014 12:20 pm
by rentsys
Is there a command I can run that looks to see if Nagios notifications are enabled? I want to make something that emails us if Nagios notifications are disabled at a certain time of day.
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 1:12 pm
by abrist
Yes. You can use the json api to get this information if you are running core4 and XI 2014:
Code: Select all
http://<ip>/nagios/cgi-bin/statusjson.cgi?query=programstatus
Or you can use the XML XI backend to get the programstatus:
Code: Select all
http://<ip>/nagiosxi/backend/?cmd=getprogramstatus
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 1:46 pm
by rentsys
Do you know how I could output the XML XI backend into a file?
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 1:50 pm
by abrist
uh, depends. You can just wget it to a file. Curl it, and then redirect to a file. Save it in your browser. Many ways to do this. How are you retrieving it?
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 2:04 pm
by rentsys
I tried to wget it, but how do I get past the fact that it needs a username and password? I think curl is the way to go, but I don't know what type of authentication to use.
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 2:49 pm
by abrist
You can embed the basic auth credentials in the url for the core json api:
Code: Select all
curl -k http://nagiosadmin:<password>@<nagios server ip>/nagios/cgi-bin/statusjson.cgi?query=programstatus
Redirect it to a file with:
Code: Select all
curl -k http://nagiosadmin:<password>@<nagios server ip>/nagios/cgi-bin/statusjson.cgi?query=programstatus > /tmp/programstatus.json
You can add a ticket id to the XI XML url to pull the XML without a login. You can get the ticket id from the backend url component. Go to --> Admin --> Manage Components --> Backend.
Select the user you wish to log in as (I suggest a read-only user), and then copy the last two get parameters (user and ticket) from the any of the urls.
Code: Select all
curl -k http://<ip>/nagiosxi/backend/?cmd=getprogramstatus&username=<user>&ticket=<ticket id string>
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 3:15 pm
by rentsys
I have the @ sign in my password so it says
how do i get past this?
Re: Nagios Notifications
Posted: Mon Jul 14, 2014 8:28 pm
by Box293
Change your password so it doesn't have an @ symbol.
Re: Nagios Notifications
Posted: Tue Jul 15, 2014 12:50 pm
by rentsys
I just html encoder it changed the @ sign into %40, this thread can be closed.