[mrtg] Monitor octets in a sting
Daniel McDonald
dan.mcdonald at austinenergy.com
Fri Jul 30 15:06:47 CEST 2010
On 7/30/10 5:11 AM, "BitnByte" <daniel.olsson at plastal.com> wrote:
>
> Hi
>
> I am having problems with an octet string. I am trying to monitor the
> ambient on an IBM RSA II card with the OID: .1.3.6.1.4.1.2.3.51.1.2.1.5.1
> The return answer is an string with this definition from IBM MIB for this
> RSA II card
> System's ambient temperature in degrees centigrade(C).
> This is surrounding temperature where the system is installed.
> An octet string expressed as 'sddd.dd Centigrade' where:
> s is the sign ('-' for negative or blank space for positive)
> d is a decimal digit or blank space for a leading zero..
> The string 'Not Readable!' indicates that the given monitor
> is not supported on this system.
The usual idiom from the device manufacturers is to record the value in
integer centi-degrees, then you would use a factor[] to scale it properly.
But a string is not expected...
>
> so I get the result " 20.00 Centigrade" right now but MRTG don't seem to
> handle it ?
Correct, mrtg expects a number. You will need to use a "conversion code"
script to make this work. It's still a perl snippet, but the interfaces are
pretty well defined. See the docs on this.
A sample perl sub to perform this might be:
sub tempString {
#grab 1st argument as the string to convert
my $String = shift;
#look for optional negative sign followed by 4 to 6 digits or decimal points
$String =~ /(-?[\.\d]{4,6})/;
my $val = $1;
#recast as a number
$val +=0;
#Convert to an integer
$val *= 100;
$val = int($val);
#return the value:
return $val;
}
--
Daniel J McDonald, CCIE # 2495, CISSP # 78281
More information about the mrtg
mailing list