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.
This commit is contained in:
Graham McIntire 2026-02-05 08:07:11 -06:00
parent 129bc9a8f4
commit d1ff581d85
No known key found for this signature in database

View file

@ -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