From 70311736629620de918259bbc7823b7319845b96 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Thu, 7 Mar 2024 13:19:57 +0100 Subject: [PATCH] update last_update for some more cornercases there were some corner cases where the last_update timestamp has not been updated. Update the timestamp whenever the last_check changes. --- src/naemon/checks_host.c | 6 ++++++ src/naemon/checks_service.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/naemon/checks_host.c b/src/naemon/checks_host.c index 7f8abcf5..ea78d9b4 100644 --- a/src/naemon/checks_host.c +++ b/src/naemon/checks_host.c @@ -373,6 +373,7 @@ int update_host_state_post_check(struct host *hst, struct check_result *cr) { int result; char *temp_ptr = NULL; + time_t now = time(NULL); if (!hst || !cr) return ERROR; @@ -413,6 +414,7 @@ int update_host_state_post_check(struct host *hst, struct check_result *cr) /* get the last check time */ hst->last_check = cr->start_time.tv_sec; + hst->last_update = now; /* save the old host state */ hst->last_state = hst->current_state; @@ -629,6 +631,7 @@ static void handle_worker_host_check(wproc_result *wpres, void *arg, int flags) { check_result *cr = (check_result *)arg; struct host *hst; + time_t now = time(NULL); /* decrement the number of host checks still out there... */ if (currently_running_host_checks > 0) @@ -638,6 +641,7 @@ static void handle_worker_host_check(wproc_result *wpres, void *arg, int flags) hst = find_host(cr->host_name); if (hst) { hst->is_executing = FALSE; + hst->last_update = now; memcpy(&cr->rusage, &wpres->rusage, sizeof(wpres->rusage)); cr->start_time.tv_sec = wpres->start.tv_sec; cr->start_time.tv_usec = wpres->start.tv_usec; @@ -1180,6 +1184,8 @@ static void check_for_orphaned_hosts_eventhandler(struct nm_event_execution_prop /* disable the executing flag */ temp_host->is_executing = FALSE; + temp_host->last_update = current_time; + /* schedule an immediate check of the host */ schedule_next_host_check(temp_host, 0, CHECK_OPTION_ORPHAN_CHECK); } diff --git a/src/naemon/checks_service.c b/src/naemon/checks_service.c index 6ac0febc..0222a373 100644 --- a/src/naemon/checks_service.c +++ b/src/naemon/checks_service.c @@ -454,6 +454,8 @@ int handle_async_service_check_result(service *temp_service, check_result *queue } } + temp_service->last_update = current_time; + /* clear the freshening flag (it would have been set if this service was determined to be stale) */ if (queued_check_result->check_options & CHECK_OPTION_FRESHNESS_CHECK) temp_service->is_being_freshened = FALSE; @@ -1083,7 +1085,6 @@ int handle_async_service_check_result(service *temp_service, check_result *queue nm_free(old_plugin_output); nm_free(old_long_plugin_output); - temp_service->last_update = current_time; return OK; } @@ -1135,6 +1136,7 @@ static void check_for_orphaned_services_eventhandler(struct nm_event_execution_p /* disable the executing flag */ temp_service->is_executing = FALSE; + temp_service->last_update = current_time; /* schedule an immediate check of the service */ schedule_next_service_check(temp_service, 0, CHECK_OPTION_ORPHAN_CHECK);