From: "R.P. Aditya" <aditya@dnai.com>
The problem is in BER.pm (part of the SNMP Perl stuff) -- you can change
sub pretty_uptime ($) {
my ($packet,$uptime);
($uptime,$packet) = &decode_unsignedlike (@_);
pretty_uptime_value ($uptime);
}
to be
sub pretty_uptime ($) {
my ($packet,$uptime);
($uptime,$packet) = &decode_unsignedlike (@_);
$uptime = int($uptime / 100);
return ($uptime);
}
and you'll get a numeric uptime in seconds...
Adi
--------------------------------------------------------------------------------
sub pretty_uptime_value ($) {
my ($uptime) = @_;
my ($seconds,$minutes,$hours,$days,$result);
## We divide the uptime by hundred since we're not interested in
## sub-second precision.
$uptime = int ($uptime / 100);
$days = int ($uptime / (60 * 60 * 24));
$uptime %= (60 * 60 * 24);
$hours = int ($uptime / (60 * 60));
$uptime %= (60 * 60);
$minutes = int ($uptime / 60);
$seconds = $uptime % 60;
if ($days == 0){
$result = sprintf ("%d:%02d:%02d", $hours, $minutes, $seconds);
} elsif ($days == 1) {
$result = sprintf ("%d day, %d:%02d:%02d",
$days, $hours, $minutes, $seconds);
} else {
$result = sprintf ("%d days, %d:%02d:%02d",
$days, $hours, $minutes, $seconds);
}
return $result;
}
In message <Pine.GSO.4.10.9907020953320.24602-100000@the.satanic.org>, roofpig@the.satani
c.org writes:
> From: <roofpig@the.satanic.org>
>
> On Wed, 30 Jun 1999, Jeff Allen wrote:
>
> > From: Jeff Allen <jra@corp.webtv.net>
> >
> > Glenn MacGregor wrote:
> >
> > > Also if I try to get sysUptime I get an error message saying 2:24:55
> > > (uptime) is not numeric, is there a way around this?
> >
> > You are trying to put a string into an RRD, which is not possible. You
> > could use an EXEC script to fetch the value then do pre-processing on
> > it -- in this case the pre-processing would be to turn the formatted
> > time string into a number of seconds.
> >
>
> I know the SNMP perl module (the UCD one, not the SNMP_Session
> that cricket uses) allows you to tell it to return the unenumerated
> value. So instead of the formated 2:24:55, you'll get the timeticks
> value. Perhaps the SNMP_Session module has a similar option? I, for one,
> have several things that I'd like to graph that are timetick (NetApp CPU
> busy seconds, APC seconds remaining on battery, APC seconds on battery,
> etc.). It seems unfortunate that I would have to write a special EXEC to
> get these values via a different SNMP method just to unformat them.
>
>
>
>
>
> --------------------------- ONElist Sponsor ----------------------------
>
> How has ONElist changed your life?
> Share your story with us at http://www.onelist.com
>
> ------------------------------------------------------------------------
>
--------------------------- ONElist Sponsor ----------------------------
Who is the most visited e-mail list community Web Service?
http://www.onelist.com
ONElist.com - where more than 20 million e-mails are exchanged each day!
------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Mon Mar 06 2000 - 19:00:55 PST