Re: [Nagios-devel] 2 calls to unlink in checkresults

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] 2 calls to unlink in checkresults

Post by Guest »

This is a multi-part message in MIME format.
--------------050009040203040605060301
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

On 5/19/09 5:01 AM, Andreas Ericsson wrote:
>> Since process_check_result_queue() has already loaded all checkresult
>> files in a list in memory (by calling add_check_result_to_list() in
>> process_check_result_file()), reap_check_results() shouldn't call
>> delete_check_result_file() at all.
>>
>> Does it make any sense to you?
>>
>
> Yes, but it seems unnecessarily complex. I think I'll revamp it so
> it's read once and deleted immediately after.
>

Here is a patch against Nagios 3.0.6 fixing the problem.
delete_check_result_file() is now called from
process_check_result_file() only.

Feel free to comment and/or improve it.

--
Mathieu

--------------050009040203040605060301
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="fix_multiple_calls_to_delete_check_result_file.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename*0="fix_multiple_calls_to_delete_check_result_file.patch"

diff -Naur nagios-3.0.6.orig/base/checks.c nagios-3.0.6/base/checks.c
--- nagios-3.0.6.orig/base/checks.c 2009-05-19 12:48:13.000000000 -0400
+++ nagios-3.0.6/base/checks.c 2009-05-19 12:49:59.000000000 -0400
@@ -163,9 +163,6 @@

logit(NSLOG_RUNTIME_WARNING,TRUE,"Warning: Check result queue contained results for service '%s' on host '%s', but the service could not be found! Perhaps you forgot to define the service in your config files?\n",queued_check_result->service_description,queued_check_result->host_name);

- /* delete the file that contains the check results, as well as the ok-to-go file */
- delete_check_result_file(queued_check_result->output_file);
-
/* free memory */
free_check_result(queued_check_result);
my_free(queued_check_result);
@@ -188,9 +185,6 @@
/* make sure the host exists */
logit(NSLOG_RUNTIME_WARNING,TRUE,"Warning: Check result queue contained results for host '%s', but the host could not be found! Perhaps you forgot to define the host in your config files?\n",queued_check_result->host_name);

- /* delete the file that contains the check results, as well as the ok-to-go file */
- delete_check_result_file(queued_check_result->output_file);
-
/* free memory */
free_check_result(queued_check_result);
my_free(queued_check_result);
@@ -206,12 +200,6 @@
handle_async_host_check_result_3x(temp_host,queued_check_result);
}

- /* delete the file that contains the check results, as well as the ok-to-go file */
- /* files can contain multiple check results - in this case, the file will be removed when the first check result is processed */
- delete_check_result_file(queued_check_result->output_file);
-
- log_debug_info(DEBUGL_CHECKS|DEBUGL_IPC,1,"Deleted check result file '%s'\n",queued_check_result->output_file);
-
/* free allocated memory */
free_check_result(queued_check_result);
my_free(queued_check_result);
diff -Naur nagios-3.0.6.orig/base/utils.c nagios-3.0.6/base/utils.c
--- nagios-3.0.6.orig/base/utils.c 2009-05-19 13:05:14.000000000 -0400
+++ nagios-3.0.6/base/utils.c 2009-05-19 13:11:18.000000000 -0400
@@ -2485,6 +2485,8 @@
/* other (current) files are deleted later (when results are processed) */
delete_check_result_file(fname);

+ log_debug_info(DEBUGL_CHECKS|DEBUGL_IPC,1,"Deleted check result file '%s'\n",fname);
+
return OK;
}


--------------050009040203040605060301--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked