From: S E W. <sew...@gm...> - 2019-10-10 17:25:58
|
Hello all, How do you use the INDEX transform? Rather, once you've done the INDEX transform, how do you use the results? The documentation completely glosses over this: 'INDEX' transform: This transform allows you to access the index part of a numerical OID in a repeater OID. For example, in the cdpCache table for the Cisco CDP MIB, walking the cdpCacheDevicePort OID will return values such as: CISCO-CDP-MIB::cdpCacheDevicePort.4.3 = STRING: GigabitEthernet4/41 CISCO-CDP-MIB::cdpCacheDevicePort.9.1 = STRING: GigabitEthernet2/16 CISCO-CDP-MIB::cdpCacheDevicePort.12.14 = STRING: Serial2/2 The value is the interface on the remote side, and there is no OID for the interface on the local side. To get the interface on the local side, you must use the last value in the index (e.g. 3 for GigabitEthernet4/41) and look in the ifTable: IF-MIB::ifName.3 = STRING: Fa0/0 The index transform allows you to get the index value (4.3 in this case) as an OID value. Any operations you need to do on the index value should be possible with existing transforms. What I'm trying to do is almost exactly what's in the example. I can get the index I need, but HOW do I use it to look in the ifTable? I thought it was possibly the CHAIN transform but I have been completely unable to make it work. Detail on my use case: I'm attempting to pull light levels off a Juniper router and am having difficulty getting the information I need to display. Here is my oids file: ifName : .1.3.6.1.2.1.31.1.1.1.1 : branch ifAlias : .1.3.6.1.2.1.31.1.1.1.18 : branch ifRxPower : .1.3.6.1.4.1.2636.3.60.1.2.1.1.6 : branch ifTxPower : .1.3.6.1.4.1.2636.3.60.1.2.1.1.8 : branch The problem is that for 40G & 100G optics there are multiple lanes per interface, so the OID I'm polling is not a one-to-one match with the ifName. (10G optics have a single lane 0.) Here's an example from snmpwalk: IF-MIB::ifName.580 = STRING: et-4/0/0 SNMPv2-SMI::enterprises.2636.3.60.1.2.1.1.6.580.0 = INTEGER: -223 SNMPv2-SMI::enterprises.2636.3.60.1.2.1.1.6.580.1 = INTEGER: -198 SNMPv2-SMI::enterprises.2636.3.60.1.2.1.1.6.580.2 = INTEGER: -227 SNMPv2-SMI::enterprises.2636.3.60.1.2.1.1.6.580.3 = INTEGER: -228 You can see that et-4/0/0 (580) includes 4 lanes, reported as 580.0, 580.1, 580.2, and 580.3 So what I want to do is iterate the ifRxPower OID, and report the ifName and Lane number on each line. I am having a hard time getting the ifName. I know I need to use the INDEX transform to pull out the index. ifRxIdx : INDEX : {ifRxPower} This pull out the indices, which in this case are 580.0, 580.1, 580.2, and 580.3 And then I'm using REGSUBs to split the index into the leaf I need to grab out of ifName and the lane number. ifRxIfIdx : REGSUB : {ifRxIdx} /^(\d+)\.\d+$/$1/ ifRxLane : REGSUB : {ifRxIdx} /^\d+\.(\d+)$/$1/ This all works as expected, putting the first part of the index in ifRxIfIdx (580, in this example), and the lane numbers (not values) in ifRxLane. The following message file proves this out. TABLE:noalarmsmsg Rx Index|Rx If Index|Rx Lane {ifRxIdx}|{ifRxIfIdx}|{ifRxLane} Giving the output Rx Index Rx If Index Rx Lane 580.0 580 0 580.1 580 1 580.2 580 2 580.3 580 3 So far so good! However nothing I've tried has allowed me to actually combine the index ifRxIfIdx with the ifName to pull out the correct value. I've tried every combination of CHAIN I can think of, going so far as to actually store the ifName numeric OID value in a repeater variable. This also didn't work. :) Does anyone have anything similar working in practice or can shed any light on how this works? Thanks, Steve |