Skip to content

Commit

Permalink
add new option to host_down_disable_service_checks
Browse files Browse the repository at this point in the history
The issue with the host_down_disable_service_checks is that reports break because
service suddenly stop executing and keeping their OK state. So in order to
keep reporting correct, you need to keep services running, even if the host is down.
With this new option, service keep on running as long as the service returns ok or
warning. And as soon as the service is down, it stops running until the host
comes back up.
That way naemon has to do less checks, especially less checks which run
into timeouts and such and reporting is still correct.
  • Loading branch information
sni committed Mar 18, 2024
1 parent 7031173 commit e3474d5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions sample-config/naemon.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 16 additions & 2 deletions src/naemon/checks_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/naemon/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -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$"
Expand Down

0 comments on commit e3474d5

Please sign in to comment.