Page 1 of 1

Seeing contactgroup information via the web UI

Posted: Wed Nov 13, 2013 12:02 pm
by r0tty
Hi,

Using the nagios web interface is it possible to extract the contactgroups associated with a server and the e-mail addresses associated with the contactgroups?

The reason I ask is that I'm using curl to control and report on my Nagios instance and I want to use the same technique for a script I am developing. If I could work out how to get the information on screen I could easily work out the curl command.

David

Re: Seeing contactgroup information via the web UI

Posted: Wed Nov 13, 2013 2:06 pm
by abrist
There are a few ways to get this information.

1. You could create a script that parses the objects.cache file for the desired information. Depending on how you named objects, this can be difficult to parse (and cannot be curled).

2. Utilize a combination of configuration pages:

The following will give you a single row table with the host object information (including contacts and contactgroups)

Code: Select all

http://<ip>/nagios/cgi-bin/config.cgi?type=hosts&expand=<host name>
The next url will show you a table of the members of the contact group in question:

Code: Select all

http://<ip>/nagios/cgi-bin/config.cgi?type=contactgroups&expand=<contactgroup>
The final url will show you a table of the contact, including the email address:

Code: Select all

http://<ip>/nagios/cgi-bin/config.cgi?type=contacts&expand=<contact>
With these three urls, you should be able to write logic to curl and parse to variables in your script. Best of luck!

Re: Seeing contactgroup information via the web UI

Posted: Fri Nov 15, 2013 1:34 pm
by r0tty
Simply beautiful! I've not scripted it yet, but the URLs are exactly what I need - scripting it will be easy from here. Much appreciated.

Rotty

Re: Seeing contactgroup information via the web UI

Posted: Fri Nov 15, 2013 2:01 pm
by tmcdonald
Good luck! Closing thread, feel free to open another if you need it.