From dba9a286d3696f82c35d03d61d022250a4c82bab Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Wed, 25 Mar 2026 12:52:24 -0500 Subject: [PATCH] fix: respect device SNMP version for agent polling instead of forcing v2c (#166) Devices configured as SNMPv1 were being force-upgraded to v2c for agent polling, which breaks devices that don't support v2c (returning empty OID responses and no throughput/capacity data). Reviewed-on: https://git.mcintire.me/graham/towerops-web/pulls/166 --- lib/towerops_web/channels/agent_channel.ex | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 }