diff --git a/sample-config/naemon.cfg.in b/sample-config/naemon.cfg.in index 091e3773..a852bd90 100644 --- a/sample-config/naemon.cfg.in +++ b/sample-config/naemon.cfg.in @@ -1042,6 +1042,10 @@ allow_empty_hostgroup_assignment=0 # # While desirable in some environments, enabling this value can distort report # values as the expected quantity of checks will not have been performed +# Valid values are: +# 0 Keep services running (default) +# 1 Do not run service checks. +# 2 Keep services running as long as they are ok/warning. #host_down_disable_service_checks=0 diff --git a/src/naemon/checks_service.c b/src/naemon/checks_service.c index 0222a373..fe0cff54 100644 --- a/src/naemon/checks_service.c +++ b/src/naemon/checks_service.c @@ -218,9 +218,23 @@ static void handle_service_check_event(struct nm_event_execution_properties *evp if ((temp_host = temp_service->host_ptr) == NULL) { log_debug_info(DEBUGL_CHECKS, 2, "Host pointer NULL in handle_service_check_event().\n"); return; - } else { - if (temp_host->current_state != STATE_UP) { + } + if (temp_host->current_state != STATE_UP) { + int keep_running = TRUE; + switch (host_down_disable_service_checks) { + /* only keep running if service is up or host_down_disable_service_checks is disabled */ + case HOST_DOWN_STOPS_SERVICE_CHECKS: log_debug_info(DEBUGL_CHECKS, 2, "Host state not UP, so service check will not be performed - will be rescheduled as normal.\n"); + keep_running = FALSE; + break; + case HOST_DOWN_KEEP_UP_SERVICES_RUNNING: + if (temp_service->current_state > STATE_WARNING) { + log_debug_info(DEBUGL_CHECKS, 2, "Host and service state not UP, so service check will not be performed - will be rescheduled as normal.\n"); + keep_running = FALSE; + } + break; + } + if(!keep_running) { if (service_skip_check_host_down_status >= 0) { temp_service->current_state = service_skip_check_host_down_status; if (strstr(temp_service->plugin_output, "(host is down)") == NULL) { diff --git a/src/naemon/defaults.h b/src/naemon/defaults.h index c1dd48a1..136ab629 100644 --- a/src/naemon/defaults.h +++ b/src/naemon/defaults.h @@ -88,6 +88,8 @@ #define DEFAULT_ALLOW_EMPTY_HOSTGROUP_ASSIGNMENT 2 /* Allow assigning to empty hostgroups by default, but warn about it */ #define DEFAULT_ALLOW_CIRCULAR_DEPENDENCIES 0 /* Allow circular dependencies */ #define DEFAULT_HOST_DOWN_DISABLE_SERVICE_CHECKS 0 /* run service checks if the host is down */ +#define HOST_DOWN_STOPS_SERVICE_CHECKS 1 /* do not run service checks if the host is down */ +#define HOST_DOWN_KEEP_UP_SERVICES_RUNNING 2 /* run service checks as long as the host and service is up (ok/warning) */ #define DEFAULT_SKIP_CHECK_STATUS -1 /* do not change status by default */ #define DEFAULT_HOST_PERFDATA_FILE_TEMPLATE "[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$"