<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=798305014-13042007>I received the following reponse from Thomas
Guyot-Sionnest on the nagios-devel mailing list which explains the change a
little better and suggests a change to the way the perfdata processing script
runs. I implemented the changes he suggested to my insert.pl script and it
cleans the file and runs quickly now.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial><FONT size=2><FONT color=#0000ff><FONT
face=Arial><FONT size=2><FONT color=#0000ff><FONT face=Arial color=#0000ff
size=2><SPAN
class=798305014-13042007></SPAN></FONT></FONT></FONT></FONT></FONT></FONT></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=798305014-13042007>Mark</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial><FONT size=2><FONT color=#0000ff><FONT
face=Arial><FONT size=2><FONT color=#0000ff><FONT face=Arial><FONT size=2><FONT
color=#0000ff><FONT face=Arial color=#0000ff size=2><SPAN
class=798305014-13042007></SPAN></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial><FONT size=2><FONT color=#0000ff><FONT
face=Arial><FONT size=2><FONT color=#0000ff><FONT face=Arial><FONT size=2><FONT
color=#0000ff><FONT face=Arial color=#0000ff size=2><SPAN
class=798305014-13042007></SPAN></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> </DIV><FONT><SPAN
class=798305014-13042007>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2>There was a
bug in 2.8 and earlier were perfdata_file_mode=a were</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>writing and
perfdata_file_mode=w were appending. change it to "w" and</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>you'll get the old
behavior.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>My understanding is that
you never remove the file in your perfdata</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>processing script so that
in 2.8, when told to write, the file was</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>truncated when Nagios was
reopening it. The correct fix is to remove the</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>file before returning
back to nagios.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>For better performance
I'd suggest something like this:</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>open(PERFDATA,
"<$perfdata_file") or die;</FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>if ((my $test=fork) == 0)
{</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN># Do something useful
here</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>close
(PERFDATA);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>exit (0);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>} elsif ($test > 0)
{</FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN># Fork forked, remove file and
return</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>unlink
($perfdata_file);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>close
(PERFDATA);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>exit (0);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>} else {</FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN># Something went wrong! Don't remove
the file, Nagios</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN># will keep appending to
it.</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>close
(PERFDATA);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=798305014-13042007> </SPAN>exit (1);</FONT></FONT></FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>}</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>This will open the file,
remove it and return immediately to nagios</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>while the forked process
will continue processing the file. Since the</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>file is already opened
when it is unlinked the new file won't interfere</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2>with the one opened by
the forked process.</FONT></DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2>Thomas</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></SPAN></FONT><FONT
face=Arial color=#0000ff size=2>
<DIV><BR></DIV></FONT>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Einar Indridason
[mailto:einar.indrida@gmail.com] <BR><B>Sent:</B> Thursday, April 12, 2007
9:31 AM<BR><B>To:</B> Frost, Mark {PBG}<BR><B>Cc:</B>
nagios-users@lists.sourceforge.net<BR><B>Subject:</B> Re: [Nagios-users]
Having issue with process-service-perfdata running too
long<BR></FONT><BR></DIV>
<DIV></DIV><BR>
<DIV><SPAN class=gmail_quote>On 4/11/07, <B class=gmail_sendername>Frost, Mark
{PBG}</B> <<A
href="mailto:mark.frost1@pepsi.com">mark.frost1@pepsi.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><BR>Hello. I'm
running Nagios 2.9 with Nagiosgraph 0.8.2. This
combination<BR>has worked well for us for a while now.<BR><BR>My perdata
file has grown rather large:<BR><BR>$ wc -l perfdata.log<BR>817880
perfdata.log <BR></BLOCKQUOTE>
<DIV> </DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">I
like keeping the historical data, but I guess that would mean my <BR>perdata
file would grow infinitely large. I don't see any option
in<BR>nagios.cfg that controls how much data stays in the perfdata.log
file<BR>(i.e. a retention interval for data contained
therein). Maybe I missed <BR>it somewhere.<BR><BR>So it's
starting to seem like I should trim this file somehow myself,<BR>but I'm not
sure how to go about that.<BR><BR>What's odd is that Nagios did this
processing for me fine up until <BR>yesterday. I have not added
any new hosts since yesterday. I can't<BR>imagine that this ran
anywhere near 5 seconds prior to yesterday but it<BR>still
worked. My config file is the same. However, I did
upgrade to <BR>Nagios 2.9 yesterday.</BLOCKQUOTE>
<DIV><BR><BR>I have the same, or similar report. I was (and currently
am) running Nagios 2.8, and the services-perf log file is created, added to,
and eventually sent to a "process the perf data" (nagiosgraph 0.7 with some
local add-ons). <BR>Then, I updated nagios to 2.9, and suddenly the
perf-log file just got bigger, and bigger, and bigger, and bigger... and no
services-performance processing was done, until the available diskspace (20MB
all in all - stored on a ramdisk) was full, Nagios 2.9 then kept on running,
but didn't have any meaningful informations available through the cgi's... (as
the status.dat file is also stored on that
ramdisk).<BR><BR>Cheers,<BR>--<BR>EinarI<BR><BR>ps: my current perf settings
(both for 2.8, which worked, and for 2.9, which didn't)
are:<BR><BR>perfdata_timeout=60<BR>process_performance_data=1<BR>host_perfdata_file=/usr/local/nagios/var/status.dir/host_perfdata.log<BR>service_perfdata_file=/usr/local/nagios/var/status.dir/service_perfdata.log
<BR>host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$<BR>service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
<BR>host_perfdata_file_mode=a<BR>service_perfdata_file_mode=a<BR>host_perfdata_file_processing_interval=0<BR>service_perfdata_file_processing_interval=300<BR>service_perfdata_file_processing_command=process-service-perfdata
<BR><BR></DIV></DIV></BLOCKQUOTE></BODY></HTML>