# Profile for NetApp devices.
# Example sysDescr:
# - "NetApp Release 9.7P9: Fri Nov 06 01:13:45 UTC 2020"
# - "NetApp Release 9.7P14: Thu Jun 10 22:54:31 UTC 2021"
# - "NetApp Release 8.2.5P3 7-Mode: Tue Jul 16 01:37:24 PDT 2019"

extends:
  - _system-base.yaml

# All netapp products have netappProducts (1.3.6.1.4.1.789.2) OID as parent
selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.789.2.*

metadata:
  device:
    fields:
      vendor:
        value: "NetApp"
      serial_number:
        symbol:
          MIB: NETAPP-MIB
          OID: 1.3.6.1.4.1.789.1.1.9.0
          name: productSerialNum  # The product serial number. Returns unknown if it cannot be determined.
      version:
        # We can alternatively use 1.3.6.1.4.1.789.1.1.2.0/productVersion, but it seems to contain the same string as sysDescr.
        # Choosing to use sysDescr since it's already retrieved anyway.
        # Info about NetApp version: https://mysupport.netapp.com/site/info/version-support
        symbol:
          OID: 1.3.6.1.2.1.1.1.0
          name: sysDescr
          match_pattern: 'NetApp Release\s+(\S+)[:\s]'
          match_value: '$1'
      # product_name:
      #   TODO: No suitable info found yet that can be used as product_name
      model:
        symbol:
          MIB: NETAPP-MIB
          OID: 1.3.6.1.4.1.789.1.1.5.0
          name: productModel  # The model name of the system. Examples are FAS980 and FAS3050.
      os_name:
        # Data ONTAP is the operating system for all NetApp storage systems.
        # Source: https://library.netapp.com/ecmdocs/ECMP1155684/html/GUID-C6A665D4-EB47-485E-B2C9-29405DEE4510.html
        value: 'ONTAP'
      os_version:
        symbol:
          OID: 1.3.6.1.2.1.1.1.0
          name: sysDescr
          match_pattern: 'NetApp Release\s+(\d+(?:\.\d+)*)'  # First part of the version composed of digits and `.`
          # Example: 9.7P14 => 9.7
          match_value: '$1'


# NETAPP-MIB
# https://mibbrowser.online/mibdb_search.php?mib=NETAPP-MIB
# https://github.com/DanielleHuisman/observium-community-edition/blob/main/mibs/netapp/NETAPP-MIB

