defmodule Towerops.Snmp.Profiles.Vendors.Adtran do
  @moduledoc """
  ADTRAN device-specific SNMP handling.

  Supports ADTRAN AOS routers and switches.

  Supported devices:
  - NetVanta 1500/1600 series switches
  - NetVanta 3000/4000 series routers
  - NetVanta 5000 series
  - ADTRAN Total Access series

  Enterprise OID: 1.3.6.1.4.1.664
  """

  @behaviour Towerops.Snmp.Profiles.Vendors.Vendor

  alias Towerops.Snmp.Client
  alias Towerops.Snmp.Profiles.Vendors.Vendor

  # ADTRAN model OID
  @model_oid "1.3.6.1.4.1.664.1.1.2.0"

  @impl true
  def profile_names, do: ["adtran-aos"]

  @impl true
  def detect_hardware(client_opts) do
    case Client.get(client_opts, @model_oid) do
      {:ok, model} when is_binary(model) -> model
      _ -> nil
    end
  end

  @impl true
  def discover_wireless_sensors(client_opts) do
    Vendor.fetch_sensors(wireless_oid_defs(), client_opts)
  end

  @impl true
  def wireless_oid_defs do
    [
      # Current CPU Utilization
      %{
        oid: "1.3.6.1.4.1.664.5.53.1.4.1.0",
        sensor_type: "load",
        sensor_descr: "CPU Utilization",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # 5-minute CPU Average
      %{
        oid: "1.3.6.1.4.1.664.5.53.1.4.4.0",
        sensor_type: "load",
        sensor_descr: "CPU 5min Average",
        sensor_unit: "%",
        sensor_divisor: 1
      },
      # Available Memory
      %{
        oid: "1.3.6.1.4.1.664.5.53.1.4.8.0",
        sensor_type: "count",
        sensor_descr: "Available Memory",
        sensor_unit: "bytes",
        sensor_divisor: 1
      },
      # System Uptime
      %{
        oid: "1.3.6.1.2.1.1.3.0",
        sensor_type: "count",
        sensor_descr: "System Uptime",
        sensor_unit: "ticks",
        sensor_divisor: 1
      }
    ]
  end
end
