fix: Use server-side timestamps for agent polling metrics
Replaces agent-supplied timestamps with server-side DateTime.utc_now() to prevent clock drift issues between agents from causing weird graphs. All metrics now use consistent server time regardless of polling method: - Agent polling (via WebSocket): server time on receipt - Phoenix polling (direct SNMP): server time on poll (already correct) This ensures time-series data aligns correctly when graphing metrics from devices polled by different agents with potentially different system clocks.
This commit is contained in:
parent
bf4fee4846
commit
f17ee2183c
1 changed files with 2 additions and 1 deletions
|
|
@ -914,7 +914,8 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
defp process_polling_result(device, result, _socket) do
|
||||
snmp_device = device.snmp_device
|
||||
oid_values = Map.new(result.oid_values)
|
||||
timestamp = DateTime.from_unix!(result.timestamp, :second)
|
||||
# Use server time to avoid clock drift issues between agents
|
||||
timestamp = DateTime.utc_now()
|
||||
|
||||
Logger.info(
|
||||
"Processing polling result for #{device.name}: #{map_size(oid_values)} OIDs, #{length(snmp_device.sensors)} sensors, #{length(snmp_device.interfaces)} interfaces"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue