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

selector:
  - sysobjectid:
      include:
        - 1.3.6.1.4.1.13315.2.*

metric_tags:
  - tag: bcn_sys_id_product
    OID: 1.3.6.1.4.1.13315.3.2.2.1.1.0
    symbol: bcnSysIdProduct
  - tag: bcn_sys_id_os_release
    OID: 1.3.6.1.4.1.13315.3.2.2.1.2.0
    symbol: bcnSysIdOSRelease
  - tag: bcn_sys_id_platform
    OID: 1.3.6.1.4.1.13315.3.2.2.1.5.0
    symbol: bcnSysIdPlatform

metadata:
  device:
    fields:
      vendor:
        value: Bluecat
      type:
        value: Server

metrics:
  - MIB: BCN-DHCPV4-MIB
    table:
      OID: 1.3.6.1.4.1.13315.3.1.1.2.2.2
      name: bcnDhcpv4SubnetTable
    symbols:
      - OID: 1.3.6.1.4.1.13315.3.1.1.2.2.2.1.4
        name: bcnDhcpv4SubnetFreeAddresses
        chart_meta:
          description: The number of IPs addresses available in this subnet.
          family: 'Network/DHCP/Subnet/Address/Free'
          unit: "{ip_address}"
        # Transform combines subnet IP and mask into CIDR notation (e.g., 192.168.1.0/24)
        # Converts mask to CIDR if possible, otherwise keeps original mask
        transform: |
          {{- $subnetIP := index .Metric.Tags "rm:bcn_dhcpv4_subnet_ip" | default "" -}}
          {{- $subnetMask := index .Metric.Tags "rm:bcn_dhcpv4_subnet_mask" | default "" -}}
          {{- if and $subnetIP $subnetMask -}}
            {{- $cidr := mask2cidr $subnetMask -}}
            {{- setTag .Metric "bcn_dhcpv4_subnet" (printf "%s/%s" $subnetIP (ternary $cidr $subnetMask $cidr)) -}}
          {{- end -}}
      - OID: 1.3.6.1.4.1.13315.3.1.1.2.2.2.1.3
        name: bcnDhcpv4SubnetSize
        chart_meta:
          description: Size of the subnet
          family: 'Network/DHCP/Subnet/Size'
          unit: "{ip_address}"
        # Transform combines subnet IP and mask into CIDR notation (e.g., 192.168.1.0/24)
        # Converts mask to CIDR if possible, otherwise keeps original mask
        transform: |
          {{- $subnetIP := index .Metric.Tags "rm:bcn_dhcpv4_subnet_ip" | default "" -}}
          {{- $subnetMask := index .Metric.Tags "rm:bcn_dhcpv4_subnet_mask" | default "" -}}
          {{- if and $subnetIP $subnetMask -}}
            {{- $cidr := mask2cidr $subnetMask -}}
            {{- setTag .Metric "bcn_dhcpv4_subnet" (printf "%s/%s" $subnetIP (ternary $cidr $subnetMask $cidr)) -}}
          {{- end -}}
    metric_tags:
      - tag: rm:bcn_dhcpv4_subnet_ip
        symbol:
          OID: 1.3.6.1.4.1.13315.3.1.1.2.2.2.1.1
          name: bcnDhcpv4SubnetIP
      - tag: rm:bcn_dhcpv4_subnet_mask
        symbol:
          OID: 1.3.6.1.4.1.13315.3.1.1.2.2.2.1.2
          name: bcnDhcpv4SubnetMask

  - MIB: BCN-DHCPV4-MIB
    table:
      OID: 1.3.6.1.4.1.13315.3.1.1.2.2.3
      name: bcnDhcpv4PoolTable
    symbols:
      - OID: 1.3.6.1.4.1.13315.3.1.1.2.2.3.1.5
        name: bcnDhcpv4PoolFreeAddresses
        chart_meta:
          description: The number of IPs addresses available in this pool
          family: 'Network/DHCP/Pool/Address/Free'
          unit: "{ip_address}"
        # Transform combines start and end IPs into a single range tag (e.g., 192.168.1.10-192.168.1.100)
        transform: |
          {{- $startIP := index .Metric.Tags "rm:bcn_dhcpv4_pool_start_ip" | default "" -}}
          {{- $endIP := index .Metric.Tags "rm:bcn_dhcpv4_pool_end_ip" | default "" -}}
          {{- if and $startIP $endIP -}}
          {{- setTag .Metric "bcn_dhcpv4_pool_range" (printf "%s-%s" $startIP $endIP) -}}
          {{- end -}}
      - OID: 1.3.6.1.4.1.13315.3.1.1.2.2.3.1.4
        name: bcnDhcpv4PoolSize
        chart_meta:
          description: Pool size
          family: 'Network/DHCP/Pool/Size'
          unit: "{ip_address}"
        # Transform combines start and end IPs into a single range tag (e.g., 192.168.1.10-192.168.1.100)
        transform: |
          {{- $startIP := index .Metric.Tags "rm:bcn_dhcpv4_pool_start_ip" | default "" -}}
          {{- $endIP := index .Metric.Tags "rm:bcn_dhcpv4_pool_end_ip" | default "" -}}
          {{- if and $startIP $endIP -}}
            {{- setTag .Metric "bcn_dhcpv4_pool_range" (printf "%s-%s" $startIP $endIP) -}}
          {{- end -}}
    metric_tags:
      - tag: bcn_dhcpv4_pool_subnet_ip
        symbol:
          OID: 1.3.6.1.4.1.13315.3.1.1.2.2.3.1.3
          name: bcnDhcpv4PoolSubnetIP
      - tag: rm:bcn_dhcpv4_pool_start_ip
        symbol:
          OID: 1.3.6.1.4.1.13315.3.1.1.2.2.3.1.1
          name: bcnDhcpv4PoolStartIP
      - tag: rm:bcn_dhcpv4_pool_end_ip
        symbol:
          OID: 1.3.6.1.4.1.13315.3.1.1.2.2.3.1.2
          name: bcnDhcpv4PoolEndIP
