# TrueNAS vs FreeNAS:
#   TrueNAS is commercially-supported, while FreeNAS is community-supported.
#   FreeNAS is an open-source network attached storage platform.
#   TrueNAS is a set of open-source NAS operating systems developed by iXsystems.

# TODO: We can possibly support later FreeNAS devices by moving FREENAS-MIB metrics to a separate abstract profile,
#       that can be extended in by ixsystems-truenas.yaml but also a new FreeNAS profile (with sysobjectid 1.3.6.1.4.1.50536.3.1 FreeNAS).

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

selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.50536.3.2  # TrueNAS

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

# 1. FREENAS-MIB
#     https://mibbrowser.online/mibdb_search.php?mib=FREENAS-MIB
#     https://github.com/librenms/librenms/blob/master/mibs/ixsystems/FREENAS-MIB

metrics:
  - MIB: FREENAS-MIB
    table:
      name: zpoolTable
      OID: 1.3.6.1.4.1.50536.1.1.1
    symbols:
      - name: freenas.zpoolReadBytes
        OID: 1.3.6.1.4.1.50536.1.1.1.1.10
        chart_meta:
          description: The bandwidth of all read operations (including metadata), expressed as units per second (averaged since system booted)
          family: 'Storage/ZFS/Pool/IO/Throughput/Read'
          unit: "By/s"
      - name: freenas.zpoolWriteBytes
        OID: 1.3.6.1.4.1.50536.1.1.1.1.11
        chart_meta:
          description: The bandwidth of all write operations, expressed as units per second (averaged since system booted).
          family: 'Storage/ZFS/Pool/IO/Throughput/Write'
          unit: "By/s"
      - name: freenas.zpoolSize
        OID: 1.3.6.1.4.1.50536.1.1.1.1.4
        chart_meta:
          description: Size of the pool
          family: 'Storage/ZFS/Pool/Space/Size'
          unit: "By"
      - name: freenas.zpoolUsed
        OID: 1.3.6.1.4.1.50536.1.1.1.1.5
        chart_meta:
          description: Used space in the pool
          family: 'Storage/ZFS/Pool/Space/Used'
          unit: "By"
      - name: freenas.zpoolAvailable
        OID: 1.3.6.1.4.1.50536.1.1.1.1.6
        chart_meta:
          description: Available space in the pool
          family: 'Storage/ZFS/Pool/Space/Available'
          unit: "By"
      - name: freenas.zpoolHealth
        OID: 1.3.6.1.4.1.50536.1.1.1.1.7
        chart_meta:
          description: The current health of the containing pool, as reported by zpool status.
          family: 'Storage/ZFS/Pool/Health/Status'
          unit: "{status}"
        mapping:
          0: online
          1: degraded
          2: faulted
          3: offline
          4: unavail
          5: removed
      - name: freenas.zpoolReadOps
        OID: 1.3.6.1.4.1.50536.1.1.1.1.8
        chart_meta:
          description: The number of read I/O operations sent to the pool or device, including metadata requests (averaged since system booted).
          family: 'Storage/ZFS/Pool/IO/Operations/Read'
          unit: "{operation}/s"
      - name: freenas.zpoolWriteOps
        OID: 1.3.6.1.4.1.50536.1.1.1.1.9
        chart_meta:
          description: The number of write I/O operations sent to the pool or device (averaged since system booted).
          family: 'Storage/ZFS/Pool/IO/Operations/Write'
          unit: "{operation}/s"
    metric_tags:
      - tag: freenas_zpool_index
        symbol:
          name: freenas.zpoolIndex
          OID: 1.3.6.1.4.1.50536.1.1.1.1.1
      - tag: freenas_zpool_descr
        symbol:
          name: freenas.zpoolDescr
          OID: 1.3.6.1.4.1.50536.1.1.1.1.2

  - MIB: FREENAS-MIB
    table:
      name: datasetTable
      OID: 1.3.6.1.4.1.50536.1.2.1
    symbols:
      - name: freenas.datasetSize
        OID: 1.3.6.1.4.1.50536.1.2.1.1.4
        chart_meta:
          description: Size of the dataset
          family: 'Storage/ZFS/Dataset/Space/Size'
          unit: "By"
      - name: freenas.datasetUsed
        OID: 1.3.6.1.4.1.50536.1.2.1.1.5
        chart_meta:
          description: Used space in the dataset
          family: 'Storage/ZFS/Dataset/Space/Used'
          unit: "By"
      - name: freenas.datasetAvailable
        OID: 1.3.6.1.4.1.50536.1.2.1.1.6
        chart_meta:
          description: Available space in the dataset
          family: 'Storage/ZFS/Dataset/Space/Available'
          unit: "By"
    metric_tags:
      - tag: freenas_dataset_index
        symbol:
          name: freenas.datasetIndex
          OID: 1.3.6.1.4.1.50536.1.2.1.1.1
      - tag: freenas_dataset_descr
        symbol:
          name: freenas.datasetDescr
          OID: 1.3.6.1.4.1.50536.1.2.1.1.2

  - MIB: FREENAS-MIB
    table:
      name: zvolTable
      OID: 1.3.6.1.4.1.50536.1.3.1
    symbols:
      - name: freenas.zvolSize
        OID: 1.3.6.1.4.1.50536.1.3.1.1.4
        chart_meta:
          description: Size of the zvol
          family: 'Storage/ZFS/Volume/Space/Size'
          unit: "By"
      - name: freenas.zvolUsed
        OID: 1.3.6.1.4.1.50536.1.3.1.1.5
        chart_meta:
          description: Used space in the zvol
          family: 'Storage/ZFS/Volume/Space/Used'
          unit: "By"
      - name: freenas.zvolAvailable
        OID: 1.3.6.1.4.1.50536.1.3.1.1.6
        chart_meta:
          description: Available space in the zvol
          family: 'Storage/ZFS/Volume/Space/Available'
          unit: "By"
      - name: freenas.zvolReferenced
        OID: 1.3.6.1.4.1.50536.1.3.1.1.7
        chart_meta:
          description: Referenced space in the zvol
          family: 'Storage/ZFS/Volume/Space/Referenced'
          unit: "By"
    metric_tags:
      - tag: freenas_zvol_index
        symbol:
          name: freenas.zvolIndex
          OID: 1.3.6.1.4.1.50536.1.3.1.1.1
      - tag: freenas_zvol_descr
        symbol:
          name: freenas.zvolDescr
          OID: 1.3.6.1.4.1.50536.1.3.1.1.2

  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcSize
      OID: 1.3.6.1.4.1.50536.1.4.1.0
      chart_meta:
        description: Size of the ARC cache
        family: 'Storage/ZFS/Cache/ARC/Size'
        unit: "By"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcCacheMissRatio  # zfsArcCacheMissRatio is a string representing a float value
      OID: 1.3.6.1.4.1.50536.1.4.10.0
      chart_meta:
        description: Arc cache miss ration percentage
        family: 'Storage/ZFS/Cache/ARC/MissRatio'
        unit: "%"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcMeta
      OID: 1.3.6.1.4.1.50536.1.4.2.0
      chart_meta:
        description: Metadata size in the ARC cache
        family: 'Storage/ZFS/Cache/ARC/Metadata'
        unit: "By"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcData
      OID: 1.3.6.1.4.1.50536.1.4.3.0
      chart_meta:
        description: Data size in the ARC cache
        family: 'Storage/ZFS/Cache/ARC/Data'
        unit: "By"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcHits
      OID: 1.3.6.1.4.1.50536.1.4.4.0
      metric_type: rate
      chart_meta:
        description: Number of ARC cache hits
        family: 'Storage/ZFS/Cache/ARC/Hit'
        unit: "{hit}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcMisses
      OID: 1.3.6.1.4.1.50536.1.4.5.0
      metric_type: rate
      chart_meta:
        description: Number of ARC cache misses
        family: 'Storage/ZFS/Cache/ARC/Miss'
        unit: "{miss}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcC
      OID: 1.3.6.1.4.1.50536.1.4.6.0
      chart_meta:
        description: ARC cache target size
        family: 'Storage/ZFS/Cache/ARC/TargetSize'
        unit: "By"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcP
      OID: 1.3.6.1.4.1.50536.1.4.7.0
      chart_meta:
        description: ARC cache size
        family: 'Storage/ZFS/Cache/ARC/P'
        unit: "By"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcMissPercent  # zfsArcMissPercent is a string representing a float value
      OID: 1.3.6.1.4.1.50536.1.4.8.0
      chart_meta:
        description: Arc miss percentage
        family: 'Storage/ZFS/Cache/ARC/MissPercent'
        unit: "%"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsArcCacheHitRatio  # zfsArcCacheHitRatio is a string representing a float value
      OID: 1.3.6.1.4.1.50536.1.4.9.0
      chart_meta:
        description: Arc cache hit ration percentage
        family: 'Storage/ZFS/Cache/ARC/HitRatio'
        unit: "%"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsL2ArcHits
      OID: 1.3.6.1.4.1.50536.1.5.1.0
      chart_meta:
        description: Number of L2ARC cache hits
        family: 'Storage/ZFS/Cache/L2ARC/Hit'
        unit: "{hit}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsL2ArcMisses
      OID: 1.3.6.1.4.1.50536.1.5.2.0
      chart_meta:
        description: Number of L2ARC cache misses
        family: 'Storage/ZFS/Cache/L2ARC/Miss'
        unit: "{miss}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsL2ArcRead
      OID: 1.3.6.1.4.1.50536.1.5.3.0
      chart_meta:
        description: Number of L2ARC reads
        family: 'Storage/ZFS/Cache/L2ARC/Read'
        unit: "{read}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsL2ArcWrite
      OID: 1.3.6.1.4.1.50536.1.5.4.0
      chart_meta:
        description: Number of L2ARC writes
        family: 'Storage/ZFS/Cache/L2ARC/Write'
        unit: "{write}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsL2ArcSize
      OID: 1.3.6.1.4.1.50536.1.5.5.0
      chart_meta:
        description: Size of the L2ARC cache
        family: 'Storage/ZFS/Cache/L2ARC/Size'
        unit: "By"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsZilstatOps1sec
      OID: 1.3.6.1.4.1.50536.1.6.1.0
      chart_meta:
        description: The ops column parsed from the command zilstat 1 1
        family: 'Storage/ZFS/ZIL/Operations/1s'
        unit: "{operation}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsZilstatOps5sec
      OID: 1.3.6.1.4.1.50536.1.6.2.0
      chart_meta:
        description: The ops column parsed from the command zilstat 5 1
        family: 'Storage/ZFS/ZIL/Operations/5s'
        unit: "{operation}/s"
  - MIB: FREENAS-MIB
    symbol:
      name: freenas.zfsZilstatOps10sec
      OID: 1.3.6.1.4.1.50536.1.6.3.0
      chart_meta:
        description: The ops column parsed from the command zilstat 10 1
        family: 'Storage/ZFS/ZIL/Operations/10s'
        unit: "{operation}/s"
