Problem with perfdata file in Nagios 2.9?
Frost, Mark {PBG}
mark.frost1 at pepsi.com
Fri Apr 13 16:48:01 CEST 2007
Thanks very much, Thomas.
I made modified the nagiosgraph insert.pl script per your
recommendations. I guess the only danger there is if the script has
some problem processing the perfdata and exits -- then the perfdata
would be lost. Small danger I guess if the script is stable.
The script runs quickly now and the perfdata file is trim as expected.
The more I learn about Nagios, the more I know I don't know. :-)
Thanks
Mark
-----Original Message-----
From: nagios-devel-bounces at lists.sourceforge.net
[mailto:nagios-devel-bounces at lists.sourceforge.net] On Behalf Of Thomas
Guyot-Sionnest
Sent: Thursday, April 12, 2007 11:11 PM
To: Nagios Developers List
Subject: Re: [Nagios-devel] Problem with perfdata file in Nagios 2.9?
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, "<$perfdata_file") or die;
if ((my $test=fork) == 0) {
# Do something useful here
close (PERFDATA);
exit (0);
} elsif ($test > 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
------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
More information about the Developers
mailing list