[mrtg] timezone issue & y2k

burt burtc at amazon.com
Thu Aug 12 18:44:35 MEST 1999


I wasn't able to get the timezone config variable to work
either.  MRTG would display the timezone in the output but failed
to actually change the displayed time.

I upgraded to 2.8.6, but it still didn't work.

In looking into the code, I also found that the time calculation
will fail at the end of the year.

Here is a modification of mrtg that uses the correct timezone (as
much as I have tested) and fixes the y2k error.

MRTG is a great program - thank you!

burt


Index: run/mrtg
===================================================================
RCS file: /mrtg-2.8.6/run/mrtg,v
retrieving revision 1.2
diff -c -r1.2 mrtg
*** run/mrtg    1999/08/12 14:28:52     1.2
--- run/mrtg    1999/08/12 15:33:35
***************
*** 74,79 ****
--- 74,80 ----
      $main::SNMPDEBUG =0;
  }
  
+ use Date::Manip;
  use strict;
  
  if($main::OS eq 'UNIX')
***************
*** 1375,1390 ****
  }
  
  sub datestr {
!   my ($time) = shift(@_) || return 0;
!   my ($wday) = ('Sunday','Monday','Tuesday','Wednesday',
!              
'Thursday','Friday','Saturday')[(localtime($time))[6]];
!   my ($month) = ('January','February' ,'March' ,'April' ,
!                'May' , 'June' , 'July' , 'August' , 'September'
, 
!                'October' ,
!                'November' , 'December'
)[(localtime($time))[4]];
!   my ($mday,$year,$hour,$min) = (localtime($time))[3,5,2,1];
!   if ($min<10) {$min = "0$min";}
!   return "$wday, $mday $month ".($year+1900)." at $hour:$min";
  }
  
  sub expistr {
--- 1376,1390 ----
  }
  
  sub datestr {
! 
!   my $time = shift ; #seconds since 01/01/1970 00:00:00, 
!                      #as returned by time()
! 
!   my $date = UnixDate(
!                     DateCalc("Jan 1, 1970 00:00:00 GMT",$time),
!                     "%A, %d %B %Y at %H:%M $ENV{TZ}");
!   return $date;
! 
  }
  
  sub expistr {
***************
*** 1510,1516 ****
  <HR>
  TEXT
  print HTML     
! &$LOC("The statistics were last updated <B>$Today
$$rcfg{'timezone'}{$router}</B>");
  
  
  if ($uptime && ! $$rcfg{options}{noinfo}{$router}) {
--- 1510,1516 ----
  <HR>
  TEXT
  print HTML     
! &$LOC("The statistics were last updated <B>$Today</B>");
  
  
  if ($uptime && ! $$rcfg{options}{noinfo}{$router}) {

--
* To unsubscribe from the mrtg mailing list, send a message with the
  subject: unsubscribe to mrtg-request at list.ee.ethz.ch
* The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg


More information about the mrtg mailing list