[mrtg] Re: hrSystemUptime

James Overbeck grendel at gmo.jp
Wed Feb 19 11:53:41 MET 2003


Hello,
	I believe the point of this exercise is to avoid sysUpTime looping like the
odometer on an old car every (((2**32 / 100) / 60) / 60) / 24 = 497 days.
sysUpTime does that because it is limited to a 32 bit counter. I've seen it
happen many a time on access servers and routers that no one has touched for
a long time. Anything beginning with hr usually uses SNMPv2 and a 64 bit
counter, so hrSystemUptime would loop roughly every ((((2**64 / 100) / 60) /
60) / 24) / 365.25 = 5845420460 years.
	The answer would be to hack the mrtg perl executable so it can take an OID
as part of the RouterUptime option, then mail Tobias and ask him nicely to
include your modification in the next release. :D
	In version 2.9.26b, this is the piece of code you need to change:

if (defined $$rcfg{routeruptime}{$rou}) {
  ($uptime,$name) = snmpget($$rcfg{routeruptime}{$rou}, $$cfg{snmpoptions},
             'sysUptime',
             'sysName'); #" <- this makes emacs parsing happy
}

		According to
http://people.ee.ethz.ch/~oetiker/webtools/mrtg/reference.html , the
RouterUptime target option allows you to specify a community at hostname for
fetching uptime, but it doesn't seem to allow you to specify an OID.
	The following would allow you to do so, as long as you don't have an @ mark
in your community and you use a numerical OID. So it's not perfect. ^^;

if (defined $$rcfg{routeruptime}{$rou}) {
  if ($$rcfg{routeruptime}{$rou} =~ /^([\d\.]+)\:([^\@]+)\@(.+)$/) {
    my($oid,$community,$host) = ($1,$2,$3);
    ($uptime,$name) = snmpget($community.'@'.$host,
             $$cfg{snmpoptions},
             $oid,
             'sysName'); #" <- this makes emacs parsing happy
  } else {
    ($uptime,$name) = snmpget($$rcfg{routeruptime}{$rou},
             $$cfg{snmpoptions},
             'sysUptime',
             'sysName'); #" <- this makes emacs parsing happy
  }
}

	With that change, you can specify RouterUptime something like this:

RouterUptime[localhost]: 1.3.6.1.2.1.25.1.1.0:public at localhost:::::2

HopeThatHelps,
James


Brett Marler wrote:
> Hello Antoine,
> 
> 
>>On a console, if I go:
>># snmpget -v 2c -c public localhost host.hrSystem.hrSystemUptime.0
> 
> (snip)
> 
>>HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (105259891) 12 days,
>>4:23:18.91
>>
>>But I have no idea how to tell mrtg to use this.
> 
> 
> I get the "uptime" of my Windows XP box by simply running a small script from 
> my Linux box which simply does an snmpwalk, searches for the sysuptime, strips 
> the "days" off and puts it into a format which MRTG can then make a graph 
> from. Script is below if you would like it, just a no brainer shell script!
> 
> --
> #!/bin/sh
> uptime=`/usr/local/bin/snmpwalk -v1 -c private 172.16.0.1 | /bin/grep -i 
> sysuptime | awk '{print $5}' | sed 's/days//'`
> echo "$uptime";
> --
> 
> Hope this is of some help.
> 
> 
> Regards.


--
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