[Nagios-devel] Daylight Savings CGI bug

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

[Nagios-devel] Daylight Savings CGI bug

Post by Guest »

------=_Part_24_20315408.1246434954059
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Greetings all,

I've discovered a Daylight Savings Time bug within the avail, histogram, summary and trends CGIs.

To reproduce, run a custom report timeperiod for a duration which spans migration into or out of DST. As an example using NZST either 1st Apr to 30th Apr or 1st Sep to 30th Sep. Note the start and end time, either the start or end time will be an hour out from what one would expect.

Please see the attached patch to fix. The problem arises from using the generated tm_isdst flag from calling localtime(&current_time) within compute_report_times(). It should be noted setting tm_isdst=-1 is used elsewhere within these CGIs already.

Thanks,
--
*Mark Goldfinch | Systems Administrator*

*MODICA GROUP*
DIGITAL MEDIA SOLUTIONS

phone: +64 4 385 7444 | ddi: +64 4 498 3485

Level 4 | 138-140 Wakefield Street | Wellington
www.modicagroup.com

*MODICA SERVICES:*

*SONIC:*Mobile solutions
*BREATHE:*Web design and development
*ONESQUARED:*IT Infrastructure


US | UK | NZ | AUS | SING

------=_Part_24_20315408.1246434954059
Content-Type: text/x-patch; name=cgi-dst-reporting.patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=cgi-dst-reporting.patch

diff -uaNr nagios-3.1.2.orig/cgi/avail.c nagios-3.1.2/cgi/avail.c
--- nagios-3.1.2.orig/cgi/avail.c 2009-06-17 14:51:50.000000000 +1200
+++ nagios-3.1.2/cgi/avail.c 2009-06-30 22:01:36.000000000 +1200
@@ -3215,6 +3215,7 @@
st->tm_mday=start_day;
st->tm_mon=start_month-1;
st->tm_year=start_year-1900;
+ st->tm_isdst=-1;

t1=mktime(st);

@@ -3226,6 +3227,7 @@
et->tm_mday=end_day;
et->tm_mon=end_month-1;
et->tm_year=end_year-1900;
+ et->tm_isdst=-1;

t2=mktime(et);
}
diff -uaNr nagios-3.1.2.orig/cgi/histogram.c nagios-3.1.2/cgi/histogram.c
--- nagios-3.1.2.orig/cgi/histogram.c 2009-06-17 14:51:50.000000000 +1200
+++ nagios-3.1.2/cgi/histogram.c 2009-07-01 19:30:18.000000000 +1200
@@ -2427,6 +2427,7 @@
st->tm_mday=start_day;
st->tm_mon=start_month-1;
st->tm_year=start_year-1900;
+ st->tm_isdst=-1;

t1=mktime(st);

@@ -2438,6 +2439,7 @@
et->tm_mday=end_day;
et->tm_mon=end_month-1;
et->tm_year=end_year-1900;
+ et->tm_isdst=-1;

t2=mktime(et);
}
diff -uaNr nagios-3.1.2.orig/cgi/summary.c nagios-3.1.2/cgi/summary.c
--- nagios-3.1.2.orig/cgi/summary.c 2009-01-16 09:40:29.000000000 +1300
+++ nagios-3.1.2/cgi/summary.c 2009-07-01 19:31:24.000000000 +1200
@@ -1454,6 +1454,7 @@
st->tm_mday=start_day;
st->tm_mon=start_month-1;
st->tm_year=start_year-1900;
+ st->tm_isdst=-1;

t1=mktime(st);

@@ -1465,6 +1466,7 @@
et->tm_mday=end_day;
et->tm_mon=end_month-1;
et->tm_year=end_year-1900;
+ et->tm_isdst=-1;

t2=mktime(et);
}
diff -uaNr nagios-3.1.2.orig/cgi/trends.c nagios-3.1.2/cgi/trends.c
--- nagios-3.1.2.orig/cgi/trends.c 2009-06-17 14:51:50.000000000 +1200
+++ nagios-3.1.2/cgi/trends.c 2009-07-01 19:28:46.000000000 +1200
@@ -2906,6 +2906,7 @@
st->tm_mday=start_day;
st->tm_mon=start_month-1;
st->tm_year=start_year-1900;
+ st->tm_isdst=-1;

t1=mktime(st);

@@ -2917,6 +2918,7 @@
et->tm_mday=end_day;
et->tm_mon=end_month-1;
et->tm_year=end_year-1900;
+ et->tm_isdst=-1;

t2=mktime(et);
}

------=_Part_24_20315408.1246434954059--





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