[mrtg] FW: Monitoring Load

Steve Shipway s.shipway at auckland.ac.nz
Sun Sep 27 23:36:09 CEST 2009

Three ways to do the same thing, with 3 solutions!  (1) is if the problem is the string conversion, (2) is for if the problem is the MIB symbolic name, and (3) is if the problem is it not being an integer.  To be honest though I think (2) or possible (2)+(3) is the way to go, but I had to include (1) as it is so pretty :)

1. Your device is outputting the laLoad variable as a string rather than as an integer.  You may need to set up a Conversion Code definition with the fromstring() function to convert it to a real number.

In the cfg file, put a line:

ConversionCode: /usr/local/mrtg/etc/conversoincode.pl

(you might need to put a different path for your script, of course).  Then, in the conversioncode.pl file, put the text:

sub fromstring() {my $v = shift; if($v =~ /(\d+\.?\d*)/) { return $1; } else { return 0; } }

Finally, your Target definition should add '|fromstring'

Target[server.wherever_load]:  laLoad.3&laLoad.3:public at server.wherever|fromstring

Having said all of this, though, I would have expected Perl to Do The Right Thing when confronted with a string containing just a number.  I don't see why this bit should be necessary.

2. Another possibility is that MRTG simply doesn't know about the symbolic laLoad name whereas snmpwalk does.  In this case you'll need ot tell MRTG about the MIB.

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

3. A third possibility is to try using laLoadInt instead.  This is definitely a number, but multipled by 100.  You need to divide it in the Target definition:

Target[server.wherever_load]:  laLoadInt.3&laLoadInt.3:public at server.wherever / 100

Note that the spaces are significant in this definition.


From: mrtg-bounces at lists.oetiker.ch [mailto:mrtg-bounces at lists.oetiker.ch] On Behalf Of Matt Baer
Sent: Monday, 28 September 2009 6:21 a.m.
To: mrtg
Subject: Re: [mrtg] Monitoring Load

Direct copy and paste output of that command:

UCD-SNMP-MIB::laIndex.1 = INTEGER: 1
UCD-SNMP-MIB::laIndex.2 = INTEGER: 2
UCD-SNMP-MIB::laIndex.3 = INTEGER: 3
UCD-SNMP-MIB::laNames.1 = STRING: Load-1
UCD-SNMP-MIB::laNames.2 = STRING: Load-5
UCD-SNMP-MIB::laNames.3 = STRING: Load-15
UCD-SNMP-MIB::laLoad.1 = STRING: 0.57
UCD-SNMP-MIB::laLoad.2 = STRING: 0.42
UCD-SNMP-MIB::laLoad.3 = STRING: 0.36
UCD-SNMP-MIB::laConfig.1 = STRING: 12.00
UCD-SNMP-MIB::laConfig.2 = STRING: 12.00
UCD-SNMP-MIB::laConfig.3 = STRING: 12.00
UCD-SNMP-MIB::laLoadInt.1 = INTEGER: 56
UCD-SNMP-MIB::laLoadInt.2 = INTEGER: 41
UCD-SNMP-MIB::laLoadInt.3 = INTEGER: 35
UCD-SNMP-MIB::laLoadFloat.1 = Opaque: Float: 0.570000
UCD-SNMP-MIB::laLoadFloat.2 = Opaque: Float: 0.420000
UCD-SNMP-MIB::laLoadFloat.3 = Opaque: Float: 0.360000
UCD-SNMP-MIB::laErrorFlag.1 = INTEGER: noError(0)
UCD-SNMP-MIB::laErrorFlag.2 = INTEGER: noError(0)
UCD-SNMP-MIB::laErrorFlag.3 = INTEGER: noError(0)
UCD-SNMP-MIB::laErrMessage.1 = STRING:
UCD-SNMP-MIB::laErrMessage.2 = STRING:
UCD-SNMP-MIB::laErrMessage.3 = STRING:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20090928/c0d185c1/attachment.htm 

More information about the mrtg mailing list