extends:
  - tripplite.yaml

selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.850.1.1.1 # Tripp Lite PDU

metadata:
  device:
    fields:
      type:
        value: "PDU"

# TRIPPLITE-PRODUCTS
# https://mibbrowser.online/mibdb_search.php?mib=TRIPPLITE-PRODUCTS
# https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/tripplite/TRIPPLITE-PRODUCTS

metrics:
  - MIB: TRIPPLITE-PRODUCTS
    table:
      OID: 1.3.6.1.4.1.850.1.1.1.2
      name: tlpDeviceTable
    symbols:
      - OID: 1.3.6.1.4.1.850.1.1.1.2.1.10
        name: tlpDeviceStatus
        chart_meta:
          description: The currently most critical alarm status for the device
          family: 'Hardware/Device/Alarm/Status'
          unit: "{status}"
        mapping:
          0: none
          1: critical
          2: warning
          3: info
          4: status
          5: offline
          6: custom
          7: configuration
    metric_tags:
      - tag: tlp_device_index
        index: 1
      - tag: _tlp_device_manufacturer
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.1.2.1.4
          name: tlpDeviceManufacturer
      - tag: _tlp_device_model
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.1.2.1.5
          name: tlpDeviceModel
      - tag: _tlp_device_name # A user-supplied name for the device.
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.1.2.1.6
          name: tlpDeviceName
      - tag: _tlp_device_location # A user-supplied location for the device.
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.1.2.1.8
          name: tlpDeviceLocation
      - tag: _tlp_device_region # A user-supplied region for the device.
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.1.2.1.9
          name: tlpDeviceRegion

  - MIB: TRIPPLITE-PRODUCTS
    table:
      OID: 1.3.6.1.4.1.850.1.1.3.2.2.1
      name: tlpPduDeviceTable
    symbols:
      - OID: 1.3.6.1.4.1.850.1.1.3.2.2.1.1.6
        name: tlpPduDeviceTemperatureC
        chart_meta:
          description: The ambient temperature at or near the PDU casing.
          family: 'Environment/Temperature/Value'
          unit: "Cel"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.2.1.1.7
        name: tlpPduDeviceTemperatureF
        chart_meta:
          description: The ambient temperature at or near the PDU casing.
          family: 'Environment/Temperature/Value'
          unit: "degF"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.2.1.1.8
        name: tlpPduDevicePhaseImbalance
        chart_meta:
          description: The percentage of imbalance of the three phases.
          family: 'PowerFlow/Phase/Imbalance/Value'
          unit: "%"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.2.1.1.9
        name: tlpPduDeviceOutputPowerTotal
        chart_meta:
          description: The AC output total power for all circuits.
          family: 'PowerFlow/Output/Total'
          unit: "W"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.2.1.1.1
        name: tlpPduDeviceMainLoadState
        chart_meta:
          description: The current state of the main output of the device
          family: 'Hardware/Output/Main/Status'
          unit: "{status}"
        mapping:
          0: unknown
          1: off
          2: on
    metric_tags:
      - tag: tlp_device_index
        index: 1
      - symbol:
          OID: 1.3.6.1.4.1.850.1.1.3.2.2.1.1.11
          name: tlpPduDeviceOutputCurrentPrecision
        tag: _tlp_pdu_device_output_current_precision
        mapping:
          0: whole_number
          1: tenths
          2: hundredths

  - MIB: TRIPPLITE-PRODUCTS
    table:
      OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1
      name: tlpPduOutputTable
    symbols:
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1.1.4
        name: tlpPduOutputVoltage
        chart_meta:
          description: The magnitude of the present output voltage for a given output line.
          family: 'PowerFlow/Output/Phase/Voltage/Value'
          unit: "V"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1.1.5
        name: tlpPduOutputCurrent
        chart_meta:
          description: The output current, in hundreths of amps, for a given phase.
          family: 'PowerFlow/Output/Phase/Current/Value'
          unit: "mA"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1.1.10
        name: tlpPduOutputSource
        chart_meta:
          description: The present source of output power.
          family: 'PowerFlow/Output/Source/Status'
          unit: "{status}"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1.1.11
        name: tlpPduOutputFrequency
        chart_meta:
          description: The present output frequency.
          family: 'PowerFlow/Output/Frequency/Value'
          unit: "Hz"
    # TODO: Check out metric_tags with symbols having mappings and/or expressing states/statuses. Need to convert to metrics.
    metric_tags:
      - tag: tlp_device_index
        index: 1 # tlpDeviceIndex
      - tag: tlp_pdu_output_index
        index: 2 # tlpPduOutputIndex
      - tag: tlp_pdu_output_phase
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1.1.2
          name: tlpPduOutputPhase
        mapping:
          1: phase1
          2: phase2
          3: phase3
      - tag: tlp_pdu_output_phase_type
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.3.2.3.2.1.1.3
          name: tlpPduOutputPhaseType
        mapping:
          0: phase_to_neutral
          1: phase_to_phase

  - MIB: TRIPPLITE-PRODUCTS
    table:
      OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1
      name: tlpPduOutletTable
    symbols:
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1.1.4
        name: tlpPduOutletState
        chart_meta:
          description: The current state of the outlet.
          family: 'Hardware/Outlet/Status'
          unit: "{status}"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1.1.7
        name: tlpPduOutletVoltage
        chart_meta:
          description: The magnitude of the present output voltage for a given outlet.
          family: 'PowerFlow/Outlet/Voltage/Value'
          unit: "V"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1.1.8
        name: tlpPduOutletCurrent
        chart_meta:
          description: The present output current, in hundreths of amps, of a given outlet.
          family: 'PowerFlow/Outlet/Current/Value'
          unit: "mA"
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1.1.9
        name: tlpPduOutletPower
        chart_meta:
          description: The output power of a given outlet.
          family: 'PowerFlow/Outlet/Active'
          unit: "W"
    metric_tags:
      - tag: tlp_pdu_outlet_name
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1.1.2
          name: tlpPduOutletName
      - tag: _tlp_pdu_outlet_description
        symbol:
          OID: 1.3.6.1.4.1.850.1.1.3.2.3.3.1.1.3
          name: tlpPduOutletDescription

  - MIB: TRIPPLITE-PRODUCTS
    table:
      OID: 1.3.6.1.4.1.850.1.1.3.2.3.5.1
      name: tlpPduBreakerTable
    symbols:
      - OID: 1.3.6.1.4.1.850.1.1.3.2.3.5.1.1.2
        name: tlpPduBreakerStatus
        chart_meta:
          description: The current state of the bank breaker
          family: 'Hardware/Breaker/Status'
          unit: "{status}"
        mapping:
          0: open
          1: closed
          2: not_installed
    metric_tags:
      - tag: tlp_device_index
        index: 1 # tlpDeviceIndex
      - tag: tlp_pdu_breaker_index
        index: 2 # tlpPduBreakerIndex
      - symbol:
          OID: 1.3.6.1.4.1.850.1.1.3.2.3.5.1.1.2
          name: tlpPduBreakerStatus
        tag: tlp_pdu_breaker_status
        mapping:
          0: open
          1: closed
          2: not_installed

  - MIB: TRIPPLITE-PRODUCTS
    symbol:
      OID: 1.3.6.1.4.1.850.1.3.1.0
      name: tlpAlarmsPresent
      chart_meta:
        description: The present number of active alarm conditions.
        family: 'System/Alarm/Active/Count'
        unit: "{alarm}"

  - MIB: TRIPPLITE-PRODUCTS
    table:
      OID: 1.3.6.1.4.1.850.1.3.2
      name: tlpAlarmTable
    symbols:
      - OID: 1.3.6.1.4.1.850.1.3.2.1.8
        name: tlpAlarmState
        chart_meta:
          description: The current state of this alarm condition
          family: 'System/Alarm/Condition/Status'
          unit: "{status}"
        mapping:
          1: active
          2: inactive
      - OID: 1.3.6.1.4.1.850.1.3.2.1.9
        name: tlpAlarmAcknowledged
        chart_meta:
          description: Denotes whether the alarm condition has been acknowledged
          family: 'System/Alarm/Condition/Acknowledgment/Status'
          unit: "{status}"
        mapping:
          1: not_acknowledged
          2: acknowledged
    metric_tags:
      - tag: tlp_alarm_index
        index: 1 # tlpAlarmId
      - tag: _tlp_alarm_descr
        symbol:
          OID: 1.3.6.1.4.1.850.1.3.2.1.2
          name: tlpAlarmDescr
