Nagios retention problem.
Markus.Almroth at teliasonera.com
Markus.Almroth at teliasonera.com
Thu Nov 20 12:52:12 CET 2008
>Could you please resend it in unified diff format (diff -up)?
>I'll have to manually apply this patch on top of the 3.0.5p1 codebase,
and my poor brain can only read >unified diff format.
>Thanks.
Ok then :-)
I have to cut'n paste it into the mail, 'cause we have some firewalling
making file transfers really cumbersome.
I *think* I got the logit() call right. :-)
There are some more fclose() calls one should probably check out by the
way.
/Markus
--------------------------------------------------- Patch...
--- xrddefault.c 2008-11-20 12:49:18.000000000 +0100
+++ ../xrddefault.c 2008-11-20 12:46:34.000000000 +0100
@@ -254,6 +254,8 @@ int xrddefault_save_state_information(vo
unsigned long contact_service_attribute_mask=0L;
unsigned long process_host_attribute_mask=0L;
unsigned long process_service_attribute_mask=0L;
+ char errormsg[40];
+ int errorcount=0;
log_debug_info(DEBUGL_FUNCTIONS,0,"xrddefault_save_state_information()\n
");
@@ -272,6 +274,7 @@ int xrddefault_save_state_information(vo
asprintf(&temp_file,"%sXXXXXX",xrddefault_temp_file);
if(temp_file==NULL)
return ERROR;
+
if((fd=mkstemp(temp_file))==-1)
return ERROR;
@@ -558,21 +561,30 @@ int xrddefault_save_state_information(vo
fprintf(fp,"}\n");
}
- fclose(fp);
+ /* If there is a problem when saving/closing the tempfile
+ don't write to the retentionfile and write an error to the
+ log
+ */
+ if(fclose(fp)) {
+ sprintf(errormsg, "Error when closing retention
tempfile: %s", strerror(errno));
+ logit(NSLOG_RUNTIME_ERROR,TRUE,errormsg,errno);
- /* move the temp file to the retention file (overwrite the old
retention file) */
- if(my_rename(temp_file,xrddefault_retention_file))
+ /* Remove the tempfile - I'm not sure this actually is a
good idea */
+ unlink(temp_file);
result=ERROR;
+ } else {
+
+ /* move the temp file to the retention file (overwrite
the old retention file) */
+ if(my_rename(temp_file,xrddefault_retention_file))
+ result=ERROR;
+ }
/* free memory */
my_free(temp_file);
-
return result;
}
-
-
/******************************************************************/
/***************** DEFAULT STATE INPUT FUNCTION *******************/
/******************************************************************/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
More information about the Developers
mailing list