Re: [Nagios-devel] Problem with perfdata file in Nagios 2.9?

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] Problem with perfdata file in Nagios 2.9?

Post by Guest »

On 12/04/07 11:58 AM, Frost, Mark {PBG} wrote:
> Hello. I recently posted to the Nagios-users list about an issue that
> seems to have cropped up since I moved to 2.9.
>
> I use Nagiosgraph 0.8.2. My nagios.cfg file has the following
> configuration options:
>
> process_performance_data=1
> service_perfdata_file_mode=a
> service_perfdata_file_processing_interval=30

There was a bug in 2.8 and earlier were perfdata_file_mode=a were
writing and perfdata_file_mode=w were appending. change it to "w" and
you'll get the old behavior.

My understanding is that you never remove the file in your perfdata
processing script so that in 2.8, when told to write, the file was
truncated when Nagios was reopening it. The correct fix is to remove the
file before returning back to nagios.

For better performance I'd suggest something like this:

open(PERFDATA, " 0) {
# Fork forked, remove file and return
unlink ($perfdata_file);
close (PERFDATA);
exit (0);
} else {
# Something went wrong! Don't remove the file, Nagios
# will keep appending to it.
close (PERFDATA);
exit (1);
}

This will open the file, remove it and return immediately to nagios
while the forked process will continue processing the file. Since the
file is already opened when it is unlinked the new file won't interfere
with the one opened by the forked process.

Thomas





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