[mrtg] Measuring RSSI

Steve Shipway s.shipway at auckland.ac.nz
Thu May 7 00:08:56 CEST 2015

It looks like the OID is returning a string value.  MRTG expects a Counter,
so this is not going to work without postprocessing using the ConversionCode
directive and Target suffixes.


You need to define a Conversion function, like this.


First, create a file conversion.pl in the same directory as the mrtg script
containing this:


sub string2int {

  my $value = shift;

  if ( $value =~ /(-?\d+\.?\d*)/ ) { return $1; } else { return undef; }



In your MRTG cfg file, have this to declare the functions:


ConversionCode: conversion.pl


Then, in your Target line, use something like this to use string2int to
postprocess the output:


Target[ezwf]: rssi.0&rssi.0:community at devicename:::::2|string2int


This will extract the '-77' from the string "-77 dBm".


However, if you are using native MRTG, you 'll have problems with decimals
and negative numbers as they are not supported.  To get around this, you
could use a simple regexp in the string2int function, such as /(\d+)/ which
will ignore and decimals and negatives.


You could use


Factor[ezwf]: -1


.to display the (positive) stored values as negative, though I'm not certain
if native-mode MRTG supports negative Factor[] definitions either.  Have
another recommendation to use the RRDTool backend J - maybe you can convince
your management.




Steve Shipway

 <mailto:s.shipway at auckland.ac.nz> s.shipway at auckland.ac.nz

(GNU Terry Pratchett)


From: Rick Silacci [mailto:rick at velociter.net] 
Sent: Thursday, 7 May 2015 5:09 a.m.
To: Steve Shipway
Subject: RE: Measuring RSSI


Actually I walked the correct OID and it came
back with "-77  dBm"  When I poll it through mrtg I get error message:
Warning: Expected a number but got -'77 dBm'



I need to suppress the 'dbm' part.  Is that possible?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/mrtg/attachments/20150506/733db347/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 10311 bytes
Desc: not available
URL: <http://lists.oetiker.ch/pipermail/mrtg/attachments/20150506/733db347/attachment-0001.bin>

More information about the mrtg mailing list