[mrtg] Re: Incorrect Uptime reported by MRTG

kelsey hudson khudson at tsss.org
Wed Sep 21 00:11:01 MEST 2005


Wow, almost five years ... Not bad.

The short answer is: A 32-bit unsigned integer is overflowing somewhere.

The long answer is:

Timeticks are reported in milliseconds. If the 'timeticks' counter is 
only read as a 32-bit unsigned integer, it will loop every 497 days or 
so (as you can only keep track of 4294967296 milliseconds = 497.102.. 
days). for instance:

loather% snmpwalk -c public -v2c wicked-funk system.sysUpTime.0 

SNMPv2-MIB::sysUpTime.0 = Timeticks: (9794656) 1 day, 3:12:26.56

There are 86400 seconds in a day, thus 8640000 milliseconds:

9794656/8640000 = 1.1336...

so, a day and some change; this is what we expect.

in your example below:
(days)            (hours)       (minutes)    (length of uint32)
((1691*8640000) + (22*360000) + (52*6000)) / 2^32 = 3.4036...

So, it looped 3 times, with some change left over. if we multiply the 
decimal part of that by the number of days in a loop, we get:

0.4036... * (2^32/8640000) = 200.6446...

or, 200 days and some change. Of course, there are calendar and clock 
rounding magic to take into account (libc takes care of this), so these 
raw numbers are going to be off a bit.

Now, as far as whose fault this is, the blame could lay in a couple of 
places:

snmp standard mandates reporting timeticks as uint32
cisco's snmp implementation reporting timeticks as uint32
mrtg maps timeticks into a uint32 datatype

I have no idea which one of these three it is, but:

If it's the first case, well, not much we can do.

If it's the second case, an upgraded IOS or CatOS image may fix that. 
But, if your switch has been running for 5 years without a reboot, 
there's probably a reason for it -- upgrading may not be an option if 
it's a busy root switch.

If it's the third case, mrtg could possibly be hacked to support longer 
bitfields than 32 bit for those counter types.

hope this sheds some light on the subject.
-kelsey


Davis, Steve wrote:
> I'm running MRTG Version 2.11.1 on a Sun Solaris box which reports the
> uptime on a Cisco 6506 Switch as:
> The statistics were last updated Tuesday, 20 September 2005 at 13:45,
> at which time 'ESWMERSAC01' had been up for 200 days, 18:45:59. 
> However, on the actual switch itself, it reports:
> Uptime is 1691 days, 22 hours, 52 minutes
> 
> Anyone have an idea why MRTG is reporting the incorrect uptime?  The
> date on the Sun box is:
> 
> # date
> Tue Sep 20 13:51:22 PDT 2005
> 
> TIA
> Steve
> 
> 
> 
> 
> --
> Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
> Archive     http://lists.ee.ethz.ch/mrtg
> FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
> WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi
> 

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



More information about the mrtg mailing list