fix: always measure actual ICMP latency instead of returning 0ms for SNMP devices
This commit is contained in:
parent
617e8c5414
commit
35f0ac495b
1 changed files with 3 additions and 14 deletions
|
|
@ -126,20 +126,9 @@ defmodule Towerops.Monitoring.DeviceMonitor do
|
|||
end
|
||||
|
||||
defp check_device_health(device) do
|
||||
if device.snmp_enabled && device.last_snmp_poll_at do
|
||||
# If SNMP poll was successful in the last 5 minutes, consider device up
|
||||
five_minutes_ago = DateTime.add(DateTime.utc_now(), -300, :second)
|
||||
|
||||
if DateTime.after?(device.last_snmp_poll_at, five_minutes_ago) do
|
||||
{:ok, 0}
|
||||
else
|
||||
# Fall back to ping if SNMP polling is stale
|
||||
@ping_module.ping(device.ip_address)
|
||||
end
|
||||
else
|
||||
# Use ICMP ping for non-SNMP devices
|
||||
@ping_module.ping(device.ip_address)
|
||||
end
|
||||
# Always perform actual ICMP ping to measure real latency
|
||||
# Don't rely solely on SNMP poll success since that doesn't give us latency data
|
||||
@ping_module.ping(device.ip_address)
|
||||
end
|
||||
|
||||
defp handle_status_change(device, old_status, new_status) do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue