Seeing contactgroup information via the web UI

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
r0tty
Posts: 13
Joined: Tue Aug 27, 2013 12:31 pm

Seeing contactgroup information via the web UI

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Seeing contactgroup information via the web UI

Post 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!
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
r0tty
Posts: 13
Joined: Tue Aug 27, 2013 12:31 pm

Re: Seeing contactgroup information via the web UI

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Seeing contactgroup information via the web UI

Post by tmcdonald »

Good luck! Closing thread, feel free to open another if you need it.
Former Nagios employee
Locked