Re: [Nagios-devel] Nagios retention problem.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Nagios retention problem.

Post by Guest »

=20
>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.=20

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=3D0L;
unsigned long process_host_attribute_mask=3D0L;
unsigned long process_service_attribute_mask=3D0L;
+ char errormsg[40];
+ int errorcount=3D0;
=20
=20
=20
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=3D=3DNULL)
return ERROR;
+
if((fd=3Dmkstemp(temp_file))=3D=3D-1)
return ERROR;
=20
@@ -558,21 +561,30 @@ int xrddefault_save_state_information(vo
fprintf(fp,"}\n");
}
=20
- 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=20
+ */
+ if(fclose(fp)) {
+ sprintf(errormsg, "Error when closing retention
tempfile: %s", strerror(errno));
+ logit(NSLOG_RUNTIME_ERROR,TRUE,errormsg,errno);
=20
- /* 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);=20
result=3DERROR;
+ } else {
+
+ /* move the temp file to the retention file (overwrite
the old retention file) */
+ if(my_rename(temp_file,xrddefault_retention_file))
+ result=3DERROR;
+ }
=20
/* free memory */
my_free(temp_file);
-
return result;
}
=20
=20
-
-
/******************************************************************/
/***************** DEFAULT STATE INPUT FUNCTION *******************/
/******************************************************************/





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked