[mrtg] Reading Cisco optical transceiver values using snmp?

Daniel McDonald dan.mcdonald at austinenergy.com
Thu Sep 30 16:50:40 CEST 2010


On 9/30/10 3:16 AM, "Jan Ferré" <Jan.Ferre at uni-c.dk> wrote:

> Does anybody know if it's possible to read the optical values from
> transceivers using snmp? Doing a terminal session, I can get information:



> 
> 
> $ sh int ten 8/1 transceiver
>                                         Optical   Optical
>             Temperature  Voltage  Current   Tx Power  Rx Power
> Port        (Celsius)    (Volts)  (mA)      (dBm)     (dBm)
> ----------  -----------  -------  --------  --------  --------
> Te8/1         34.3       0.00       7.6 --   -0.8     -12.9
> 
> 
> But I have been unable to find the snmp-variables to read those values
> directly.

It's in the entity-sensor-mib.  The instance number moves around a bit with
each boot, so you have to search for them rather than have a static config.

A couple of caveats:
The number is reported as centiBels.  That means you need to use factor[] to
display them properly
The number is negative.  Rateup doesn't understand negative numbers at all.
Rrdtool is configured by default to not accept negative numbers.  You need
to perform an rrdtune on the rrd files in order to allow it to track
negative numbers.  I usually use:

rrdtool tune /path/to/rrdfile.rrd -i DS0:-800 -i DS1:-800

Someday when I have free time I'll think about devising some way to create
the RRD that way, so I don't have to hunt them down and manually tune
them...


> 
> (don't waste time trying to find them - I only ask you to tell me if you
> have this information at hand)

Here is the template I use to find these:
#
# Look for dBm meters - probably interesting

snmpMIB_to_OID("/usr/share/snmp/mibs/ENTITY-MIB-V1SMI.my");
snmpMIB_to_OID("/usr/share/snmp/mibs/ENTITY-SENSOR-MIB.my");
snmpMIB_to_OID("/usr/share/snmp/mibs/CISCO-ENTITY-SENSOR-MIB-V1SMI.my");
        my (@est) = snmpwalk($router,$v3opt,'entSensorType');
        foreach my $esti (@est) {
        my ($tinstance,$ttype) = ($esti =~  /(\d+):(.+)$/) ;
        next if $ttype != 14;
                my (@estv) =
snmpwalk($router,$v3opt,'entSensorThresholdValue.'.$tinstance);
                my %thresh;
                foreach my $estvi (@estv) {
                        my ($thin,$value) = ($estvi =~ /(\d+):(.+)$/) ;
                        $thresh{$thin} = $value;
                        };
                my $maxsize = $thresh{1}+10;
                $maxsize = 10   if ($maxsize < 0) ;
                my ($sens_name) =
snmpget($router,$v3opt,'entPhysicalName.'.$tinstance);
        my $sens_descr .= ' '.$sens_name;
        my $target_name=$router_name.".signal".$tinstance;
        $target_lines .= <<SIGNAL
#---------------------------------------------------------------------------
-----------
# Signal Strength
    
Target[$target_name]:
entSensorValue.$tinstance&entSensorValue.$tinstance:$router
SnmpOptions[$target_name]: $v3options
YLegend[$target_name]: dB
Options[$target_name]: gauge, noi, nopercent
Directory[$target_name]: $directory_name
MaxBytes[$target_name]: $maxsize
ShortLegend[$target_name]: dB
Factor[$target_name]: .1
routers.cgi*ShortDesc[$target_name]: $sens_name
routers.cgi*Options[$target_name]: nototal
bb*host[$target_name]: $router_name
bb*svc[$target_name]: signal
bb*red[$target_name]: $thresh{4}:$thresh{1}
bb*yellow[$target_name]: $thresh{3}:$thresh{2}
Legend1[$target_name]: dB
WithPeak[$target_name]: ymw
Title[$target_name]: $sysname $sens_descr
PageTop[$target_name]: <H1>$sysname $sens_descr </H1>
 <TABLE>
   <TR><TD>System:</TD><TD>$sysname  </TD></TR>
   <TR><TD>Location:</TD><TD>$syslocation </TD></TR>
 </TABLE>
SIGNAL
;
} 

> 
> Thanks
> 
> Jan

-- 
Daniel J McDonald, CCIE # 2495, CISSP # 78281



More information about the mrtg mailing list