Re: [Nagios-devel] Patch: Improved Error Reporting when rotation

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] Patch: Improved Error Reporting when rotation

Post by Guest »

Lars Michelsen wrote:
> Hi Ethan, Hi List,
> I just had some problems with the log rotation of the nagios logfile
> on my productive nagios system. After several trys to get the source
> of the problem I recognized some permission problems. That was a hard
> way to get to that point and fix this.
> Finally this was only possible due to some modifications to the Nagios
> code. True, I could turn on the debug mode, but that's no option on
> the productive system.
>
> Here is a small patch for a little better error reporting to the log
> file when renaming files. This patch should help others to recognize
> the source of their problem much faster.
>
> Peronaly I would add much more error messages for the user to that
> functions but that would also blow up the code.
>
> This patch is for Nagios 2.10, but it should also be applicable to Nagios 3.0.
>
> --- base/utils.c.orig 2007-10-24 17:37:06.000000000 +0200
> +++ base/utils.c 2007-10-24 18:42:52.000000000 +0200
> @@ -4329,6 +4329,7 @@
> int source_fd;
> int dest_fd;
> int bytes_read;
> + char temp_buffer[MAX_INPUT_BUFFER];
>
>
> /* make sure we have something */
> @@ -4338,6 +4339,13 @@
> /* first see if we can rename file with standard function */
> rename_result=rename(source,dest);
>
> + /* the user should know why the logrotation fails */
> + if(rename_result==-1 && errno!=EXDEV) {
> + snprintf(temp_buffer,sizeof(temp_buffer),"ERROR in
> my_rename: unhandled error '%s' while renaming from '%s' to
> '%s'",strerror(errno),source,dest);
> + temp_buffer[sizeof(temp_buffer)-1]='\x0';
> + write_to_all_logs(temp_buffer,NSLOG_PROCESS_INFO);
> + }
> +
> /* an error occurred because the source and dest files are on
> different filesystems */
> if(rename_result==-1 && errno==EXDEV){
>
>
> --
> Lars
>

Thanks! Patch will be in CVS shortly.


Ethan Galstad
Nagios Developer
___
Email: [email protected]
Web: www.nagios.org





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