# Hot Standby Router Protocol (HSRP) metrics for Cisco devices.
# MIB: CISCO-HSRP-MIB (1.3.6.1.4.1.9.9.106)
# Monitors first-hop gateway redundancy: group state, priority, active/standby routers.
# Universal across IOS, IOS-XE, and NX-OS.

metrics:
  - MIB: CISCO-HSRP-MIB
    table:
      OID: 1.3.6.1.4.1.9.9.106.1.2.1
      name: cHsrpGrpTable
    symbols:
      - OID: 1.3.6.1.4.1.9.9.106.1.2.1.1.15
        name: cHsrpGrpStandbyState
        chart_meta:
          description: Current HSRP state machine state for this group
          family: 'Network/HSRP/Group/State'
          unit: "{status}"
        mapping:
          1: initial
          2: learn
          3: listen
          4: speak
          5: standby
          6: active
      - OID: 1.3.6.1.4.1.9.9.106.1.2.1.1.3
        name: cHsrpGrpPriority
        chart_meta:
          description: HSRP group priority (higher wins active role election)
          family: 'Network/HSRP/Group/Priority'
          unit: "{priority}"
    metric_tags:
      # Index is (ifIndex, cHsrpGrpNumber) — extract ifIndex for interface name join
      - tag: interface
        table: ifXTable
        MIB: IF-MIB
        symbol:
          OID: 1.3.6.1.2.1.31.1.1.1.1
          name: ifName
        index_transform:
          - start: 0
            end: 0
      - tag: hsrp_group
        index: 2
      - tag: _hsrp_virtual_ip
        symbol:
          OID: 1.3.6.1.4.1.9.9.106.1.2.1.1.11
          name: cHsrpGrpVirtualIpAddr
          format: ip_address
      - tag: _hsrp_active_router
        symbol:
          OID: 1.3.6.1.4.1.9.9.106.1.2.1.1.13
          name: cHsrpGrpActiveRouter
          format: ip_address
      - tag: _hsrp_standby_router
        symbol:
          OID: 1.3.6.1.4.1.9.9.106.1.2.1.1.14
          name: cHsrpGrpStandbyRouter
          format: ip_address
      - tag: _hsrp_preempt
        symbol:
          OID: 1.3.6.1.4.1.9.9.106.1.2.1.1.4
          name: cHsrpGrpPreempt
        mapping:
          1: "true"
          2: "false"
