# Metrics mixin for Cisco Catalyst devices.
# Stored in a separate file for reuse within the cisco-3850 compat shim.

# Example sysDescr:
#   "Cisco Systems WS-C6509.Cisco Catalyst Operating System Software, Version 5.5(8).Copyright (c) 1995-2001 by Cisco Systems."
#   "Cisco IOS Software, IOS-XE Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 03.06.06E RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2016 by Cisco Systems, Inc. Compiled Sat 17-Dec-"

metadata:
  device:
    fields:
      serial_number:
        symbol:
          # Cisco Catalyst devices are using CISCO-STACK-MIB
          # Source1: http://www.circitor.fr/Mibs/Html/C/CISCO-STACK-MIB.php
          #   "This MIB provides configuration and runtime status for chassis, modules, ports, etc. on the Catalyst systems."
          # Source2: chassisSerialNumberString is present for this device:
          #   Cisco Systems WS-C6509.Cisco Catalyst Operating System Software, Version 5.5(8).Copyright (c) 1995-2001 by Cisco Systems.
          MIB: CISCO-STACK-MIB
          OID: 1.3.6.1.4.1.9.5.1.2.19.0
          name: chassisSerialNumberString

metrics:
  - MIB: CISCO-ENTITY-SENSOR-MIB   # TODO: this is not Catalyst-specific, need to add to other Cisco devices
    table:
      OID: 1.3.6.1.4.1.9.9.91.1.1.1
      name: entSensorValueTable
    symbols:
      - OID: 1.3.6.1.4.1.9.9.91.1.1.1.1.4
        name: entSensorValue # Do not change this name — required by transformEntitySensorValue for matching and renaming logic
        chart_meta:
          description: Most recent measurement obtained by the agent for this sensor
          family: 'Hardware/Sensor/Value'
          unit: "1"
        transform: |
          {{- transformEntitySensorValue .Metric -}}
    metric_tags:
      - tag: sensor_index
        index: 1
      - tag: _ent_phys_descr
        MIB: ENTITY-MIB
        table: entPhysicalTable
        symbol:
          OID: 1.3.6.1.2.1.47.1.1.1.1.2
          name: entPhysicalDescr
      - tag: rm:sensor_type # needed for transform
        symbol:
          OID: 1.3.6.1.4.1.9.9.91.1.1.1.1.1
          name: entSensorType
      - tag: rm:sensor_scale # needed for transform
        symbol:
          OID: 1.3.6.1.4.1.9.9.91.1.1.1.1.2
          name: entSensorScale
      - tag: rm:sensor_precision # needed for transform
        symbol:
          OID: 1.3.6.1.4.1.9.9.91.1.1.1.1.3
          name: entSensorPrecision

  - MIB: CISCO-IF-EXTENSION-MIB # TODO: this is not Catalyst-specific, need to add to other Cisco devices
    table:
      OID: 1.3.6.1.4.1.9.9.276.1.1.1
      name: cieIfPacketStatsTable
    symbols:
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.1
        name: cieIfLastInTime
        chart_meta:
          description: "Elapsed time in milliseconds since last protocol input packet was received"
          family: 'Network/Interface/Activity/In'
          unit: "ms"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.2
        name: cieIfLastOutTime
        chart_meta:
          description: "Elapsed time in milliseconds since last protocol output packet was transmitted"
          family: 'Network/Interface/Activity/Out'
          unit: "ms"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.10
        name: cieIfInputQueueDrops
        chart_meta:
          description: "Number of input packets which were dropped"
          family: 'Network/Interface/Queue/Drops/In'
          unit: "{drop}/s"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.11
        name: cieIfOutputQueueDrops
        chart_meta:
          description: "Number of output packets dropped by the interface"
          family: 'Network/Interface/Queue/Drops/Out'
          unit: "{drop}/s"
      # L1/L2 error counters — primary debug signals for cabling/SFP/duplex issues
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.4
        name: cieIfInRuntsErrs
        chart_meta:
          description: "Number of runt packets received (frames smaller than 64 bytes)"
          family: 'Network/Interface/Errors/L1'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.5
        name: cieIfInGiantsErrs
        chart_meta:
          description: "Number of giant packets received (frames larger than MTU)"
          family: 'Network/Interface/Errors/L1'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.6
        name: cieIfInFramingErrs
        chart_meta:
          description: "Number of framing error packets received"
          family: 'Network/Interface/Errors/L1'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.7
        name: cieIfInOverrunErrs
        chart_meta:
          description: "Number of overrun error packets received (hardware buffer exhaustion)"
          family: 'Network/Interface/Errors/L1'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.8
        name: cieIfInIgnored
        chart_meta:
          description: "Number of input packets ignored by the interface"
          family: 'Network/Interface/Errors/L1'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.9.9.276.1.1.1.1.9
        name: cieIfInAbortErrs
        chart_meta:
          description: "Number of input packets aborted"
          family: 'Network/Interface/Errors/L1'
          unit: "{error}/s"
    metric_tags:
      - tag: interface
        MIB: IF-MIB
        table: ifXTable
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.1
          name: ifName

  # STP topology change detection (BRIDGE-MIB scalars)
  - MIB: BRIDGE-MIB
    symbol:
      OID: 1.3.6.1.2.1.17.2.4.0
      name: dot1dStpTimeSinceTopologyChange
      scale_factor: 0.01
      chart_meta:
        description: Time since the last STP topology change was detected
        family: 'Network/Bridge/STP/TopologyChange'
        unit: "s"
  - MIB: BRIDGE-MIB
    symbol:
      OID: 1.3.6.1.2.1.17.2.5.0
      name: dot1dStpTopChanges
      chart_meta:
        description: Rate of STP topology changes detected
        family: 'Network/Bridge/STP/TopologyChange'
        unit: "{change}/s"
