Cisco – how to get port/interface status of cisco switch via snmp

ciscosnmp

I am trying to write a simple program that displays the front panel of cisco devices remotely (in this case a 3560 switch). So I need to read the status of each port via snmp and turn on the LED on my GUI accordingly.
After some search I came to use the "ifOperStatus" with OID 1.3.6.1.2.1.2.2.1.8.

But the problem is that this OID returns "1:up" as soon as a cable is plugged into the port and does not reflect the different status the port might have including:

Blinking green: Link has activity

Solid amber: Port is faulty

etc,

Any clue or hint on which OIDs I should use?

Best Answer

Have you looked at this OID ?

Specific Object Information 
Object  clsPortLedStatus
OID 1.3.6.1.4.1.9.5.11.1.7.1.1.3
Type    INTEGER
Permission  read-only
Status  current
Values  1 : unknown
2 : on
3 : off
MIB CISCO-RHINO-MIB 
Description "Indicates the status of the LED.
Unknown(1) indicates either the LED status is 
not supported or the status is none of the
defined."

And the related :

Specific Object Information 
Object  clsPortLedType
OID 1.3.6.1.4.1.9.5.11.1.7.1.1.2
Type    INTEGER
Permission  read-only
Status  current
Values  1 : ledTx
2 : ledRx
3 : ledLink
4 : led100Mbps
5 : ledRxLoss
6 : ledRxFullOut
7 : ledRxSync
8 : ledFullDuplex
9 : ledOptDetect

Unfortunately the supported images/platforms are very limited : http://tools.cisco.com/ITDIT/MIBS/AdvancedSearch?MibSel=4682

I would say fake it, for link activity. Poll interface stats (bytes or frames or packets in or out) and make the light in your application blink as long as either is increasing.
(Though I suppose technically some control traffic might or might not cause the physical LED to blink - for example, do BPDUs alone count towards link activity ? I do not know - I can check later, if you'd like.)

I searched and browsed the SNMP Object Navigator (http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en) last night for you, but found nothing suitable (not to say it doesn't exist), and any potentially interesting ones were marked as inaccessible ("Permission not-accessible").

If you're feeling especially crafty, and want the utmost accuracy, you could probably setup an ambient light sensor / "light to frequency converter" in front of each crucial port LED, and code to have that info passed to your application.
But that's not scalable, so it's probably easier to fake it.

EDIT, ROUND 2 !

How about :

"This object is used to indicate the current color of a LED."

Object  c2900PortVisualIndicator
OID 1.3.6.1.4.1.9.9.87.1.4.1.1.24
Type    INTEGER
Permission  read-only
Status  current
Values  1 : notused
2 : black
3 : amber
4 : green
MIB CISCO-C2900-MIB
Description "This object is used to indicate the current color of
a LED. If a LED is flashing, the value of this object will
represent the color of the LED at that instant in time.
The following conventions indicate port status:
Link healthy returns green(4)
Link activity usually green(4), but may return black(2).
Link faulty alternating green(4)/amber(3)
Port disabled returns amber(3)"

"The color of the LED."

Object  ceExtEntityLEDColor
OID 1.3.6.1.4.1.9.9.195.1.3.1.2
Type    INTEGER
Permission  read-only
Status  mandatory
Values  1 : off
2 : green
3 : amber
4 : red
MIB CISCO-ENTITY-EXT-MIB-V1SMI
Description The color of the LED.

"An integer value that describes the color of the display"

Type    CDisplayColor
Status  current
Values  1 : unknown
2 : white
3 : red
4 : green
5 : yellow
6 : amber
7 : blue
8 : greenAndAmber
MIB CISCO-ENTITY-DISPLAY-MIB
Description "An integer value that describes the color of the display.

'greenAndAmber' - Indicates that the display color toggles between green and amber."

As well as,
mrStackUnitBasePortVisualIndicatorGreenMap,
mrStackUnitBasePortVisualIndicatorAmberMap,
mrStackUnitExpansionPortVisualIndicatorGreenMap,
mrStackUnitExpansionPortVisualIndicatorAmberMap, and
mrStackUnitActivityVisualIndicator

all under mrStackUnitEntry.

For ATM :
ciscoAtmIfXmitLed
ciscoAtmIfRecvLed
ciscoAtmIfCdLed

Finally, this nugget, from "CISCO-WIRELESS-EXP-MIB" :
"When the CISCO-LED-MIB.my becomes available and supports the functionality the LED group needs, the LED group will be migrated into that."

Apparently mention of a MIB that never came to be.