metrics:
  - MIB: NETAPP-MIB
    symbol:
      OID: 1.3.6.1.4.1.789.1.2.3.8.0
      name: cfInterconnectStatus
      # The current status of the interconnect.
      # The partialFailure(3) status indicates that one of the links in the interconnect hardware is down.
      chart_meta:
        description: The current status of the interconnect
        family: 'System/ClusterFailover/Interconnect/Status'
        unit: "{status}"
  - MIB: NETAPP-MIB
    symbol:
      OID: 1.3.6.1.4.1.789.1.2.2.23.0
      name: miscCacheAge
      # Age in minutes of the oldest read-only blocks in the buffer cache.
      # This indicates how fast read operations are cycling through system memory;
      # when the appliance is reading very large files (larger than the machine's memory size),
      # buffer cache age will be very low.
      chart_meta:
        description: Age in minutes of the oldest read-only blocks in the buffer cache
        family: 'Storage/Cache/Buffer/Age'
        unit: "min"
  - MIB: NETAPP-MIB
    symbol:
      OID: 1.3.6.1.4.1.789.1.8.3.6.36.0
      name: ncHttpActiveCliConns
      chart_meta:
        description: Number of currently active TCP/IP connections to HTTP clients
        family: 'Network/HTTP/Connection/Active'
        unit: "{connection}"

  - MIB: NETAPP-MIB
    symbol:
      OID: 1.3.6.1.4.1.789.1.26.8.0
      name: extcache64Hits
      chart_meta:
        description: Number of wafl buffers read from the external cache
        family: 'Storage/Cache/External/Hit'
        unit: "{buffer}/s"

  # Snap vaults (https://oidref.com/1.3.6.1.4.1.789.1.19.11.1.15)
  - MIB: NETAPP-MIB
    table:
      OID: 1.3.6.1.4.1.789.1.19.11
      name: snapvaultStatusTable
    symbols:
      - OID: 1.3.6.1.4.1.789.1.19.11.1.11
        name: svTotalTransMBs
        chart_meta:
          description: Transfer size
          family: 'Storage/SnapVault/Transfer/Throughput'
          unit: "By/s"
        scale_factor: 1048576
      - OID: 1.3.6.1.4.1.789.1.19.11.1.7
        name: svTotalSuccesses
        chart_meta:
          description: Successful transfers
          family: 'Storage/SnapVault/Transfer/Success'
          unit: "{transfer}/s"
      - OID: 1.3.6.1.4.1.789.1.19.11.1.9
        name: svTotalFailures
        chart_meta:
          description: Failed or aborted transfers
          family: 'Storage/SnapVault/Transfer/Failure'
          unit: "{transfer}/s"
      - OID: 1.3.6.1.4.1.789.1.19.11.1.6
        name: svLag
        chart_meta:
          description: Shows how far away the destination is from the source.
          family: 'Storage/SnapVault/Sync/Lag'
          unit: "cs"
      - OID: 1.3.6.1.4.1.789.1.19.11.1.4
        name: svStatus
        chart_meta:
          description: Current transfer status
          family: 'Storage/SnapVault/Transfer/Status'
          unit: "{status}"
        mapping:
          1: idle
          2: transferring
          3: pending
          4: aborting
          6: quiescing
          7: resyncing
          12: paused
      - OID: 1.3.6.1.4.1.789.1.19.11.1.5
        name: svState
        chart_meta:
          description: Current state of the SnapVault relationship
          family: 'Storage/SnapVault/Relationship/Status'
          unit: "{status}"
        mapping:
          1: uninitialized
          2: snapvaulted
          3: brokenOff
          4: quiesced
          5: source
          6: unknown
          7: restoring
    metric_tags:
      - tag: sv_index
        symbol:
          OID: 1.3.6.1.4.1.789.1.19.11.1.1
          name: svIndex
      - tag: _sv_src
        symbol:
          OID: 1.3.6.1.4.1.789.1.19.11.1.2
          name: svSrc
      - tag: _sv_dest
        symbol:
          OID: 1.3.6.1.4.1.789.1.19.11.1.3
          name: svDst

  # Snap mirrors (https://oidref.com/1.3.6.1.4.1.789.1.9.20.1.2)
  - MIB: NETAPP-MIB
    table:
      OID: 1.3.6.1.4.1.789.1.9.20
      name: snapmirrorStatusTable
    metric_type: gauge
    symbols:
      - OID: 1.3.6.1.4.1.789.1.9.20.1.11
        name: snapmirrorTotalTransMBs
        chart_meta:
          description: Transfer size
          family: 'Storage/SnapMirror/Transfer/Throughput'
          unit: "By/s"
        scale_factor: 1048576
      - OID: 1.3.6.1.4.1.789.1.9.20.1.7
        name: snapmirrorTotalSuccesses
        chart_meta:
          description: Successful transfers
          family: 'Storage/SnapMirror/Transfer/Success'
          unit: "{transfer}/s"
      - OID: 1.3.6.1.4.1.789.1.9.20.1.9
        name: snapmirrorTotalFailures
        chart_meta:
          description: Failed or aborted transfers
          family: 'Storage/SnapMirror/Transfer/Failure'
          unit: "{transfer}/s"
      - OID: 1.3.6.1.4.1.789.1.9.20.1.6
        name: snapmirrorLag
        chart_meta:
          description: How far behind from the source the destination is
          family: 'Storage/SnapMirror/Sync/Lag'
          unit: "cs"
      - OID: 1.3.6.1.4.1.789.1.9.20.1.4
        name: snapmirrorStatus
        chart_meta:
          description: Current transfer status of the SnapMirror
          family: 'Storage/SnapMirror/Transfer/Status'
          unit: "{status}"
        mapping:
          1: uninitialized
          2: snapmirrored
          3: brokenOff
          4: quiesced
          5: source
          6: unknown
      - OID: 1.3.6.1.4.1.789.1.9.20.1.5
        name: snapmirrorState
        chart_meta:
          description: Current state of the SnapMirror
          family: 'Storage/SnapMirror/State/Status'
          unit: "{status}"
        mapping:
          1: idle
          2: transferring
          3: pending
          4: aborting
          5: migrating
          6: quiescing
          7: resyncing
          8: waiting
          9: syncing
          10: inSync
    metric_tags:
      - tag: sm_index
        symbol:
          OID: 1.3.6.1.4.1.789.1.9.20.1.1
          name: snapmirrorIndex
      - tag: _sm_dest
        symbol:
          OID: 1.3.6.1.4.1.789.1.9.20.1.3
          name: snapmirrorDst

  # Disk filesystems (http://oidref.com/1.3.6.1.4.1.789.1.5.4.1)
  - MIB: NETAPP-MIB
    table:
      OID: 1.3.6.1.4.1.789.1.5.4
      name: dfTable
    metric_type: gauge
    symbols:
      - OID: 1.3.6.1.4.1.789.1.5.4.1.20
        name: dfStatus
        chart_meta:
          description: The status of the file system
          family: 'System/FileSystem/Status'
          unit: "{status}"
        mapping:
          1: unmounted
          2: mounted
          3: frozen
          4: destroying
          5: creating
          6: mounting
          7: unmounting
          8: nofsinfo
          9: replaying
          10: replayed
      - OID: 1.3.6.1.4.1.789.1.5.4.1.21
        name: dfMirrorStatus
        chart_meta:
          description: The status of the file system
          family: 'System/FileSystem/Mirror/Status'
          unit: "{status}"
        mapping:
          1: invalid
          2: uninitialized
          3: needcpcheck
          4: cpcheckwait
          5: unmirrored
          6: normal
          7: degraded
          8: resyncing
          9: failed
          10: limbo
      - OID: 1.3.6.1.4.1.789.1.5.4.1.14
        name: dfHighTotalKBytes
        chart_meta:
          description: Total capacity for the referenced file system
          family: 'System/FileSystem/Space/Total'
          unit: "By"
        scale_factor: 1024
      - OID: 1.3.6.1.4.1.789.1.5.4.1.16
        name: dfHighUsedKBytes
        chart_meta:
          description: The total disk space that is in use on the referenced file system
          family: 'System/FileSystem/Space/Used'
          unit: "By"
        scale_factor: 1024
      - OID: 1.3.6.1.4.1.789.1.5.4.1.18
        name: dfHighAvailKBytes
        chart_meta:
          description: Total disk space that is free for use on the referenced file system
          family: 'System/FileSystem/Space/Available'
          unit: "By"
        scale_factor: 1024
      - OID: 1.3.6.1.4.1.789.1.5.4.1.7
        name: dfInodesUsed
        chart_meta:
          description: Total number of inodes in use on the referenced file system
          family: 'System/FileSystem/Inode/Used'
          unit: "{inode}"
      - OID: 1.3.6.1.4.1.789.1.5.4.1.8
        name: dfInodesFree
        chart_meta:
          description: Total number of inodes that are available for use on the referenced file system
          family: 'System/FileSystem/Inode/Free'
          unit: "{inode}"
    metric_tags:
      - tag: df_index
        symbol:
          OID: 1.3.6.1.4.1.789.1.5.4.1.1
          name: dfIndex
      - tag: df_filesystem
        symbol:
          OID: 1.3.6.1.4.1.789.1.5.4.1.2
          name: dfFileSys
      - tag: df_type
        symbol:
          OID: 1.3.6.1.4.1.789.1.5.4.1.23
          name: dfType

  # Network interfaces (http://oidref.com/1.3.6.1.4.1.789.1.22.1.2.1)
  - MIB: NETAPP-MIB
    table:
      OID: 1.3.6.1.4.1.789.1.22.1.2
      name: netifTable
    symbols:
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.25
        name: if64InOctets
        chart_meta:
          description: The total number of octets received on the interface, including framing characters
          family: 'Network/Interface/Traffic/Total/In'
          unit: "bit/s"
        scale_factor: 8
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.31
        name: if64OutOctets
        chart_meta:
          description: The total number of octets transmitted out of the interface, including framing characters
          family: 'Network/Interface/Traffic/Total/Out'
          unit: "bit/s"
        scale_factor: 8
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.26
        name: if64InUcastPkts
        chart_meta:
          description: The number of unicast packets delivered to a higher-layer protocol
          family: 'Network/Interface/Packet/Unicast/In'
          unit: "{packet}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.32
        name: if64OutUcastPkts
        chart_meta:
          description: The total number of unicast packets requested to be transmitted
          family: 'Network/Interface/Packet/Unicast/Out'
          unit: "{packet}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.27
        name: if64InNUcastPkts
        chart_meta:
          description: The number of non-unicast (broadcast/multicast) packets delivered to a higher-layer protocol
          family: 'Network/Interface/Packet/NonUnicast/In'
          unit: "{packet}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.33
        name: if64OutNUcastPkts
        chart_meta:
          description: The total number of non-unicast packets requested to be transmitted
          family: 'Network/Interface/Packet/NonUnicast/Out'
          unit: "{packet}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.28
        name: if64InDiscards
        chart_meta:
          description: The number of inbound packets discarded even though no errors were detected
          family: 'Network/Interface/Packet/Discard/In'
          unit: "{packet}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.34
        name: if64OutDiscards
        chart_meta:
          description: The number of outbound packets discarded even though no errors were detected
          family: 'Network/Interface/Packet/Discard/Out'
          unit: "{packet}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.29
        name: if64InErrors
        chart_meta:
          description: The number of inbound packets containing errors preventing delivery to higher-layer protocol
          family: 'Network/Interface/Error/Total/In'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.35
        name: if64OutErrors
        chart_meta:
          description: The number of outbound packets that could not be transmitted due to errors
          family: 'Network/Interface/Error/Total/Out'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.789.1.22.1.2.1.30
        name: if64InUnknownProtos
        chart_meta:
          description: The number of packets discarded due to unknown or unsupported protocol
          family: 'Network/Interface/Error/UnknownProtocol'
          unit: "{packet}/s"
    metric_tags:
      - tag: interface_index
        symbol:
          OID: 1.3.6.1.4.1.789.1.22.1.2.1.1
          name: netifIndex
      - tag: _interface
        symbol:
          OID: 1.3.6.1.4.1.789.1.22.1.2.1.2
          name: netifDescr
