Title: [opsview-base] [220] Workaround for log file rotation being invoked twice
- Revision
- 220
- Author
- tvoon
- Date
- 2013-02-26 17:30:27 +0000 (Tue, 26 Feb 2013)
Log Message
Workaround for log file rotation being invoked twice
Modified Paths
Added Paths
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2013-02-26 13:30:30 UTC (rev 219)
+++ trunk/Makefile 2013-02-26 17:30:27 UTC (rev 220)
@@ -599,6 +599,8 @@
# Commit 2601 can be ignored for the moment
# NOTE!!!!! When upgrading past 2601 (includes an API change) - need to check downtime.h is syncd with NDOutils, otherwise will get coredump in future
# End bugfixes (till 2013-02-22)
+ cd ${NAGIOS} && patch -p1 < ../patches/nagios_overcome_log_rotation_overwrites.patch
+ cd ${NAGIOS} && patch -p1 < ../patches/nagios_reentrant_localtime.patch
if [ $(KERNEL_NAME) = Linux ] ; then \
cd ${NAGIOS} && CFLAGS="${CFLAGS}" ./configure --with-nagios-user=$(NAGIOS_USER) --with-nagios-group=$(NAGIOS_GROUP) --with-command-group=$(NAGIOS_GROUP) --with-cgiurl=/cgi-bin --with-htmurl=/ --enable-libtap ; \
elif [ $(KERNEL_NAME) = Darwin ] ; then \
Added: trunk/patches/nagios_overcome_log_rotation_overwrites.patch
===================================================================
--- trunk/patches/nagios_overcome_log_rotation_overwrites.patch (rev 0)
+++ trunk/patches/nagios_overcome_log_rotation_overwrites.patch 2013-02-26 17:30:27 UTC (rev 220)
@@ -0,0 +1,25 @@
+diff -ur nagios-4.0.20130107.original//base/logging.c nagios-4.0.20130107/base/logging.c
+--- nagios-4.0.20130107.original//base/logging.c 2013-01-21 13:44:50.000000000 +0000
++++ nagios-4.0.20130107/base/logging.c 2013-02-26 16:52:34.000000000 +0000
+@@ -339,6 +339,7 @@
+ int rename_result = 0;
+ int stat_result = -1;
+ struct stat log_file_stat;
++ time_t current_time;
+
+ if(log_rotation_method == LOG_ROTATION_NONE) {
+ return OK;
+@@ -354,6 +355,13 @@
+ else
+ return ERROR;
+
++ /* Opsview: There's a strange bug in Nagios 3.4.4 and Nagios 4 where the log rotation sometimes happens twice. We try to overcome it here */
++ current_time = time(NULL);
++ if (current_time - last_log_rotation < 3000) {
++ logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Another log rotation was requested for %lu. Last rotation at %lu, current time is %lu", rotation_time, last_log_rotation, current_time);
++ return ERROR;
++ }
++
+ /* update the last log rotation time and status log */
+ last_log_rotation = time(NULL);
+ update_program_status(FALSE);
Added: trunk/patches/nagios_reentrant_localtime.patch
===================================================================
--- trunk/patches/nagios_reentrant_localtime.patch (rev 0)
+++ trunk/patches/nagios_reentrant_localtime.patch 2013-02-26 17:30:27 UTC (rev 220)
@@ -0,0 +1,14 @@
+diff -ur nagios-4.0.20130107.original//base/utils.c nagios-4.0.20130107/base/utils.c
+--- nagios-4.0.20130107.original//base/utils.c 2013-01-21 13:44:50.000000000 +0000
++++ nagios-4.0.20130107/base/utils.c 2013-02-26 16:29:29.000000000 +0000
+@@ -743,7 +737,9 @@
+
+ /* Checks if the given time is in daylight time saving period */
+ int is_dst_time(time_t *time) {
+- struct tm *bt = localtime(time);
++ struct tm tm_s;
++ //struct tm *bt = localtime(time);
++ struct tm *bt = localtime_r(time, &tm_s);
+ return bt->tm_isdst;
+ }
+
_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins