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

git at icinga.org git at icinga.org
Tue Aug 7 15:34:45 CEST 2012

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

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 d174afc..8bb6571 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -2739,6 +2739,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