[icinga-checkins] icinga.org: icinga-core/mfriedrich/workers: core: fix deleting too old check result files #2951

git at icinga.org git at icinga.org
Sun Aug 5 23:32:12 CEST 2012

Module: icinga-core
Branch: mfriedrich/workers
Commit: 13b11a984d715516414dde3bb706b8e4a6535972
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=13b11a984d715516414dde3bb706b8e4a6535972

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Sun Aug  5 13:24:55 2012 +0200

core: fix deleting too old check result files #2951

this is a rather common issue - the checkresult dir does not get cleaned
after the core reaps the files, and leaves files there, slowing down the
overall processing.

as the original diff describes, the initial problem are the "write the
checkresult to tmp dir, then move it to checkresult queue, and put a .ok
file there as well, telling the core checkresult reaper that files are
totally fine to be read". on frequent reloads, this will cause a lot of
"not yet finished" checks to stay within the queue, but not having the
.ok file there.

the core algorithm on checking if a file is ok, requires to loop all
files and stat() if the .ok file is there - which is normally a lot of
misses because those old checkresult files won't even be processed
anymore. and who got a manual cronjob cleaning that, when the core
should do?

refs #2951


 base/utils.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/base/utils.c b/base/utils.c
index 8c57e87..136532d 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -2543,6 +2543,15 @@ int process_check_result_queue(char *dirname) {
 			/* at this point we have a regular file... */
+			/*
+			 * if the file is too old, we delete it
+			 * otherwise we will leave old files there
+			 */
+			if (stat_buf.st_mtime + max_check_result_file_age < time(NULL)) {
+				delete_check_result_file(dirfile->d_name);
+				continue;
+			}
 			/* can we find the associated ok-to-go file ? */
 			dummy = asprintf(&temp_buffer, "%s.ok", file);
 			result = stat(temp_buffer, &ok_stat_buf);

More information about the icinga-checkins mailing list