Get List of contact groups for service/host

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cmif
Posts: 12
Joined: Mon Sep 12, 2016 2:28 am

Get List of contact groups for service/host

Post by cmif »

Hi,

Is there a way to view all the contact groups that can view a particular alarm in the status detail page. The servicegroups and hostgroups that the service/hosts are part of, are already being shown. I could not find a way to add this even by using the backend cmds

Is there a way to accomplish this? Maybe I am missing something

Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Get List of contact groups for service/host

Post by rkennedy »

Currently, this isn't going to be possible. You would need to look from the Configure -> Core Config Manager and find the host / service here.

I did file a feature request for this though, so it may make it into a future version!

Code: Select all

NEW TASK ID 11101 created - Nagios XI Feature Request: Add ability to see who is enabled on notifications from host / service detail level
Former Nagios Employee
cmif
Posts: 12
Joined: Mon Sep 12, 2016 2:28 am

Re: Get List of contact groups for service/host

Post by cmif »

Thanks. It would really be useful to have such functionality to determine if the right people can view the alarm being shown.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Get List of contact groups for service/host

Post by mcapra »

If you were feeling particularly ambitious, you could probably script this out using the Core JSON CGIs located here:

Code: Select all

http://<nagios_host>/nagios/jsonquery.html
If I wanted to get all the contacts under the host "mywmi.host.com" for the service "CPU Usage", I could run the following query:

Code: Select all

http://192.168.67.1/nagios/cgi-bin/objectjson.cgi?query=service&hostname=mywmi.host.com&servicedescription=CPU+Usage
Which will return a lovely JSON object:

Code: Select all

{
  "format_version": 0,
  "result": {
    "query_time": 1487543755000,
    "cgi": "objectjson.cgi",
    "user": "nagiosadmin",
    "query": "service",
    "query_status": "released",
    "program_start": 1487543753000,
    "last_data_update": 1487543753000,
    "type_code": 0,
    "type_text": "Success",
    "message": ""
  },
  "data": {
    "service": {
      "host_name": "mywmi.host.com",
      "description": "CPU Usage",
      "display_name": "CPU Usage",
      "check_command": "check_xi_ncpa!-t 'welcome' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'!!!!!!!",
      "event_handler": "",
      "initial_state": 0,
      "check_interval": 5.00,
      "retry_interval": 1.00,
      "max_attempts": 5,
      "parallelize": true,
      "contact_groups": [
        "IT Admins"
      ],
      "contacts": [
        "bob1",
        "nagiosadmin"
      ],
      "notification_interval": 60.00,
      "first_notification_delay": 0.00,
      "notifications_options": -1,
      "stalking_options": 0,
      "is_volatile": false,
      "notification_period": "xi_timeperiod_24x7",
      "check_period": "xi_timeperiod_24x7",
      "flap_detection_enabled": true,
      "low_flap_threshold": 0.00,
      "high_flap_threshold": 0.00,
      "flap_detection_options": -1,
      "process_performance_data": true,
      "check_freshness": false,
      "freshness_threshold": 0,
      "accept_passive_checks": true,
      "event_handler_enabled": true,
      "checks_enabled": true,
      "retain_status_information": true,
      "retain_nonstatus_information": true,
      "notifications_enabled": true,
      "obsess": true,
      "hourly_value": 0,
      "parents": [
      ],
      "children": [
      ],
      "notes": "",
      "notes_url": "",
      "action_url": "",
      "icon_image": "",
      "icon_image_alt": "",
      "custom_variables": {
        "XIWIZARD": "ncpa"
      }
    }
  }
}
Attribute of note:

Code: Select all

"contacts": [
        "bob1",
        "nagiosadmin"
      ],
Where the bob1 contact is inherited through the "IT Admins" contact group.
Former Nagios employee
https://www.mcapra.com/
Locked