extends:
  - citrix.yaml

selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.5951.6

metadata:
  device:
    fields:
      serial_number:
        symbol:
          MIB: SDX-ROOT-MIB
          OID: 1.3.6.1.4.1.5951.6.2.16.0
          name: netscaler.sdx.systemSerial
      version:
        symbol:
          MIB: SDX-ROOT-MIB
          OID: 1.3.6.1.4.1.5951.6.2.3.0
          name: netscaler.sdx.systemBuildNumber
      type:
        value: "LoadBalancer"

metric_tags:
  - OID: 1.3.6.1.4.1.5951.6.2.2.0
    symbol: systemProduct
    tag: netscaler_sdx_system_product
  - OID: 1.3.6.1.4.1.5951.6.2.4.0
    symbol: systemSvmIPAddressType
    tag: netscaler_sdx_system_svm_ip_address_type
    mapping:
      0: unknown
      1: ipv4
      2: ipv6
      3: ipv4z
      4: ipv6z
      16: dns
      25: l2vpn
  - OID: 1.3.6.1.4.1.5951.6.2.5.0
    symbol: systemSvmIPAddress
    # TODO update this to the modern syntax that supports format
    # format: ip_address
    tag: netscaler_sdx_system_svm_ip_address
  - OID: 1.3.6.1.4.1.5951.6.2.6.0
    symbol: systemXenIPAddressType
    tag: netscaler_sdx_system_xen_ip_address_type
    mapping:
      0: unknown
      1: ipv4
      2: ipv6
      3: ipv4z
      4: ipv6z
      16: dns
      25: l2vpn
  - OID: 1.3.6.1.4.1.5951.6.2.7.0
    symbol: systemXenIPAddress
    # format: ip_address
    tag: netscaler_sdx_system_xen_ip_address
  - OID: 1.3.6.1.4.1.5951.6.2.8.0
    symbol: systemNetmaskType
    tag: netscaler_sdx_system_netmask_type
    mapping:
      0: unknown
      1: ipv4
      2: ipv6
      3: ipv4z
      4: ipv6z
      16: dns
      25: l2vpn
  - OID: 1.3.6.1.4.1.5951.6.2.9.0
    symbol: systemNetmask
    # format: ip_address
    tag: netscaler_sdx_system_netmask
  - OID: 1.3.6.1.4.1.5951.6.2.10.0
    symbol: systemGatewayType
    tag: netscaler_sdx_system_gateway_type
    mapping:
      0: unknown
      1: ipv4
      2: ipv6
      3: ipv4z
      4: ipv6z
      16: dns
      25: l2vpn
  - OID: 1.3.6.1.4.1.5951.6.2.11.0
    symbol: systemGateway
    # format: ip_address
    tag: netscaler_sdx_system_gateway
  - OID: 1.3.6.1.4.1.5951.6.2.12.0
    symbol: systemNetworkInterface
    tag: netscaler_sdx_system_network_interface
  # different versions of MIBs have different definitions for these metrics. Keep this comment until investigated further.
  # - OID: 1.3.6.1.4.1.5951.6.2.13.0
  #   symbol: systemDnsType
  #   tag: netscaler_sdx_system_dns_type
  #   mapping:
  #     0: unknown
  #     1: ipv4
  #     2: ipv6
  #     3: ipv4z
  #     4: ipv6z
  #     16: dns
  #     25: l2vpn
  # - OID: 1.3.6.1.4.1.5951.6.2.14.0
  #   symbol: systemDns
  #   format: ip_address
  #   tag: netscaler_sdx_system_dns
  - OID: 1.3.6.1.4.1.5951.6.2.19.0
    symbol: systemBiosVersion
    tag: netscaler_sdx_system_bios_version

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

