From c74e00fcb0bca6d00d4576325a61a56fba4c63bc Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 17 Jan 2026 17:02:51 -0600 Subject: [PATCH] Always use ICMP ping for latency monitoring, not SNMP checks Changed device_monitor.ex to always use ICMP ping for monitoring checks, regardless of whether SNMP is enabled for the device. Rationale: - ICMP ping gives actual network latency (round-trip time) - SNMP checks are for data collection (interfaces, sensors, etc.) - Both should run independently for SNMP-enabled devices: * SNMP polling: Collects device metrics (handled by poller_worker) * ICMP monitoring: Measures latency and availability (handled by device_monitor) This ensures latency graphs always show actual network response time, not SNMP query response time. --- lib/towerops/monitoring/device_monitor.ex | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/towerops/monitoring/device_monitor.ex b/lib/towerops/monitoring/device_monitor.ex index 0599eb13..d7e8f4a0 100644 --- a/lib/towerops/monitoring/device_monitor.ex +++ b/lib/towerops/monitoring/device_monitor.ex @@ -12,10 +12,9 @@ defmodule Towerops.Monitoring.DeviceMonitor do # Allow dependency injection for testing @ping_module Application.compile_env(:towerops, :ping_module, Towerops.Monitoring.Ping) - @poller_module Application.compile_env(:towerops, :poller_module, Towerops.Snmp.Poller) # Suppress warnings for Mox modules that are defined at runtime during tests - @compile {:no_warn_undefined, [Towerops.Monitoring.PingMock, Towerops.Snmp.PollerMock]} + @compile {:no_warn_undefined, Towerops.Monitoring.PingMock} # Client API @@ -73,14 +72,9 @@ defmodule Towerops.Monitoring.DeviceMonitor do defp perform_check(device_id) do device = Devices.get_device!(device_id) - # Use SNMP if enabled, otherwise fallback to ping - check_result = - if device.snmp_enabled do - client_opts = @poller_module.build_client_opts(device) - @poller_module.check_device(client_opts) - else - @ping_module.ping(device.ip_address) - end + # Always use ICMP ping for latency measurement + # SNMP polling is handled separately by the poller_worker + check_result = @ping_module.ping(device.ip_address) now = DateTime.truncate(DateTime.utc_now(), :second)