From d1ff581d85dfc92cc3f4665e0adc54bfc2edf3fb Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 5 Feb 2026 08:07:11 -0600 Subject: [PATCH] fix: add SNMPv3 credentials to DevicePollerWorker The DevicePollerWorker was only passing SNMPv2c credentials (community string) to the SNMP client, causing KeyError when polling SNMPv3 devices. Changes: - Updated build_client_opts in device_poller_worker.ex to detect version "3" - Added same SNMPv3 credential handling as discovery.ex - Includes: security_name, security_level, auth_protocol, auth_password, priv_protocol, priv_password This completes the SNMPv3 implementation - both discovery and polling now support v3 authentication alongside the existing v2c support. --- lib/towerops/workers/device_poller_worker.ex | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/towerops/workers/device_poller_worker.ex b/lib/towerops/workers/device_poller_worker.ex index b007b6c2..13693eb7 100644 --- a/lib/towerops/workers/device_poller_worker.ex +++ b/lib/towerops/workers/device_poller_worker.ex @@ -1115,12 +1115,28 @@ defmodule Towerops.Workers.DevicePollerWorker do defp build_client_opts(device) do snmp_config = Devices.get_snmp_config(device) - [ + base_opts = [ ip: device.ip_address, - community: snmp_config.community, version: snmp_config.version, port: device.snmp_port || 161 ] + + # Add version-specific credentials + if snmp_config.version == "3" do + v3_config = Devices.get_snmpv3_config(device) + + base_opts ++ + [ + security_name: v3_config.username, + security_level: v3_config.security_level, + auth_protocol: v3_config.auth_protocol, + auth_password: v3_config.auth_password, + priv_protocol: v3_config.priv_protocol, + priv_password: v3_config.priv_password + ] + else + base_opts ++ [community: snmp_config.community] + end end defp get_poll_interval(device) do