Fix latency data not being captured in monitoring checks

The monitoring system was creating checks but hardcoding response_time_ms
to nil instead of using the actual ping latency. This caused the latency
graphs to have no data to display.

Changes:
- device_monitor.ex: Capture response time from ping/SNMP check result
- monitor_worker.ex: Use correct field name (response_time_ms) and status enum values (:success/:failure)

After this fix, new monitoring checks will include latency data and the
latency graphs will display properly on both device and site detail pages.
This commit is contained in:
Graham McIntire 2026-01-17 17:00:52 -06:00
parent 35ca827bd0
commit 57f81b70f8
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View file

@ -84,17 +84,17 @@ defmodule Towerops.Monitoring.DeviceMonitor do
now = DateTime.truncate(DateTime.utc_now(), :second)
status =
{status, response_time_ms} =
case check_result do
{:ok, _time} -> :success
{:error, _reason} -> :failure
{:ok, time} -> {:success, time}
{:error, _reason} -> {:failure, nil}
end
# Save the check result
case Monitoring.create_check(%{
device_id: device_id,
status: status,
response_time_ms: nil,
response_time_ms: response_time_ms,
checked_at: now
}) do
{:ok, _check} ->

View file

@ -36,8 +36,8 @@ defmodule Towerops.Workers.MonitorWorker do
Monitoring.create_check(%{
device_id: device_id,
status: "up",
latency_ms: latency,
status: :success,
response_time_ms: latency,
checked_at: DateTime.utc_now()
})
@ -48,8 +48,8 @@ defmodule Towerops.Workers.MonitorWorker do
Monitoring.create_check(%{
device_id: device_id,
status: "down",
latency_ms: nil,
status: :failure,
response_time_ms: nil,
checked_at: DateTime.utc_now()
})