Hi,
Hope someone can help.
I have about 10 different contactgroups to allow notifications for different aspects of the system eg: network system dev
I want to be able to list the services that are defined for a specific contactgroup
IE: Show all service belonging to the network contact group
I have tried playing around with config.cgi but no luck
I thought about writing a script that looks in the *.cfg files but that looks very difficult trying to figure out where all the contacts are defined.
Does anyone have an ideas on how I can achieve this.
Thanks in advance
Pete
Display All Services for a specific contactgroup
-
- Posts: 3
- Joined: Sat Aug 11, 2018 11:24 am
Re: Display All Services for a specific contactgroup
The JSON CGIs are your best friend:
https://labs.nagios.com/2014/06/19/expl ... -7-part-1/
Those CGIs should be included with any modern Nagios Core installation. To get all services associated with a contactgroup named admins:
On an install using just the demo configurations:
Might also consider adding jq to your toolbox -- it's like sed/grep but for structured JSON:
https://stedolan.github.io/jq/
https://labs.nagios.com/2014/06/19/expl ... -7-part-1/
Those CGIs should be included with any modern Nagios Core installation. To get all services associated with a contactgroup named admins:
Code: Select all
http://your.nagios.instance/cgi-bin/objectjson.cgi?query=servicelist&contactgroup=admins
Code: Select all
$ curl -u nagiosadmin:nagios -XGET 'http://127.0.0.1:8080/cgi-bin/objectjson.cgi?query=servicelist&contactgroup=admins'
{
"format_version": 0,
"result": {
"query_time": 1631139069000,
"cgi": "objectjson.cgi",
"user": "nagiosadmin",
"query": "servicelist",
"query_status": "released",
"program_start": 1631138250000,
"last_data_update": 1631138250000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"contactgroup": "admins"
},
"servicelist": {
"localhost": [
"Current Load",
"Current Users",
"HTTP",
"PING",
"Root Partition",
"SSH",
"Swap Usage",
"Total Processes"
]
}
}
}
https://stedolan.github.io/jq/
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/