[mrtg] Re: Problems with ?dates? on FreeBSD 5.0-RELEASE sparc64

Corey Smith csmith at bonddesk.com
Tue Feb 11 15:30:03 MET 2003


Ok.  The problem exists because sizeof(long) != sizeof(time_t) or 64 !=
32...

Some of the code uses longs to represent time_t values.

The following patch fixes the problem in mrtg-2.9.25:

<PATCH>
--- src/rateup.c.orig   Sat Oct 19 05:06:55 2002
+++ src/rateup.c        Mon Feb 10 22:55:06 2003
@@ -830,12 +830,14 @@
     struct HISTORY *hist;
     unsigned long rd[5];
     time_t cur;
+    long lasttime;

     if ((fi = fopen(file,"r")) != NULL) {
-       if (fscanf(fi,"%ld %s %s\n",(long int
*)&last.time,&last.in[0],&last.out[0]) != 3){
+       if (fscanf(fi,"%ld %s %s\n",&lasttime,&last.in[0],&last.out[0])
!= 3){
            fprintf(stderr,"Read Error: File %s lin 1\n",file);
           retcode = 1;
        }
+       last.time = lasttime;
         cur = last.time;
        x = histvalid=0;
        hist = history;
</PATCH>

The following patch fixes the problem in rrdtool-1.0.40:

<PATCH>
--- src/parsetime.c.orig        Fri Oct 11 14:39:46 2002
+++ src/parsetime.c     Mon Feb 10 20:47:18 2003
@@ -660,6 +660,7 @@
 {
     long mday=0, wday, mon, year = ptv->tm.tm_year;
     int tlen;
+    time_t montime;

     switch (sc_tokid) {
     case YESTERDAY:
@@ -713,7 +714,8 @@
            tlen = strlen(sc_token);
            mon = atol(sc_token);
             if (mon > 10*356*24*60*60) {
-               ptv->tm=*localtime(&mon);
+               montime = mon;
+               ptv->tm=*localtime(&montime);
                token();
                break;
            }
</PATCH>

Once these patches are applied I am able to poll devices using either
LogFormat.

Corey Smith

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list