Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Next:
Breaking changes:
* Due to object structure changes, it is recommended to recompile any NEB modules

Features:
* new attribute 'check_timeout' on `host` and `service` structs, overrides the global host / service check timeouts. (#525)

1.5.0 - Feb 03 2026
===================
Breaking changes:
Expand Down
1 change: 1 addition & 0 deletions src/naemon/checks.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef struct check_result {
double latency;
struct timeval start_time; /* time the service check was initiated */
struct timeval finish_time; /* time the service check was completed */
int timeout; /* timeout used in this check */
int early_timeout; /* did the service check timeout? */
int exited_ok; /* did the plugin check return okay? */
int return_code; /* plugin return code */
Expand Down
11 changes: 6 additions & 5 deletions src/naemon/checks_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static int run_async_host_check(host *hst, int check_options, double latency)
end_time.tv_usec = 0L;
tv_set(&hst->last_update);

neb_result = broker_host_check(NEBTYPE_HOSTCHECK_ASYNC_PRECHECK, NEBFLAG_NONE, NEBATTR_NONE, hst, CHECK_TYPE_ACTIVE, hst->current_state, hst->state_type, start_time, end_time, hst->check_command, hst->latency, 0.0, host_check_timeout, FALSE, 0, NULL, NULL, NULL, NULL, NULL);
neb_result = broker_host_check(NEBTYPE_HOSTCHECK_ASYNC_PRECHECK, NEBFLAG_NONE, NEBATTR_NONE, hst, CHECK_TYPE_ACTIVE, hst->current_state, hst->state_type, start_time, end_time, hst->check_command, hst->latency, 0.0, hst->check_timeout, FALSE, 0, NULL, NULL, NULL, NULL, NULL);

if (neb_result == NEBERROR_CALLBACKCANCEL || neb_result == NEBERROR_CALLBACKOVERRIDE) {
log_debug_info(DEBUGL_CHECKS, 0, "Check of host '%s' (id=%u) was %s by a module\n",
Expand Down Expand Up @@ -338,12 +338,13 @@ static int run_async_host_check(host *hst, int check_options, double latency)
cr->latency = latency;
cr->start_time = start_time;
cr->finish_time = start_time;
cr->timeout = hst->check_timeout;
cr->early_timeout = FALSE;
cr->exited_ok = TRUE;
cr->return_code = STATE_OK;
cr->output = NULL;

neb_result = broker_host_check(NEBTYPE_HOSTCHECK_INITIATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CHECK_TYPE_ACTIVE, hst->current_state, hst->state_type, start_time, end_time, hst->check_command, hst->latency, 0.0, host_check_timeout, FALSE, 0, processed_command, NULL, NULL, NULL, cr);
neb_result = broker_host_check(NEBTYPE_HOSTCHECK_INITIATE, NEBFLAG_NONE, NEBATTR_NONE, hst, CHECK_TYPE_ACTIVE, hst->current_state, hst->state_type, start_time, end_time, hst->check_command, hst->latency, 0.0, hst->check_timeout, FALSE, 0, processed_command, NULL, NULL, NULL, cr);

/* neb module wants to override the service check - perhaps it will check the service itself */
if (neb_result == NEBERROR_CALLBACKOVERRIDE || neb_result == NEBERROR_CALLBACKCANCEL) {
Expand All @@ -354,7 +355,7 @@ static int run_async_host_check(host *hst, int check_options, double latency)
return neb_result == NEBERROR_CALLBACKOVERRIDE ? OK : ERROR;
}

runchk_result = wproc_run_callback(processed_command, host_check_timeout, handle_worker_host_check, (void *)cr, &mac);
runchk_result = wproc_run_callback(processed_command, hst->check_timeout, handle_worker_host_check, (void *)cr, &mac);
if (runchk_result == ERROR) {
nm_log(NSLOG_RUNTIME_ERROR,
"Unable to send check for host '%s' to worker (ret=%d)\n", hst->name, runchk_result);
Expand Down Expand Up @@ -623,7 +624,7 @@ int handle_async_host_check_result(host *temp_host, check_result *cr)
temp_host->check_command,
temp_host->latency,
temp_host->execution_time,
host_check_timeout,
cr->timeout,
cr->early_timeout,
cr->return_code,
NULL,
Expand Down Expand Up @@ -1178,7 +1179,7 @@ static void check_for_orphaned_hosts_eventhandler(struct nm_event_execution_prop
continue;

/* determine the time at which the check results should have come in (allow 10 minutes slack time) */
expected_time = (time_t)(temp_host->next_check + temp_host->latency + host_check_timeout + check_reaper_interval + 600);
expected_time = (time_t)(temp_host->next_check + temp_host->latency + temp_host->check_timeout + check_reaper_interval + 600);

/* this host was supposed to have executed a while ago, but for some reason the results haven't come back in... */
if (expected_time < current_time.tv_sec) {
Expand Down
9 changes: 5 additions & 4 deletions src/naemon/checks_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,15 @@ static int run_scheduled_service_check(service *svc, int check_options, double l
cr->latency = latency;
cr->start_time = start_time;
cr->finish_time = start_time;
cr->timeout = svc->check_timeout;
cr->early_timeout = FALSE;
cr->exited_ok = TRUE;
cr->return_code = STATE_OK;
cr->output = NULL;
cr->host_name = nm_strdup(svc->host_name);
cr->service_description = nm_strdup(svc->description);

neb_result = broker_service_check(NEBTYPE_SERVICECHECK_INITIATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CHECK_TYPE_ACTIVE, start_time, end_time, svc->check_command, svc->latency, 0.0, service_check_timeout, FALSE, 0, processed_command, cr);
neb_result = broker_service_check(NEBTYPE_SERVICECHECK_INITIATE, NEBFLAG_NONE, NEBATTR_NONE, svc, CHECK_TYPE_ACTIVE, start_time, end_time, svc->check_command, svc->latency, 0.0, svc->check_timeout, FALSE, 0, processed_command, cr);

/* neb module wants to override the service check - perhaps it will check the service itself */
if (neb_result == NEBERROR_CALLBACKOVERRIDE || neb_result == NEBERROR_CALLBACKCANCEL) {
Expand All @@ -421,7 +422,7 @@ static int run_scheduled_service_check(service *svc, int check_options, double l
}

/* paw off the check to a worker to run */
runchk_result = wproc_run_callback(processed_command, service_check_timeout, handle_worker_service_check, (void *)cr, &mac);
runchk_result = wproc_run_callback(processed_command, svc->check_timeout, handle_worker_service_check, (void *)cr, &mac);
if (runchk_result == ERROR) {
nm_log(NSLOG_RUNTIME_ERROR,
"Unable to send check for service '%s' on host '%s' to worker (ret=%d)\n", svc->description, svc->host_name, runchk_result);
Expand Down Expand Up @@ -1125,7 +1126,7 @@ int handle_async_service_check_result(service *temp_service, check_result *queue
temp_service->check_command,
temp_service->latency,
temp_service->execution_time,
service_check_timeout,
queued_check_result->timeout,
queued_check_result->early_timeout,
queued_check_result->return_code,
NULL,
Expand Down Expand Up @@ -1186,7 +1187,7 @@ static void check_for_orphaned_services_eventhandler(struct nm_event_execution_p
continue;

/* determine the time at which the check results should have come in (allow 10 minutes slack time) */
expected_time = (time_t)(temp_service->next_check + temp_service->latency + service_check_timeout + check_reaper_interval + 600);
expected_time = (time_t)(temp_service->next_check + temp_service->latency + temp_service->check_timeout + check_reaper_interval + 600);

/* this service was supposed to have executed a while ago, but for some reason the results haven't come back in... */
if (expected_time < current_time.tv_sec) {
Expand Down
8 changes: 7 additions & 1 deletion src/naemon/objects_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ host *create_host(const char *name)
return new_host;
}

int setup_host_variables(host *new_host, const char *display_name, const char *alias, const char *address, const char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, const char *notification_period, int notifications_enabled, const char *check_command, int checks_enabled, int accept_passive_checks, const char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, const char *vrml_image, const char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value)
int setup_host_variables(host *new_host, const char *display_name, const char *alias, const char *address, const char *check_period, int initial_state, int check_timeout, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, const char *notification_period, int notifications_enabled, const char *check_command, int checks_enabled, int accept_passive_checks, const char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, const char *vrml_image, const char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value)
{
timeperiod *check_tp = NULL, *notify_tp = NULL;

Expand All @@ -104,6 +104,10 @@ int setup_host_variables(host *new_host, const char *display_name, const char *a
nm_log(NSLOG_CONFIG_ERROR, "Error: Invalid check_interval value for host '%s'\n", new_host->name);
return -1;
}
if (check_timeout <= 0) {
nm_log(NSLOG_CONFIG_ERROR, "Error: check_timeout must be a positive integer host '%s'\n", new_host->name);
return -1;
}
if (notification_interval < 0) {
nm_log(NSLOG_CONFIG_ERROR, "Error: Invalid notification_interval value for host '%s'\n", new_host->name);
return -1;
Expand Down Expand Up @@ -157,6 +161,7 @@ int setup_host_variables(host *new_host, const char *display_name, const char *a
/* duplicate non-string vars */
new_host->hourly_value = hourly_value;
new_host->max_attempts = max_attempts;
new_host->check_timeout = check_timeout;
new_host->check_interval = check_interval;
new_host->retry_interval = retry_interval;
new_host->notification_interval = notification_interval;
Expand Down Expand Up @@ -545,6 +550,7 @@ void fcache_host(FILE *fp, const host *temp_host)
fprintf(fp, "u\n");
else
fprintf(fp, "o\n");
fprintf(fp,"\tcheck_timeout\t%d\n", temp_host->check_timeout);
fprintf(fp, "\thourly_value\t%u\n", temp_host->hourly_value);
fprintf(fp, "\tcheck_interval\t%f\n", temp_host->check_interval);
fprintf(fp, "\tretry_interval\t%f\n", temp_host->retry_interval);
Expand Down
3 changes: 2 additions & 1 deletion src/naemon/objects_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct host {
struct servicesmember *services;
char *check_command;
int initial_state;
int check_timeout;
double check_interval;
double retry_interval;
int max_attempts;
Expand Down Expand Up @@ -153,7 +154,7 @@ void destroy_objects_host(void);

host *create_host(const char *name);
/** This is an evil legacy function which you should never, ever use */
int setup_host_variables(host *new_host, const char *display_name, const char *alias, const char *address, const char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, const char *notification_period, int notifications_enabled, const char *check_command, int checks_enabled, int accept_passive_checks, const char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, const char *vrml_image, const char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int retain_status_information, int retain_nonstatus_information, int obsess_over_host, unsigned int hourly_value);
int setup_host_variables(host *new_host, const char *display_name, const char *alias, const char *address, const char *check_period, int initial_state, int check_timeout, double check_interval, double retry_interval, int max_attempts, int notification_options, double notification_interval, double first_notification_delay, const char *notification_period, int notifications_enabled, const char *check_command, int checks_enabled, int accept_passive_checks, const char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, const char *vrml_image, const char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int retain_status_information, int retain_nonstatus_information, int obsess_over_host, unsigned int hourly_value);
int register_host(host *new_host);
void destroy_host(host *this_host);

Expand Down
8 changes: 7 additions & 1 deletion src/naemon/objects_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ service *create_service(host *hst, const char *description)
return new_service;
}

int setup_service_variables(service *new_service, const char *display_name, const char *check_command, const char *check_period, int initial_state, int max_attempts, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, const char *event_handler, int event_handler_enabled, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value)
int setup_service_variables(service *new_service, const char *display_name, const char *check_command, const char *check_period, int initial_state, int check_timeout, int max_attempts, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, const char *event_handler, int event_handler_enabled, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value)
{
timeperiod *cp = NULL, *np = NULL;
command *cmd;
Expand Down Expand Up @@ -123,6 +123,10 @@ int setup_service_variables(service *new_service, const char *display_name, cons
nm_log(NSLOG_CONFIG_ERROR, "Error: check_interval must be a non-negative integer for service '%s' on host '%s'\n", new_service->description, new_service->host_name);
return -1;
}
if (check_timeout <= 0) {
nm_log(NSLOG_CONFIG_ERROR, "Error: check_timeout must be a positive integer for service '%s' on host '%s'\n", new_service->description, new_service->host_name);
return -1;
}
if (retry_interval <= 0) {
nm_log(NSLOG_CONFIG_ERROR, "Error: retry_interval must be a positive integer for service '%s' on host '%s'\n", new_service->description, new_service->host_name);
return -1;
Expand Down Expand Up @@ -171,6 +175,7 @@ int setup_service_variables(service *new_service, const char *display_name, cons
}

new_service->hourly_value = hourly_value;
new_service->check_timeout = check_timeout;
new_service->check_interval = check_interval;
new_service->retry_interval = retry_interval;
new_service->max_attempts = max_attempts;
Expand Down Expand Up @@ -484,6 +489,7 @@ void fcache_service(FILE *fp, const service *temp_service)
fprintf(fp, "c\n");
else
fprintf(fp, "o\n");
fprintf(fp,"\tcheck_timeout\t%d\n", temp_service->check_timeout);
fprintf(fp, "\thourly_value\t%u\n", temp_service->hourly_value);
fprintf(fp, "\tcheck_interval\t%f\n", temp_service->check_interval);
fprintf(fp, "\tretry_interval\t%f\n", temp_service->retry_interval);
Expand Down
3 changes: 2 additions & 1 deletion src/naemon/objects_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct service {
char *check_command;
char *event_handler;
int initial_state;
int check_timeout;
double check_interval;
double retry_interval;
int max_attempts;
Expand Down Expand Up @@ -152,7 +153,7 @@ int init_objects_service(int elems);
void destroy_objects_service(int truncate_lists);

service *create_service(host *hst, const char *description);
int setup_service_variables(service *svc, const char *display_name, const char *check_period, const char *check_command, int initial_state, int max_attempts, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, const char *event_handler, int event_handler_enabled, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value);
int setup_service_variables(service *svc, const char *display_name, const char *check_period, const char *check_command, int initial_state, int check_timeout, int max_attempts, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notification_options, int notifications_enabled, int is_volatile, const char *event_handler, int event_handler_enabled, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_options, int stalking_options, int process_perfdata, int check_freshness, int freshness_threshold, const char *notes, const char *notes_url, const char *action_url, const char *icon_image, const char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess, unsigned int hourly_value);
int register_service(service *new_service);
void destroy_service(service *svc, int truncate_lists);

Expand Down
Loading