Page 1 of 1

How are disabled service notifications documented

Posted: Tue Sep 13, 2016 1:41 pm
by awilson
Hi. We find that users sometimes disable notifications for a given service and forget to re-enable the notifications after the incident is resolved. Has anyone worked out a way to "age" the disabled state and then toggle notifications back on? Where is the "enable/disable" notifications flag stored? Can it be reached via the API?

Thanks!

Re: How are disabled service notifications documented

Posted: Tue Sep 13, 2016 3:33 pm
by mcapra
awilson wrote:Where is the "enable/disable" notifications flag stored? Can it be reached via the API?
You could make a call to the back-end API and get all service statuses where notifications_enabled=0 and current_state=0 (OK) like so:

Code: Select all

[root@localhost ~]# curl -XGET "http://<nagios_server>/nagiosxi/api/v1/objects/servicestatus?notifications_enabled=0&current_state=0&apikey=<api_key>&pretty=1"
{
    "servicestatuslist": {
        "recordcount": "1",
        "servicestatus": {
            "@attributes": {
                "id": "12952"
            },
            "instance_id": "1",
            "service_id": "546",
            "host_id": "436",
            "host_name": "192.168.67.99",
            "host_alias": "192.168.67.99",
            "name": "Application Host Helper Service",
            "host_display_name": "",
            "host_address": "192.168.67.99",
            "display_name": "Application Host Helper Service",
            "status_update_time": "2016-09-13 16:25:18",
            "status_text": "OK - Found 1 Services(s), 1 OK and 0 with problems (0 excluded). &apos;Application Host Helper Service&apos; (AppHostSvc) is Running.",
            "status_text_long": "",
            "current_state": "0",
            "performance_data": "&apos;Total Service Count&apos;=1;1; &apos;Service Count OK State&apos;=1; &apos;Service Count Problem State&apos;=0;0; &apos;Excluded Service Count&apos;=0;",
            "should_be_scheduled": "1",
            "check_type": "0",
            "last_state_change": "2016-09-13 15:31:52",
            "last_hard_state_change": "2016-09-02 10:01:01",
            "last_hard_state": "0",
            "last_time_ok": "2016-09-13 16:24:52",
            "last_time_warning": "1969-12-31 19:00:00",
            "last_time_critical": "2016-08-30 12:01:48",
            "last_time_unknown": "2016-09-13 15:31:52",
            "last_notification": "1969-12-31 19:00:00",
            "next_notification": "1969-12-31 19:00:00",
            "no_more_notifications": "0",
            "acknowledgement_type": "0",
            "current_notification_number": "0",
            "process_performance_data": "1",
            "obsess_over_service": "1",
            "event_handler_enabled": "1",
            "modified_service_attributes": "1",
            "event_handler": "",
            "check_command": "check_xi_service_wmiplus!&apos;admin&apos;!&apos;welcome123@&apos;!checkservice!-a &apos;AppHostSvc&apos; -c _Total=1: -c 0",
            "normal_check_interval": "1",
            "retry_check_interval": "1",
            "check_timeperiod_id": "131",
            "icon_image": "",
            "icon_image_alt": "",
            "has_been_checked": "1",
            "current_check_attempt": "1",
            "max_check_attempts": "5",
            "last_check": "2016-09-13 16:24:52",
            "next_check": "2016-09-13 16:25:52",
            "state_type": "1",
            "notifications_enabled": "0",
            "problem_acknowledged": "0",
            "flap_detection_enabled": "1",
            "is_flapping": "0",
            "percent_state_change": "0",
            "latency": "0",
            "execution_time": "0.21098",
            "scheduled_downtime_depth": "0",
            "passive_checks_enabled": "1",
            "active_checks_enabled": "1"
        }
    }
}
The last_hard_state_change or last_state_change fields are potential candidates for determining what the status of this object is. For example, if we see that the last state change was over 24 hours ago it might be safe to assume that the service has recovered fully and that notifications should be enabled again.

Re: How are disabled service notifications documented

Posted: Tue Sep 13, 2016 3:37 pm
by awilson
Thank you!

Ok to close this.

Alan