diff --git a/sample-config/naemon.cfg.in b/sample-config/naemon.cfg.in index a877dc516..5e83261e3 100644 --- a/sample-config/naemon.cfg.in +++ b/sample-config/naemon.cfg.in @@ -1048,9 +1048,9 @@ allow_empty_hostgroup_assignment=0 # SET SERVICE/HOST STATUS WHEN SERVICE CHECK SKIPPED # These options will allow you to set the status of a service when its -# service check is skipped due to one of three reasons: -# 1) failed dependency check; 2) parent's status; 3) host not up -# Number 3 can only happen if 'host_down_disable_service_checks' above +# service check is skipped due to one of two reasons: +# 1) failed dependency check; 2) host not up +# Number 2 can only happen if 'host_down_disable_service_checks' above # is set to 1. # Valid values for the service* options are: # -1 Do not change the service status (default) @@ -1059,7 +1059,6 @@ allow_empty_hostgroup_assignment=0 # 2 Set the service status to STATE_CRITICAL # 3 Set the service status to STATE_UNKNOWN #service_skip_check_dependency_status=-1 -#service_skip_check_parent_status=-1 #service_skip_check_host_down_status=-1 # The host_dependency_skip_check_status option will allow you to set the diff --git a/src/naemon/checks_host.c b/src/naemon/checks_host.c index b9245c73f..2134eaa04 100644 --- a/src/naemon/checks_host.c +++ b/src/naemon/checks_host.c @@ -241,8 +241,14 @@ static int run_async_host_check(host *hst, int check_options, double latency) /* check host dependencies for execution */ log_debug_info(DEBUGL_CHECKS, 0, "Host '%s' checking dependencies...\n", hst->name); if (check_host_dependencies(hst, EXECUTION_DEPENDENCY) == DEPENDENCIES_FAILED) { - if (service_skip_check_dependency_status >= 0) { - hst->current_state = service_skip_check_dependency_status; + if (host_skip_check_dependency_status >= 0) { + hst->current_state = host_skip_check_dependency_status; + if(strstr(hst->plugin_output, "(host dependency check failed)") == NULL) { + char *old_output = nm_strdup(hst->plugin_output); + nm_free(hst->plugin_output); + nm_asprintf(&hst->plugin_output, "(host dependency check failed) was: %s", old_output); + nm_free(old_output); + } } log_debug_info(DEBUGL_CHECKS, 0, "Host '%s' failed dependency check. Aborting check\n", hst->name); diff --git a/src/naemon/checks_service.c b/src/naemon/checks_service.c index 331b76007..df9a77a0b 100644 --- a/src/naemon/checks_service.c +++ b/src/naemon/checks_service.c @@ -201,8 +201,14 @@ static void handle_service_check_event(struct nm_event_execution_properties *evp /* check service dependencies for execution */ log_debug_info(DEBUGL_CHECKS, 0, "Service '%s' on host '%s' checking dependencies...\n", temp_service->description, temp_service->host_name); if (check_service_dependencies(temp_service, EXECUTION_DEPENDENCY) == DEPENDENCIES_FAILED) { - if (service_skip_check_parent_status >= 0) { - temp_service->current_state = service_skip_check_parent_status; + if (service_skip_check_dependency_status >= 0) { + temp_service->current_state = service_skip_check_dependency_status; + if(strstr(temp_service->plugin_output, "(service dependency check failed)") == NULL) { + char *old_output = nm_strdup(temp_service->plugin_output); + nm_free(temp_service->plugin_output); + nm_asprintf(&temp_service->plugin_output, "(service dependency check failed) was: %s", old_output); + nm_free(old_output); + } } log_debug_info(DEBUGL_CHECKS, 0, "Service '%s' on host '%s' failed dependency check. Aborting check\n", temp_service->description, temp_service->host_name); return; @@ -217,7 +223,13 @@ static void handle_service_check_event(struct nm_event_execution_properties *evp if(temp_host->current_state != STATE_UP) { log_debug_info(DEBUGL_CHECKS, 2, "Host state not UP, so service check will not be performed - will be rescheduled as normal.\n"); if (service_skip_check_host_down_status >= 0) { - temp_host->current_state = service_skip_check_host_down_status; + temp_service->current_state = service_skip_check_host_down_status; + if(strstr(temp_service->plugin_output, "(host is down)") == NULL) { + char *old_output = nm_strdup(temp_service->plugin_output); + nm_free(temp_service->plugin_output); + nm_asprintf(&temp_service->plugin_output, "(host is down) was: %s", old_output); + nm_free(old_output); + } } return; } diff --git a/src/naemon/configuration.c b/src/naemon/configuration.c index 1e107b15a..16638d614 100644 --- a/src/naemon/configuration.c +++ b/src/naemon/configuration.c @@ -1077,13 +1077,6 @@ read_config_file(const char *main_config_file, nagios_macros *mac) error = TRUE; break; } - } else if(!strcmp(variable,"service_skip_check_parent_status")) { - service_skip_check_parent_status = atoi(value); - if (service_skip_check_parent_status < -1 || service_skip_check_parent_status > 3) { - nm_asprintf(&error_message, "Illegal value for service_skip_check_parent_status"); - error = TRUE; - break; - } } else if (!strcmp(variable,"service_skip_check_host_down_status")) { service_skip_check_host_down_status = atoi(value); if (service_skip_check_host_down_status < -1 || service_skip_check_host_down_status > 3) { diff --git a/src/naemon/defaults.h b/src/naemon/defaults.h index 749d6a26d..a26b19d21 100644 --- a/src/naemon/defaults.h +++ b/src/naemon/defaults.h @@ -88,6 +88,7 @@ #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 depdendencies */ #define DEFAULT_HOST_DOWN_DISABLE_SERVICE_CHECKS 0 /* run service checks if the host is down */ +#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$" #define DEFAULT_SERVICE_PERFDATA_FILE_TEMPLATE "[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$" diff --git a/src/naemon/globals.h b/src/naemon/globals.h index 4bb2565c9..fa0f744c9 100644 --- a/src/naemon/globals.h +++ b/src/naemon/globals.h @@ -147,7 +147,6 @@ extern int allow_empty_hostgroup_assignment; extern int allow_circular_dependencies; extern int host_down_disable_service_checks; extern int service_skip_check_dependency_status; -extern int service_skip_check_parent_status; extern int service_skip_check_host_down_status; extern int host_skip_check_dependency_status; diff --git a/src/naemon/utils.c b/src/naemon/utils.c index f2809128e..bf43f6aa9 100644 --- a/src/naemon/utils.c +++ b/src/naemon/utils.c @@ -166,10 +166,9 @@ char *use_timezone = NULL; int allow_empty_hostgroup_assignment = DEFAULT_ALLOW_EMPTY_HOSTGROUP_ASSIGNMENT; int allow_circular_dependencies = DEFAULT_ALLOW_CIRCULAR_DEPENDENCIES; int host_down_disable_service_checks = DEFAULT_HOST_DOWN_DISABLE_SERVICE_CHECKS; -int service_skip_check_dependency_status = -1; -int service_skip_check_parent_status = -1; -int service_skip_check_host_down_status = -1; -int host_skip_check_dependency_status = -1; +int service_skip_check_dependency_status = DEFAULT_SKIP_CHECK_STATUS; +int service_skip_check_host_down_status = DEFAULT_SKIP_CHECK_STATUS; +int host_skip_check_dependency_status = DEFAULT_SKIP_CHECK_STATUS; static long long check_file_size(char *, unsigned long, struct rlimit);