extends:
  - _system-base.yaml
  - _std-host-resources-mib-feat-base.yaml
  - _std-if-mib.yaml

selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.23695
        - 1.3.6.1.4.1.23695.*

metadata:
  device:
    fields:
      vendor:
        value: "Peplink"
      type:
        value: "Router"

metric_tags:
  - tag: _peplink_device_model
    OID: 1.3.6.1.4.1.23695.200.1.1.1.1.1
    symbol: deviceModel
  - tag: _peplink_device_serial_number
    OID: 1.3.6.1.4.1.23695.200.1.1.1.1.2
    symbol: deviceSerialNumber
  - tag: _peplink_device_firmware_version
    OID: 1.3.6.1.4.1.23695.200.1.1.1.1.3
    symbol: deviceFirmwareVersion
  - tag: _peplink_bal_firmware
    OID: 1.3.6.1.4.1.23695.1.1.1.1
    symbol: balFirmware
  - tag: _peplink_bal_serial_number
    OID: 1.3.6.1.4.1.23695.1.1.1.2
    symbol: balSerialNumber

# PEPLINK-DEVICE
# https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/peplink/PEPLINK-DEVICE

metrics:
  - MIB: PEPLINK-DEVICE
    symbol:
      name: cpu.usage
      OID: 1.3.6.1.4.1.23695.200.1.1.1.3.1.0
      chart_meta:
        family: 'System/CPU/Usage'
        description: The current CPU utilization
        unit: "%"
  - MIB: PEPLINK-DEVICE
    symbol:
      name: memory.total
      OID: 1.3.6.1.4.1.23695.200.1.1.1.3.2.0
      chart_meta:
        family: 'System/Memory/Total'
        description: Total memory
        unit: "By"
  - MIB: PEPLINK-DEVICE
    symbol:
      name: memory.usage
      OID: 1.3.6.1.4.1.23695.200.1.1.1.3.3.0
      chart_meta:
        family: 'System/Memory/Usage'
        description: Memory usage
        unit: "%"
  - MIB: PEPLINK-DEVICE
    symbol:
      name: peplink.deviceTemperatureCelsius
      OID: 1.3.6.1.4.1.23695.200.1.1.1.4.4.1.0
      chart_meta:
        family: 'Hardware/Temperature/Value'
        description: Device temperature celsius
        unit: "Cel"
  - MIB: PEPLINK-DEVICE
    symbol:
      name: peplink.deviceTemperatureFahrenheit
      OID: 1.3.6.1.4.1.23695.200.1.1.1.4.4.2.0
      chart_meta:
        family: 'Hardware/Temperature/Value'
        description: Device temperature fahrenheit
        unit: "degF"

  - MIB: PEPLINK-DEVICE
    table:
      OID: 1.3.6.1.4.1.23695.200.1.1.1.4.1
      name: devicePSUTable
    symbols:
      - name: peplink.devicePSUPercentage
        OID: 1.3.6.1.4.1.23695.200.1.1.1.4.1.1.5
        chart_meta:
          family: 'Hardware/Power/Usage'
          description: Device psu percentage
          unit: "%"
      - OID: 1.3.6.1.4.1.23695.200.1.1.1.4.1.1.2
        name: devicePSUStatus
        chart_meta:
          family: 'Hardware/Power/Status'
          description: Device psu status
          unit: "{status}"
        mapping:
          0: error
          1: on
    metric_tags:
      - tag: device_psu_id
        symbol:
          OID: 1.3.6.1.4.1.23695.200.1.1.1.4.1.1.1
          name: devicePSUId

  - MIB: PEPLINK-DEVICE
    table:
      OID: 1.3.6.1.4.1.23695.200.1.1.1.4.2
      name: deviceFanTable
    symbols:
      - name: peplink.deviceFanSpeed
        OID: 1.3.6.1.4.1.23695.200.1.1.1.4.2.1.3
        chart_meta:
          family: 'Hardware/Fan/Speed'
          description: Device fan speed
          unit: "{revolution}/min"
      - OID: 1.3.6.1.4.1.23695.200.1.1.1.4.2.1.2
        name: deviceFanStatus
        chart_meta:
          family: 'Hardware/Fan/Status'
          description: Device fan status
          unit: "{status}"
        mapping:
          0: error
          1: on
    metric_tags:
      - tag: device_fan_id
        symbol:
          OID: 1.3.6.1.4.1.23695.200.1.1.1.4.2.1.1
          name: deviceFanId

  - MIB: PEPLINK-DEVICE
    table:
      OID: 1.3.6.1.4.1.23695.200.1.1.1.4.3
      name: devicePowerSourceTable
    symbols:
      - OID: 1.3.6.1.4.1.23695.200.1.1.1.4.3.1.3
        name: devicePowerSourceStatus
        chart_meta:
          family: 'Hardware/Power/Source/Status'
          description: Power source status
          unit: "{status}"
        mapping:
          0: noCableDetected
          1: connected
    metric_tags:
      - tag: device_power_source_id
        symbol:
          name: devicePowerSourceId
          OID: 1.3.6.1.4.1.23695.200.1.1.1.4.3.1.1
      - tag: device_power_source_name
        symbol:
          name: devicePowerSourceName
          OID: 1.3.6.1.4.1.23695.200.1.1.1.4.3.1.2

  # - MIB: PEPLINK-BALANCE-MIB # TODO: Handle string for "up"/"down"
  #   symbol:
  #     name: peplink.balLanStatus
  #     OID: 1.3.6.1.4.1.23695.1.1.1.6.1
  #     format: TODO_handle_conversion_to_one

  - MIB: PEPLINK-BALANCE-MIB
    table:
      OID: 1.3.6.1.4.1.23695.1.1.2.2
      name: linkTable
    symbols:
      - name: peplink.linkThroughputIn
        OID: 1.3.6.1.4.1.23695.1.1.2.2.1.4
        chart_meta:
          family: 'Network/Link/Throughput/Total/In'
          description: Number of inbound packets discarded to free buffer space
          unit: "{packet}/s"
      - name: peplink.linkThroughputOut
        OID: 1.3.6.1.4.1.23695.1.1.2.2.1.5
        chart_meta:
          family: 'Network/Link/Throughput/Total/Out'
          description: Number of outbound packets discarded to free buffer space
          unit: "{packet}/s"
      - name: peplink.linkDataTransferred
        OID: 1.3.6.1.4.1.23695.1.1.2.2.1.6
        chart_meta:
          family: 'Network/Link/Data/Total'
          description: Number of bytes transferred through
          unit: "By/s"
    metric_tags:
      - tag: link_conn_num
        symbol:
          name: linkConnNum
          OID: 1.3.6.1.4.1.23695.1.1.2.2.1.1
      - tag: link_name
        symbol:
          name: linkName
          OID: 1.3.6.1.4.1.23695.1.1.2.2.1.2

  - MIB: PEPLINK-BALANCE-MIB
    table:
      OID: 1.3.6.1.4.1.23695.1.1.3
      name: wanUsageTable
    symbols:
      - name: peplink.wanUsageThroughputIn
        OID: 1.3.6.1.4.1.23695.1.1.3.1.2
        chart_meta:
          family: 'Network/WAN/Throughput/Total/In'
          description: Number of inbound packets discarded to free buffer space
          unit: "{packet}/s"
      - name: peplink.wanUsageThroughputOut
        OID: 1.3.6.1.4.1.23695.1.1.3.1.3
        chart_meta:
          family: 'Network/WAN/Throughput/Total/Out'
          description: Number of outbound packets discarded to free buffer space
          unit: "{packet}/s"
      - name: peplink.wanUsageDataTransferred
        OID: 1.3.6.1.4.1.23695.1.1.3.1.4
        chart_meta:
          family: 'Network/WAN/Data/Total'
          description: Number of bytes transferred through
          unit: "By/s"
    metric_tags:
      - tag: wan_usage_index
        symbol:
          name: wanUsageIndex
          OID: 1.3.6.1.4.1.23695.1.1.3.1.1
