I noticed that these time periods aren't implemented in the Nagios
CGIs, so I implemented them a few months ago for the availability
reports. Presumably these can also be applied to histogram, summary,
and trends.
But I wanted to pass this by this list, since I'm seeing some
unpredictable behavior. I'm concerned that this code is either
touching ugly internals or just plain wrongly implemented. It works,
but the lines with the "Why" comments are concerning. My
modification of t->tm_hour had to be -1 in v1.2, and now has to be 1
in v2.0b3, neither value being expected.
These time periods might be useful for folk who work at shops that
track quarterly availability.
Thanks,
--
Ken.
--- avail.c 2005/05/03 23:26:44 1.1
+++ avail.c 2005/05/04 00:14:22
@@ -567,6 +567,8 @@
printf("This Month\n",
(timeperiod_type==TIMEPERIOD_THISMONTH)?"SELECTED":"");
printf("Last 31 Days\n",
(timeperiod_type==TIMEPERIOD_LAST31DAYS)?"SELECTED":"");
printf("Last Month\n",
(timeperiod_type==TIMEPERIOD_LASTMONTH)?"SELECTED":"");
+ printf("This Quarter\n",
(timeperiod_type==TIMEPERIOD_THISQUARTER)?"SELECTED":"");
+ printf("Last Quarter\n",
(timeperiod_type==TIMEPERIOD_LASTQUARTER)?"SELECTED":"");
printf("This Year\n",
(timeperiod_type==TIMEPERIOD_THISYEAR)?"SELECTED":"");
printf("Last Year\n",
(timeperiod_type==TIMEPERIOD_LASTYEAR)?"SELECTED":"");
printf("\n");
@@ -660,6 +662,8 @@
printf("This Month\n");
printf("Last 31 Days\n");
printf("Last Month\n");
+ printf("This Quarter\n");
+ printf("Last Quarter\n");
printf("This Year\n");
printf("Last Year\n");
printf("* CUSTOM REPORT PERIOD *\n");
@@ -3147,10 +3151,30 @@
t1=mktime(t);
break;
case TIMEPERIOD_THISQUARTER:
- /* not implemented */
+ t->tm_mon = t->tm_mon - ( t->tm_mon % 3 );
+ t->tm_mday = 1 ;
+ t->tm_hour = 1 ; /* Why not 0 ??? */
+ t1=mktime(t);
+ t2=current_time;
break;
case TIMEPERIOD_LASTQUARTER:
- /* not implemented */
+ if ( t->tm_mon tm_mon = 0 ;
+ t->tm_mday = 1 ;
+ t2 = mktime(t) - 1 ;
+ t->tm_year-- ;
+ t->tm_mon = 9 ;
+ t->tm_hour = 0 ; /* This makes sense... */
+ t1 = mktime(t);
+ }
+ else {
+ t->tm_mon = t->tm_mon - ( t->tm_mon % 3 );
+ t->tm_mday = 1 ;
+ t->tm_hour = 1 ; /* Why not 0 ??? */
+ t2 = mktime(t) - 1 ;
+ t->tm_mon -= 3 ;
+ t1 = mktime(t);
+ }
break;
case TIMEPERIOD_THISYEAR:
t->tm_mon=0;
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]