extends:
  - _system-base.yaml
  - _std-if-mib.yaml

selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.6574.*

metadata:
  device:
    fields:
      vendor:
        value: "Synology"
      type:
        value: "Storage"

metric_tags:
  - tag: synology_model_name
    OID: 1.3.6.1.4.1.6574.1.5.1.0
    symbol: modelName
  - tag: synology_serial_number
    OID: 1.3.6.1.4.1.6574.1.5.2.0
    symbol: serialNumber
  - tag: synology_version
    OID: 1.3.6.1.4.1.6574.1.5.3.0
    symbol: version

# 1. UCD-SNMP-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=UCD-SNMP-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/net-snmp/UCD-SNMP-MIB
# 2. HOST-RESOURCES-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=HOST-RESOURCES-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/rfc/HOST-RESOURCES-MIB
# 3. SYNOLOGY-SYSTEM-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-SYSTEM-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-SYSTEM-MIB
# 4. SYNOLOGY-DISK-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-DISK-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-DISK-MIB
# 5. SYNOLOGY-RAID-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-RAID-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-RAID-MIB
# 6. SYNOLOGY-SMART-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-SMART-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-SMART-MIB
# 7. SYNOLOGY-SERVICES-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-SERVICES-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-SERVICES-MIB
# 8. SYNOLOGY-STORAGEIO-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-STORAGEIO-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-STORAGEIO-MIB
# 9. SYNOLOGY-SPACEIO-MIB
#    https://mibbrowser.online/mibdb_search.php?mib=SYNOLOGY-SPACEIO-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-SPACEIO-MIB
# 10. SYNOLOGY-GPUINFO-MIB
#    https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/synology/SYNOLOGY-GPUINFO-MIB

