prometheus / snmp_exporter

SNMP Exporter for Prometheus
Apache License 2.0
1.71k stars 630 forks source link

FR: PhysAddress type for Fibre Channel/SCSI-WWNs #607

Open svalouch opened 3 years ago

svalouch commented 3 years ago

Fibre Channel and other storage-related communication protocols use longer physical addresses, namely 64 bits instead of 48 bits as used for MAC addresses. The existing PhysAddress48 type truncates the WWN to 48 bits, rendering it unusable. There are 16 byte / 128 bit WWNs, but I haven't encountered any of those yet. Wikipedia article: World Wide Name.

Device is a Brocade 5100 or 6510 FC-switch using the Brocade SW-MIB. The swFCPortWwn is defined as follows:

  swFCPortWwn       OBJECT-TYPE
    SYNTAX      OCTET STRING (SIZE(8))
    MAX-ACCESS      read-only
    STATUS      current
    DESCRIPTION "The World_wide_Name of the Fibre Channel port.
        The contents of an instance are in the IEEE extended format
        as specified in FC-PH; the 12-bit port identifier represents
        the port number within the switch."
  ::= { swFCPortEntry 34 }

snmpwalk returns the following for the OID (except, port number 1):

SW-MIB::swFCPortWwn.1 = Hex-STRING: 20 00 00 01 33 AA 15 D7

Configuration used for testing:

---
brocade_fc:
  walk:
  - 1.3.6.1.4.1.1588.2.1.1.1.6.2.1.34
  metrics:
  - name: swFCPortWwn
    oid: 1.3.6.1.4.1.1588.2.1.1.1.6.2.1.34
    type: OctetString
    help: The World_wide_Name of the Fibre Channel port - 1.3.6.1.4.1.1588.2.1.1.1.6.2.1.34
    indexes:
    - labelname: swFCPortIndex
      type: gauge

This yields the following output when queried:

swFCPortWwn{swFCPortIndex="1",swFCPortWwn="0x2000000133AA15D7"} = 1

If I change the type to PhysAddress48, it looks as follows, which misses the last two elements:

swFCPortWwn{swFCPortIndex="1",swFCPortWwn="20:00:00:01:33:AA"} = 1

The output I want:

swFCPortWwn{swFCPortIndex="1",swFCPortWwn="20:00:00:01:33:AA:15:D7"} = 1

I guess the easiest way would be to add a PhysAddress64 data type that has a higher length limit. The other way would be to add a type that can contain both 48 and 64 bit addresses. The PostgreSQL macaddr8 data type documentation talks about how to represent one in the other, I personally don't think that something like that would be worth implementing and the exporter should simply reformat the existing data according to the type set by the user. I don't know if it is possible for devices to return either 64 or 48 bit values if there's a FC over IP or IP over FC scenario and I can't test this, i.e. if there's any vendor defining a long OCTET STRING and depending on the usage of the specific port return a shorter or longer value.

Version

snmp-exporter 0.19.0

MIB used

Brocade SW-MIB An outdated, but still usable version: https://github.com/librenms/librenms/blob/master/mibs/brocade/SW-MIB#L1478

SuperQ commented 3 years ago

Seems like this could be PhysAddress TEXTUAL-CONVENTION

From SNMPv2-TC:

PhysAddress ::= TEXTUAL-CONVENTION
    DISPLAY-HINT "1x:"
    STATUS       current
    DESCRIPTION
            "Represents media- or physical-level addresses."
    SYNTAX       OCTET STRING

If we could automatically handle the length, it would simplify things.