diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index f90a48fb..3e3ddb01 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -1083,14 +1083,17 @@ defmodule ToweropsWeb.AgentChannel do defp build_v2c_snmp_device(device, snmp_config) do community = snmp_config.community || "" - # Always use v2c for agent polling — Counter64 (HC counters) can't be - # encoded in SNMPv1 responses, causing 64-bit counter queries to fail. - # v2c uses the same community string and is supported by virtually all - # SNMP-capable devices. Without HC counters, 32-bit counters on fast - # links wrap undetectably (full cycle in ~69s at 500 Mbps). + # Use v2c when possible for HC (64-bit) counter support, but respect + # the device's configured version — some devices only support v1. + version = + case device.snmp_version do + "1" -> "1" + _ -> "2c" + end + %SnmpDevice{ ip: device.ip_address, - version: "2c", + version: version, port: device.snmp_port || 161, community: community }