[mrtg] Re: UPS Runtime Remaining

Hart, Kevin KHart at helixtechnology.com
Wed Jan 15 17:39:36 MET 2003


Hi Leonard,

Here is yet another Perl script which someone had contributed previously.
I use this on a W2K box with snmputil from the W2K Resource Kit
and it works fine.

Kevin

====================================================================
$IP = $ARGV[0];
$Community = $ARGV[1];
chomp $ip;
chomp $Community;

@a=`/snmputil.exe get $IP $Community .1.3.6.1.4.1.318.1.1.1.2.2.3.0`;
chomp @a;
@b=split(/Value    = TimeTicks /, at a[1]);
print eval($b[1] / 6000),"\n";
@c=`/snmputil.exe get $IP $Community .1.3.6.1.4.1.318.1.1.1.2.2.3.0`;
chomp @c;
@d=split(/Value    = TimeTicks /, at c[1]);
print eval($d[1] / 6000),"\n";


MRTG Config

Target[APC-TIME]: `perl c:\mrtg-2.9.22\bin\ups_time.pl xxxx.xxxx.xxxx.xxxx
community`
MaxBytes[APC-TIME]: 100
Title[APCB4-TIME]:   UPS Battery Time Remaining (Minutes)
PageTop[APC-TIME]: <H1> UPS Battery Time Remaining (Minutes)</H1>
Unscaled[APC-TIME]: ymwd
ShortLegend[APC-TIME]: minutes
XSize[APC-TIME]: 380
YSize[APC-TIME]: 100
YLegend[APC-TIME]: Minutes
LegendI[APC-TIME]:
LegendO[APC-TIME]: &nbsp
Options[APC-TIME]: gauge, integer, nopercent

===========================================================================


-----Original Message-----
From: Jerry Heidtke [mailto:jheidtke at fmlh.edu]
Sent: Wednesday, January 15, 2003 9:21 AM
To: 'Leonard Miller'; mrtg at list.ee.ethz.ch
Subject: [mrtg] Re: UPS Runtime Remaining



Here's what I use with APC UPS to graph time remaining.

This is the perl script. It's a slightly modified version of the script
included in the contrib directory with mrtg. The main modification is that
it accepts the target IP address and community name as command line
parameters.

It uses snmpget.exe from the net-snmp package. It could rather easily be
rewritten to use the SNMP_util perl library included with mrtg. This is left
for an exercise for the reader...

Jerry

--------------------------------------------
#!d:\perl\bin\perl
#
# Script to convert runtime MIB variable for UPS into minutes
# eg. perl upsdata01.pl host-addr snmp-community
$x=$ARGV[0];
@y=split(/@/,$x);
$a=`d:/usr/bin/snmpget $y[1] $y[0] .1.3.6.1.4.1.318.1.1.1.2.2.3.0`;
chomp $a;
@b=split(/ /,$a);
@c=split(/:/,$b[4]);
@d=split(/ /,`d:/usr/bin/snmpget $y[1] $y[0]
.1.3.6.1.4.1.318.1.1.1.4.2.3.0`);
chomp $d;
print eval($c[0] * 60 + $c[1]),"\n";
print $d[3];
--------------------------------------------

Here is a sample mrtg config to call it.

--------------------------------------------
MaxBytes[_]: 600
Options[_]: growright, gauge, nopercent, noo, integer
WithPeak[_]: wmy
Unscaled[_]:
YLegend[_]: UPS Run Time
ShortLegend[_]: minutes
LegendI[_]: UPS Run Time Remaining:
LegendO[_]:
Legend1[_]: UPS Run Time
Legend2[_]:
Legend3[_]: Max. UPS Run Time
Legend4[_]:

Target[UPSTime]: `d:\perl\bin\wperl d:\mrtgcfg\cfg\template\upsdata01.pl
xxx.xxx.xxx.xxx community`
Title[UPSTime]:  UPS Run Time Remaining for
PageTop[UPSTime]:  UPS Run Time Remaining for
--------------------------------------------


-----Original Message-----
From: Leonard Miller [mailto:Leonard_Miller at udlp.com] 
Sent: Wednesday, January 15, 2003 7:37 AM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] UPS Runtime Remaining



Me again with another UPS question.  So far I have been able
to get everything I need from my UPSssssss, temperature, status, capacity
and about 8 other values I needed, except runtime remaining.  I assumed it
would return a value like this "546000" and I had the config file setup to
calculate the result based on that. But it doesn't.  It returns the actual
time remaining, HH:MM:SS.

Is there a way to get it to read and graph the returned value? Or will I
have to look to an external perl script to do this?  

Thanks
Leonard

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


Confidentiality Notice: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and may contain confidential 
and privileged information.  Any unauthorized review, use, disclosure or 
distribution is prohibited.  If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.


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

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