where did my perfdata file go?
frank
ratty at they.org
Tue Apr 5 04:31:53 CEST 2005
On Fri, 1 Apr 2005, Andreas Ericsson wrote:
> Date: Fri, 01 Apr 2005 10:23:55 +0200
> From: Andreas Ericsson <ae at op5.se>
> To: nagios-users at lists.sourceforge.net
> Subject: Re: [Nagios-users] where did my perfdata file go?
>
> frank wrote:
>> Running 2.0b2 and loving it. But when I looked at my service_perfdata_file
>> today it was less than complete.
>>
>> Relevent configs (mostly defaults):
>>
>> service_perfdata_command=process-service-perfdata
>> service_perfdata_file=/tmp/service-perfdata
>> service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
>> service_perfdata_file_mode=a
>> service_perfdata_file_processing_interval=0
>> service_perfdata_file_processing_command=process-service-perfdata-file
>>
>> Instead of actually using a perf proc command from within Nagios, I simply
>> run a 'tail -f' on the output file and parse it myself. I assume that
>> "file_processing_interval=0" means Nagios will just leave my file alone...
>>
>> With the file_mode set to "a" I expected that by now I'd find a huge file
>> filled with our perf data beginning on the day I started Nagios, but
>> instead the file starts this morning around 11am. I know for a fact that
>> data has been flowing into the file all along (a few weeks) because my RRDs
>> have been getting properly populated. I was hoping to be able to recreate
>> my RRDs with new RRA sets in them using the perf data but since it's gone I
>> can't.
>>
>> Any clue what happened? Did Nagios somehow rotate/truncate my file without
>> my knowledge or permission? Is there a facility in Nagios to rotate this
>> along with the main Nagios log file?
>>
>
> Perfparse truncates it when it parses it. This is necessary in order for it
> to be able to keep up with the dataflow.
>
> If you want to be able to recreate your data you should set your processing
> commands to log to two different files.
I've been searching thru the source code for a few hours now and I can't
find any place that is intentionally truncating the perf logs.
As a test, I added this snippet to xpddefault.c:
<diff>
--- src/nagios-2.0b2/xdata/xpddefault.c 2004-12-05 19:40:03.000000000 -0800
+++ xpddefault.c 2005-04-04 18:49:58.050577544 -0700
@@ -558,6 +558,11 @@ int xpddefault_open_service_perfdata_fil
char buffer[MAX_INPUT_BUFFER];
if(xpddefault_service_perfdata_file!=NULL){
+ /*XXX*/
+ snprintf(buffer,sizeof(buffer),"Warning: Service perf file mode is: %s\n",(xpddefault_service_perfdata_file_append==TRUE)?"a":"w");
+ buffer[sizeof(buffer)-1]='\x0';
+ write_to_logs_and_console(buffer,NSLOG_RUNTIME_WARNING,TRUE);
+ /*XXX*/
xpddefault_service_perfdata_fp=fopen(xpddefault_service_perfdata_file,(xpddefault_service_perfdata_file_append==TRUE)?"a":"w");
</diff>
My nagios.log reports back:
Warning: Service perf file mode is: w
If I delete/comment-out the config lines in nagios.conf I still get "w".
BUT
If I change "service_perfdata_file_mode=a" to
"service_perfdata_file_mode=w" then my code reports back with an "a"!!
I think the problem is in the initialization code.
xdata/xpddefault.c:308-311:
if(!strstr(value,"w"))
xpddefault_service_perfdata_file_append=FALSE;
else
xpddefault_service_perfdata_file_append=TRUE;
I think the logic is backwards here. "w" is supposed to mean
"append=FALSE". But here if "w" is inside "value", strstr() returns
positive, but the "!" negates it and causes "append=TRUE". That is the
wrong outcome.
Now I'll go check CVS to see if this has already been fixed.
.enjoy
-Frank
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
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
More information about the Users
mailing list