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.
This commit is contained in:
parent
57f81b70f8
commit
c74e00fcb0
1 changed files with 4 additions and 10 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue