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.
 
Mark
 
 

                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


________________________________

        From: Einar Indridason [mailto:[EMAIL PROTECTED] 
        Sent: Thursday, April 12, 2007 9:31 AM
        To: Frost, Mark {PBG}
        Cc: [EMAIL PROTECTED]
        Subject: Re: [Nagios-users] Having issue with
process-service-perfdata running too long
        
        

        On 4/11/07, Frost, Mark {PBG} <[EMAIL PROTECTED]> wrote: 


                Hello.  I'm running Nagios 2.9 with Nagiosgraph 0.8.2.
This combination
                has worked well for us for a while now.
                
                My perdata file has grown rather large:
                
                $ wc -l perfdata.log
                817880 perfdata.log 
                

         

                I like keeping the historical data, but I guess that
would mean my 
                perdata file would grow infinitely large.  I don't see
any option in
                nagios.cfg that controls how much data stays in the
perfdata.log file
                (i.e. a retention interval for data contained therein).
Maybe I missed 
                it somewhere.
                
                So it's starting to seem like I should trim this file
somehow myself,
                but I'm not sure how to go about that.
                
                What's odd is that Nagios did this processing for me
fine up until 
                yesterday.  I have not added any new hosts since
yesterday.  I can't
                imagine that this ran anywhere near 5 seconds prior to
yesterday but it
                still worked.  My config file is the same.  However, I
did upgrade to 
                Nagios 2.9 yesterday.



        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).  
        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).
        
        Cheers,
        --
        EinarI
        
        ps: my current perf settings (both for 2.8, which worked, and
for 2.9, which didn't) are:
        
        perfdata_timeout=60
        process_performance_data=1
        
host_perfdata_file=/usr/local/nagios/var/status.dir/host_perfdata.log
        
service_perfdata_file=/usr/local/nagios/var/status.dir/service_perfdata.
log 
        
host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEX
ECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
        
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICED
ESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$ 
        host_perfdata_file_mode=a
        service_perfdata_file_mode=a
        host_perfdata_file_processing_interval=0
        service_perfdata_file_processing_interval=300
        
service_perfdata_file_processing_command=process-service-perfdata 
        
        

-------------------------------------------------------------------------
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
_______________________________________________
Nagios-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to