metrics:
  - MIB: SDX-ROOT-MIB
    table:
      name: hardwareResourceTable
      OID: 1.3.6.1.4.1.5951.6.2.1000.1
    symbols:
      - OID: 1.3.6.1.4.1.5951.6.2.1000.1.1.7
        name: netscaler.sdx.hardwareResourceStatus
        chart_meta:
          description: Health status of the resource
          family: 'Hardware/Resource/Status'
          unit: "{status}"
        mapping:
          OK: 1
          ERROR: 2
    metric_tags:
      - tag: netscaler_sdx_hardware_resource_name
        symbol:
          name: netscaler.sdx.hardwareResourceName
          OID: 1.3.6.1.4.1.5951.6.2.1000.1.1.1

  - MIB: SDX-ROOT-MIB
    table:
      name: softwareResourceTable
      OID: 1.3.6.1.4.1.5951.6.2.1000.2
    symbols:
      - OID: 1.3.6.1.4.1.5951.6.2.1000.2.1.7
        name: netscaler.sdx.softwareResourceStatus
        chart_meta:
          description: Health status of the resource
          family: 'System/Software/Resource/Status'
          unit: "{status}"
        mapping:
          OK: 1
          ERROR: 2
    metric_tags:
      - tag: netscaler_sdx_software_resource_name
        symbol:
          name: netscaler.sdx.softwareResourceName
          OID: 1.3.6.1.4.1.5951.6.2.1000.2.1.1

  - MIB: SDX-ROOT-MIB
    table:
      name: srTable
      OID: 1.3.6.1.4.1.5951.6.2.1000.4
    symbols:
      - name: netscaler.sdx.srUtilized
        OID: 1.3.6.1.4.1.5951.6.2.1000.4.1.5
        chart_meta:
          description: "Physical utilization of the storage repository"
          family: 'Storage/Repository/Used'
          unit: "By"
      - name: netscaler.sdx.srSize
        OID: 1.3.6.1.4.1.5951.6.2.1000.4.1.6
        chart_meta:
          description: "Physical size of the storage repository"
          family: 'Storage/Repository/Size'
          unit: "By"
      - OID: 1.3.6.1.4.1.5951.6.2.1000.4.1.7
        name: netscaler.sdx.srStatus
        chart_meta:
          description: Status of the storage repository
          family: 'Storage/Repository/Status'
          unit: "{status}"
        mapping:
          OK: 1
          ERROR: 2
    metric_tags:
      - tag: netscaler_sdx_sr_name
        symbol:
          name: netscaler.sdx.srName
          OID: 1.3.6.1.4.1.5951.6.2.1000.4.1.1
      - tag: netscaler_sdx_sr_bay_number
        symbol:
          name: netscaler.sdx.srBayNumber
          OID: 1.3.6.1.4.1.5951.6.2.1000.4.1.2

  - MIB: SDX-ROOT-MIB
    table:
      name: interfaceTable
      OID: 1.3.6.1.4.1.5951.6.2.1000.5
    symbols:
      - name: netscaler.sdx.interfaceRxPackets
        OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.5
        chart_meta:
          description: "Received packets"
          family: 'Network/Interface/Packet/Total/In'
          unit: "{packet}/s"
      - name: netscaler.sdx.interfaceTxPackets
        OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.6
        chart_meta:
          description: "Transmitted packets"
          family: 'Network/Interface/Packet/Total/Out'
          unit: "{packet}/s"
      - name: netscaler.sdx.interfaceRxBytes
        OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.7
        scale_factor: 8
        chart_meta:
          description: "Received bytes"
          family: 'Network/Interface/Traffic/Total/In'
          unit: "bit/s"
      - name: netscaler.sdx.interfaceTxBytes
        OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.8
        scale_factor: 8
        chart_meta:
          description: "Transmitted bytes"
          family: 'Network/Interface/Traffic/Total/Out'
          unit: "bit/s"
      - name: netscaler.sdx.interfaceRxErrors
        OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.9
        chart_meta:
          description: "Receiving errors"
          family: 'Network/Interface/Error/Total/In'
          unit: "{error}/s"
      - name: netscaler.sdx.interfaceTxErrors
        OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.10
        chart_meta:
          description: "Transmission errors"
          family: 'Network/Interface/Error/Total/Out'
          unit: "{error}/s"
      - OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.4
        name: netscaler.sdx.interfaceState
        chart_meta:
          description: State of the Interface
          family: 'Network/Interface/Status/Operational'
          unit: "{status}"
        mapping:
          UP: 1
          DOWN: 2
    metric_tags:
      - tag: netscaler_sdx_interface_port
        symbol:
          name: netscaler.sdx.interfacePort
          OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.1
      - tag: netscaler_sdx_interface_mapped_port
        symbol:
          name: netscaler.sdx.interfaceMappedPort
          OID: 1.3.6.1.4.1.5951.6.2.1000.5.1.13

  - MIB: SDX-ROOT-MIB
    table:
      name: xenTable
      OID: 1.3.6.1.4.1.5951.6.3.1
    symbols:
      - name: cpu.usage
        OID: 1.3.6.1.4.1.5951.6.3.1.1.8
        chart_meta:
          description: The current CPU utilization
          family: 'System/CPU/Usage'
          unit: "%"
      - name: memory.usage
        OID: 1.3.6.1.4.1.5951.6.3.1.1.11
        chart_meta:
          description: "Memory usage percentage of host"
          family: 'System/Memory/Usage'
          unit: "%"
    metric_tags:
      - tag: netscaler_sdx_xen_ip_address_type
        symbol:
          OID: 1.3.6.1.4.1.5951.6.3.1.1.1
          name: netscaler.sdx.xenIpAddressType
        mapping:
          0: unknown
          1: ipv4
          2: ipv6
          3: ipv4z
          4: ipv6z
          16: dns
          25: l2vpn
      - tag: netscaler_sdx_xen_ip_address
        symbol:
          OID: 1.3.6.1.4.1.5951.6.3.1.1.2
          name: netscaler.sdx.xenIpAddress
          format: ip_address
      - tag: netscaler_sdx_xen_uuid
        symbol:
          OID: 1.3.6.1.4.1.5951.6.3.1.1.6
          name: netscaler.sdx.xenUuid

  - MIB: SDX-ROOT-MIB
    table:
      name: netscalerTable
      OID: 1.3.6.1.4.1.5951.6.3.2
    symbols:
      - name: netscaler.sdx.nsNsCPUUsage
        OID: 1.3.6.1.4.1.5951.6.3.2.1.33
        chart_meta:
          description: "Cpu usage percentage of netscaler instance"
          family: 'Virtualization/VirtualInstance/CPU/Usage'
          unit: "%"
      - name: netscaler.sdx.nsNsMemoryUsage
        OID: 1.3.6.1.4.1.5951.6.3.2.1.35
        chart_meta:
          description: "Memory usage percentage"
          family: 'Virtualization/VirtualInstance/Memory/Usage'
          unit: "%"
      - name: netscaler.sdx.nsNsTx
        OID: 1.3.6.1.4.1.5951.6.3.2.1.36
        scale_factor: 1000000 # MBits => Bits
        chart_meta:
          description: "Out throughput of netscaler instance in megabits per second"
          family: 'Virtualization/VirtualInstance/Network/Traffic/Out'
          unit: "bit/s"
      - name: netscaler.sdx.nsNsRx
        OID: 1.3.6.1.4.1.5951.6.3.2.1.37
        scale_factor: 1000000 # MBits => Bits
        chart_meta:
          description: "In throughput of netscaler instance in megabits per second"
          family: 'Virtualization/VirtualInstance/Network/Traffic/In'
          unit: "bit/s"
      - name: netscaler.sdx.nsHttpReq
        OID: 1.3.6.1.4.1.5951.6.3.2.1.38
        chart_meta:
          description: "Http requests per second"
          family: 'Virtualization/VirtualInstance/Network/HTTP/Request/Total'
          unit: "{request}/s"
    metric_tags:
      - tag: netscaler_sdx_ns_uuid
        symbol:
          name: netscaler.sdx.nsUuid
          OID: 1.3.6.1.4.1.5951.6.3.2.1.14
      - tag: netscaler_sdx_ns_name
        symbol:
          name: netscaler.sdx.nsName
          OID: 1.3.6.1.4.1.5951.6.3.2.1.6
      - tag: _netscaler_sdx_ns_ip_address_type
        symbol:
          name: netscaler.sdx.nsIpAddressType
          OID: 1.3.6.1.4.1.5951.6.3.2.1.1
        mapping:
          0: unknown
          1: ipv4
          2: ipv6
          3: ipv4z
          4: ipv6z
          16: dns
          25: l2vpn
      - tag: _netscaler_sdx_ns_profile_name
        symbol:
          name: netscaler.sdx.nsProfileName
          OID: 1.3.6.1.4.1.5951.6.3.2.1.5
      - tag: _netscaler_sdx_ns_netmask_type
        symbol:
          name: netscaler.sdx.nsNetmaskType
          OID: 1.3.6.1.4.1.5951.6.3.2.1.7
        mapping:
          0: unknown
          1: ipv4
          2: ipv6
          3: ipv4z
          4: ipv6z
          16: dns
          25: l2vpn
      - tag: _netscaler_sdx_ns_hostname
        symbol:
          name: netscaler.sdx.nsHostname
          OID: 1.3.6.1.4.1.5951.6.3.2.1.11
      - tag: _netscaler_sdx_ns_description
        symbol:
          name: netscaler.sdx.nsDescription
          OID: 1.3.6.1.4.1.5951.6.3.2.1.12
      - tag: _netscaler_sdx_ns_version
        symbol:
          name: netscaler.sdx.nsVersion
          OID: 1.3.6.1.4.1.5951.6.3.2.1.13
      - tag: _netscaler_sdx_ns_throughput
        symbol:
          name: netscaler.sdx.nsThroughput
          OID: 1.3.6.1.4.1.5951.6.3.2.1.31