metrics:
  - MIB: UCD-SNMP-MIB
    symbol:
      name: cpu.usage
      OID: 1.3.6.1.4.1.2021.10.1.5.1
      chart_meta:
        description: The 1,5 and 15 minute load averages
        family: 'System/CPU/Load'
        unit: "{load_average}"
  # TODO support for units like this is not yet implemented
  # - MIB: HOST-RESOURCES-MIB
  #   symbol:
  #     name: memory.total
  #     OID: 1.3.6.1.2.1.25.2.3.1.6.1 # hrStorageUsed.1 = Physical memory
  #     chart_meta:
  #       description: The amount of the storage represented by this entry that is allocated, in units of hrStorageAllocationUnits
  #       family: "System/Memory/Used"
  #       unit: "By"
  # - MIB: HOST-RESOURCES-MIB
  #   symbol:
  #     OID: 1.3.6.1.2.1.25.2.3.1.6.6 # hrStorageUsed.6 = Memory buffers
  #     name: hrMemoryBuffers
  #     chart_meta:
  #       description: The amount of the storage represented by this entry that is allocated, in units of hrStorageAllocationUnits
  #       family: "System/Memory/Buffer"
  #       unit: "By"
  # - MIB: HOST-RESOURCES-MIB
  #   symbol:
  #     OID: 1.3.6.1.2.1.25.2.3.1.6.7 # hrStorageUsed.7 = Cached memory
  #     name: hrCachedMemory
  #     chart_meta:
  #       description: The amount of the storage represented by this entry that is allocated, in units of hrStorageAllocationUnits
  #       family: "System/Memory/Cache"
  #       unit: "By"
  - MIB: SYNOLOGY-SYSTEM-MIB
    symbol:
      name: synology.system.systemStatus
      OID: 1.3.6.1.4.1.6574.1.1.0
      chart_meta:
        description: System status
        family: 'System/Status'
        unit: "{status}"
      mapping:
        normal: 1
        failed: 2
  - MIB: SYNOLOGY-SYSTEM-MIB
    symbol:
      name: synology.system.temperature
      OID: 1.3.6.1.4.1.6574.1.2.0
      chart_meta:
        description: The temperature of Disk Station
        family: 'Hardware/Temperature/Value'
        unit: "Cel"
  - MIB: SYNOLOGY-SYSTEM-MIB
    symbol:
      name: synology.system.powerStatus
      OID: 1.3.6.1.4.1.6574.1.3.0
      chart_meta:
        description: Power status
        family: 'Hardware/Power/Status'
        unit: "{status}"
      mapping:
        1: normal
        2: failed
  - MIB: SYNOLOGY-SYSTEM-MIB
    symbol:
      name: synology.system.systemFanStatus
      OID: 1.3.6.1.4.1.6574.1.4.1.0
      chart_meta:
        description: Fan status
        family: 'Hardware/Fan/Status/System'
        unit: "{status}"
      mapping:
        1: normal
        2: failed
  - MIB: SYNOLOGY-SYSTEM-MIB
    symbol:
      name: synology.system.cpuFanStatus
      OID: 1.3.6.1.4.1.6574.1.4.2.0
      chart_meta:
        description: CPU fan status
        family: 'Hardware/Fan/Status/CPU'
        unit: "{status}"
      mapping:
        1: normal
        2: failed
  - MIB: SYNOLOGY-SYSTEM-MIB
    symbol:
      name: synology.system.upgradeAvailable
      OID: 1.3.6.1.4.1.6574.1.5.4.0
      chart_meta:
        description: System upgrade availability
        family: 'System/Upgrade/Status'
        unit: "{status}"
      mapping:
        1: available
        2: unavailable
        3: connecting
        4: disconnected
        5: others
  - MIB: SYNOLOGY-DISK-MIB
    table:
      name: diskTable
      OID: 1.3.6.1.4.1.6574.2.1
    symbols:
      - name: synology.diskTemperature
        OID: 1.3.6.1.4.1.6574.2.1.1.6
        chart_meta:
          description: The temperature of each disk uses Celsius degree
          family: 'Hardware/Disk/Temperature/Value'
          unit: "Cel"
      - OID: 1.3.6.1.4.1.6574.2.1.1.5
        name: synology.diskStatus
        chart_meta:
          description: Disk status
          family: 'Hardware/Disk/Status'
          unit: "{status}"
        mapping:
          1: normal
          2: initialized
          3: not_initialized
          4: system_partition_failed
          5: crashed
    metric_tags:
      - tag: synology_disk_id
        symbol:
          name: synology.diskID
          OID: 1.3.6.1.4.1.6574.2.1.1.2
      - tag: synology_disk_model
        symbol:
          name: synology.diskModel
          OID: 1.3.6.1.4.1.6574.2.1.1.3
      - tag: synology_disk_type
        symbol:
          name: synology.diskType
          OID: 1.3.6.1.4.1.6574.2.1.1.4

  - MIB: SYNOLOGY-RAID-MIB
    table:
      name: raidTable
      OID: 1.3.6.1.4.1.6574.3.1
    symbols:
      - name: synology.raidFreeSize
        OID: 1.3.6.1.4.1.6574.3.1.1.4
        metric_type: monotonic_count
        chart_meta:
          description: The free size of raid
          family: 'Storage/RAID/Free'
          unit: "By"
      - name: synology.raidTotalSize
        OID: 1.3.6.1.4.1.6574.3.1.1.5
        metric_type: monotonic_count
        chart_meta:
          description: The total size of raid
          family: 'Storage/RAID/Total'
          unit: "By"
      - OID: 1.3.6.1.4.1.6574.3.1.1.3
        name: synology.raid.raidStatus
        chart_meta:
          description: Raid status
          family: 'Storage/RAID/Status'
          unit: "{status}"
        mapping:
          1: normal
          2: repairing
          3: migrating
          4: expanding
          5: deleting
          6: creating
          7: raid_syncing
          8: raid_parity_checking
          9: raid_assembling
          10: canceling
          11: degrade
          12: crashed
          13: data_scrubbing
          14: raid_deploying
          15: raid_un_deploying
          16: raid_mount_cache
          17: raid_unmount_cache
          18: raid_expanding_unfinished_shr
          19: raid_convert_shr_to_pool
          20: raid_migrate_shr1_to_shr2
          21: raid_unknown_status
          # full list of mappings here https://global.download.synology.com/download/Document/Software/DeveloperGuide/Firmware/DSM/All/enu/Synology_DiskStation_MIB_Guide.pdf
    metric_tags:
      - tag: synology_raid_index
        index: 1
      - tag: synology_raid_name
        symbol:
          name: synology.raid.raidName
          OID: 1.3.6.1.4.1.6574.3.1.1.2

  - MIB: SYNOLOGY-SMART-MIB
    table:
      name: diskSMARTTable
      OID: 1.3.6.1.4.1.6574.5.1
    symbols:
      - name: synology.diskSMARTAttrCurrent
        OID: 1.3.6.1.4.1.6574.5.1.1.5
        chart_meta:
          description: SMART attribute current value
          family: 'Hardware/Disk/SMART/Current'
          unit: "1"
      - name: synology.diskSMARTAttrThreshold
        OID: 1.3.6.1.4.1.6574.5.1.1.7
        chart_meta:
          description: SMART attribute threshold value
          family: 'Hardware/Disk/SMART/Threshold'
          unit: "1"
    metric_tags:
      - tag: synology_disk_smart_info_dev_name
        symbol:
          name: synology.diskSMARTInfoDevName
          OID: 1.3.6.1.4.1.6574.5.1.1.2
      - tag: _synology_disk_smart_attr_name
        symbol:
          name: synology.diskSMARTAttrName
          OID: 1.3.6.1.4.1.6574.5.1.1.3
      - tag: synology_disk_smart_attr_id
        symbol:
          name: synology.diskSMARTAttrId
          OID: 1.3.6.1.4.1.6574.5.1.1.4
  # TODO: find mapping and add as a metric
  #      - symbol:
  #          OID: 1.3.6.1.4.1.6574.5.1.1.9
  #          name: synology.diskSMARTAttrStatus
  #        tag: synology_disk_smart_attr_status

  - MIB: SYNOLOGY-SERVICES-MIB
    table:
      name: serviceTable
      OID: 1.3.6.1.4.1.6574.6.1
    symbols:
      - name: synology.serviceUsers
        OID: 1.3.6.1.4.1.6574.6.1.1.3
        chart_meta:
          description: Number of users using this service
          family: 'System/Service/User/Active'
          unit: "{user}"
    metric_tags:
      - tag: service_index
        index: 1
      - tag: synology_service_name
        symbol:
          name: synology.serviceName
          OID: 1.3.6.1.4.1.6574.6.1.1.2
  - MIB: SYNOLOGY-STORAGEIO-MIB
    table:
      name: synology.storageIO
      OID: 1.3.6.1.4.1.6574.101.1.1
    symbols:
      - name: synology.storageIOReads
        OID: 1.3.6.1.4.1.6574.101.1.1.5
        chart_meta:
          description: The number of read accesses from this device since boot
          family: 'Storage/IO/Operations/Read'
          unit: "{access}/s"
      - name: synology.storageIOWrites
        OID: 1.3.6.1.4.1.6574.101.1.1.6
        chart_meta:
          description: The number of write accesses to this device since boot
          family: 'Storage/IO/Operations/Write'
          unit: "{access}/s"
      - name: synology.storageIOLA
        OID: 1.3.6.1.4.1.6574.101.1.1.8
        chart_meta:
          description: The load of disk
          family: 'Storage/IO/Load'
          unit: "%"
      - name: synology.storageIONReadX
        OID: 1.3.6.1.4.1.6574.101.1.1.12
        chart_meta:
          description: The number of bytes read from this device since boot
          family: 'Storage/IO/Throughput/Read'
          unit: "By/s"
      - name: synology.storageIONWrittenX
        OID: 1.3.6.1.4.1.6574.101.1.1.13
        chart_meta:
          description: The number of bytes written to this device since boot
          family: 'Storage/IO/Throughput/Write'
          unit: "By/s"
    metric_tags:
      - tag: storage_io_device_index
        index: 1
      - tag: synology_storage_io_device
        symbol:
          name: synology.storageIODevice
          OID: 1.3.6.1.4.1.6574.101.1.1.2
  - MIB: SYNOLOGY-SPACEIO-MIB
    table:
      name: synology.spaceIO
      OID: 1.3.6.1.4.1.6574.102.1.1
    symbols:
      - name: synology.spaceIOReads
        OID: 1.3.6.1.4.1.6574.102.1.1.5
        chart_meta:
          description: The number of read accesses from this device since boot
          family: 'Storage/Volume/IO/Operations/Read'
          unit: "{access}/s"
      - name: synology.spaceIOWrites
        OID: 1.3.6.1.4.1.6574.102.1.1.6
        chart_meta:
          description: The number of write accesses to this device since boot
          family: 'Storage/Volume/IO/Operations/Write'
          unit: "{access}/s"
      - name: synology.spaceIOLA
        OID: 1.3.6.1.4.1.6574.102.1.1.8
        chart_meta:
          description: The load of disk
          family: 'Storage/Volume/IO/Load'
          unit: "%"
      - name: synology.spaceIONReadX
        OID: 1.3.6.1.4.1.6574.102.1.1.12
        chart_meta:
          description: The number of bytes read from this device since boot
          family: 'Storage/Volume/IO/Throughput/Read'
          unit: "By/s"
      - name: synology.spaceIONWrittenX
        OID: 1.3.6.1.4.1.6574.102.1.1.13
        chart_meta:
          description: The number of bytes written to this device since boot
          family: 'Storage/Volume/IO/Throughput/Write'
          unit: "By/s"
    metric_tags:
      - tag: space_io_device_index
        index: 1
      - tag: synology_space_io_device
        symbol:
          name: synology.spaceIODevice
          OID: 1.3.6.1.4.1.6574.102.1.1.2

  - MIB: SYNOLOGY-GPUINFO-MIB
    symbol:
      name: synology.system.gpuInfoSupported
      OID: 1.3.6.1.4.1.6574.108.1.0
      chart_meta:
        description: GPU info support status
        family: 'System/GPU/Support/Status'
        unit: "{status}"
      mapping:
        0: supported
        1: unsupported
  - MIB: SYNOLOGY-GPUINFO-MIB
    symbol:
      name: synology.gpuUtilization
      OID: 1.3.6.1.4.1.6574.108.2.0
      chart_meta:
        description: GPU utilization
        family: 'System/GPU/Usage'
        unit: "%"
  - MIB: SYNOLOGY-GPUINFO-MIB
    symbol:
      name: synology.gpuMemoryUtilization
      OID: 1.3.6.1.4.1.6574.108.3.0
      chart_meta:
        description: GPU memory utilization
        family: 'System/GPU/Memory/Usage'
        unit: "%"
