From 0f3f16d443373d88ce5bfa1a64ad77898925d583 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Thu, 26 Mar 2026 11:10:27 -0500 Subject: [PATCH] fix: only send SNMP jobs to agent for SNMP-enabled devices (#180) - Check device.snmp_enabled before creating discovery/polling jobs - Also check snmp_enabled for MikroTik jobs - Prevents agent from attempting SNMP operations on ping-only devices - Fixes "Agent collected 0 OIDs" errors for devices without SNMP Reviewed-on: https://git.mcintire.me/graham/towerops-web/pulls/180 --- lib/towerops_web/channels/agent_channel.ex | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index 3e3ddb01..745a0e18 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -969,18 +969,20 @@ defmodule ToweropsWeb.AgentChannel do end defp build_jobs_for_device(device) do - # Build SNMP job (discovery or polling) + # Build SNMP job (discovery or polling) only if SNMP is enabled snmp_job = - if needs_discovery?(device) do - build_discovery_job(device) - else - build_polling_job(device) + if device.snmp_enabled do + if needs_discovery?(device) do + build_discovery_job(device) + else + build_polling_job(device) + end end # Build MikroTik job only during discovery (not during regular polling) # MikroTik commands are discovery-type operations that should run once per 24h mikrotik_job = - if needs_discovery?(device) and mikrotik_device?(device) do + if device.snmp_enabled and needs_discovery?(device) and mikrotik_device?(device) do build_mikrotik_job(device) end