[Pkg-nagios-devel] Bug#339366: After update, Nagios runs, but no status
sean finney
seanius at seanius.net
Fri Dec 2 18:12:54 CET 2005
hi ethan,
On Sat, Nov 26, 2005 at 12:58:15AM -0600, Ethan Galstad wrote:
> Thanks - I've just added some checks to the code to help cope with
> this problem.
cool--and i've just backported it to the 1.3 branch. if you're
interested, it's attached.
sean
-------------- next part --------------
#! /bin/sh /usr/share/dpatch/dpatch-run
## 14_xdata_check-fulldisks.dpatch by <seanius at debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: perform error checks on writes to the status log
## DP: backported by sean finney from the 2.0 cvs tree.
@DPATCH@
diff -urNad sid~/xdata/xsddefault.c sid/xdata/xsddefault.c
--- sid~/xdata/xsddefault.c 2002-02-26 05:04:11.000000000 +0100
+++ sid/xdata/xsddefault.c 2005-12-02 08:44:38.000000000 +0100
@@ -208,16 +208,26 @@
/* start aggregated dump */
int xsddefault_begin_aggregated_dump(void){
char buffer[MAX_INPUT_BUFFER];
+ char temp_buffer[MAX_INPUT_BUFFER];
/* open a safe temp file for output */
snprintf(xsddefault_aggregate_temp_file,sizeof(xsddefault_aggregate_temp_file)-1,"%sXXXXXX",xsddefault_temp_file);
xsddefault_aggregate_temp_file[sizeof(xsddefault_aggregate_temp_file)-1]='\x0';
- if((xsddefault_aggregate_fd=mkstemp(xsddefault_aggregate_temp_file))==-1)
+ if((xsddefault_aggregate_fd=mkstemp(xsddefault_aggregate_temp_file))==-1){
+ /* log an error */
+ snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to create temp file for writing status data!\n");
+ temp_buffer[sizeof(temp_buffer)-1]='\x0';
+ write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
return ERROR;
+ }
xsddefault_aggregate_fp=fdopen(xsddefault_aggregate_fd,"w");
if(xsddefault_aggregate_fp==NULL){
close(xsddefault_aggregate_fd);
unlink(xsddefault_aggregate_temp_file);
+ /* log an error */
+ snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to open temp file '%s' for writing status data!\n",xsddefault_aggregate_temp_file);
+ temp_buffer[sizeof(temp_buffer)-1]='\x0';
+ write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
return ERROR;
}
@@ -232,6 +242,7 @@
/* finish aggregated dump */
int xsddefault_end_aggregated_dump(void){
+ char temp_buffer[MAX_INPUT_BUFFER];
/* reset file permissions */
fchmod(xsddefault_aggregate_fd,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
@@ -241,8 +252,13 @@
close(xsddefault_aggregate_fd);
/* move the temp file to the status log (overwrite the old status log) */
- if(my_rename(xsddefault_aggregate_temp_file,xsddefault_status_log))
+ if(my_rename(xsddefault_aggregate_temp_file,xsddefault_status_log)){
+ /* log an error */
+ snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to update status data file '%s'!\n",xsddefault_status_log);
+ temp_buffer[sizeof(temp_buffer)-1]='\x0';
+ write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
return ERROR;
+ }
return OK;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20051202/5b83e865/attachment.sig>
More information about the Developers
mailing list