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:
parent
35ca827bd0
commit
57f81b70f8
2 changed files with 8 additions and 8 deletions
|
|
@ -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} ->
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue