[mrtg] Re: hrSystemUptime

Mike Wren mwren at burnsmcd.com
Wed Feb 19 15:33:25 MET 2003

My interest in UpTime was so I could graph it.  I wanted to know how
often during a year that a device had been rebooted.  I created two
similar script files, one used system.sysUpTime.0 and the other used the
host.hrSystem.hrSystemUptime.0 OID.  With the Routers and switches is
use the system.sysUpTime.0 and computers I use the
host.hrSystem.hrSystemUptime.0.  The script files are the same except
for the OID and are named GetUptime and GetUptimeHr.  Also I got caught
by the fact that system.sysUpTime.0 is the uptime of the SNMP agent, and
if it is stopped and started the value will not reflect that actual
uptime of the computer.

Here is the script file GetUptime:

#script GetUptime so I can graph a devices uptime
RESPONSE=`snmpget -Ov -c $1 $2 system.sysUpTime.0`
VALUE=`echo $RESPONSE | cut -d'(' -f2 | cut -d')' -f1`
CHARVAL=`echo $RESPONSE | cut -d' ' --fields=3-5`
UPTIME=`echo "scale=0; $VALUE / 8640000" | bc`
echo $UPTIME
echo $UPTIME
echo $2

The entry in my template file looks like this:

Target[$router_name.uptime]: `/usr/bin/GetUptime $community
YLegend[$router_name.uptime]: Days
ShortLegend[$router_name.uptime]: Days
RouterUptime[$router_name.uptime]: $router_connect
Legend1[$router_name.uptime]: Days
Legend3[$router_name.uptime]: Max Days
LegendI[$router_name.uptime]:  Days: 
WithPeak[$router_name.uptime]: ywm
MaxBytes[$router_name.uptime]: 100000
Options[$router_name.uptime]: noo, growright, gauge, nopercent
Title[$router_name.uptime]: Uptime (in days)
Directory[$router_name.uptime]: $router_name
PageTop[$router_name.uptime]: <H1>$router_name Uptime</H1>
  <TR><TD>System:</TD><TD>PIX $sysname in $html_syslocation </TD></TR>
  <TR><TD>Description:</TD><TD>$html_sysdescr </TD></TR>
  <TR><TD>Maintainer:</TD><TD>$html_syscontact </TD></TR>

Michael Wren
Senior Network Analyst
Burns & McDonnell Engineering
P.O. Box 419173
Kansas City, MO 64141-6173
mwren at burnsmcd.com

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