Add backward compatibility for PING results from older agents
Older agents send PING job results as SnmpResult messages instead of MonitoringCheck messages, causing FunctionClauseError when process_job_result/3 tried to pattern match on job_type: :PING. Added handler that: - Catches PING results in SnmpResult format - Logs warning that agent should be upgraded - Creates monitoring check with success status - Stores result via store_monitoring_check This prevents crashes while maintaining backward compatibility until all production agents are upgraded to use MonitoringCheck format. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
fbce65070a
commit
ecd9f78ba8
1 changed files with 22 additions and 0 deletions
|
|
@ -1163,6 +1163,28 @@ defmodule ToweropsWeb.AgentChannel do
|
|||
process_polling_result(device, result, socket)
|
||||
end
|
||||
|
||||
defp process_job_result(device, %{job_type: :PING} = result, socket) do
|
||||
# Backward compatibility: older agents send PING results as SnmpResult instead of MonitoringCheck
|
||||
# Newer agents should use the "monitoring_check" event instead
|
||||
Logger.warning("Agent sent PING result as SnmpResult (deprecated). Agent should be upgraded.",
|
||||
agent_token_id: socket.assigns.agent_token_id,
|
||||
device_id: device.id,
|
||||
job_id: result.job_id
|
||||
)
|
||||
|
||||
# PING jobs sent as SnmpResult have empty oid_values
|
||||
# If we receive a result (not an error), assume success
|
||||
check = %{
|
||||
device_id: device.id,
|
||||
status: "success",
|
||||
# Unknown - older agents don't send this
|
||||
response_time_ms: 0.0,
|
||||
timestamp: result.timestamp
|
||||
}
|
||||
|
||||
store_monitoring_check(check, socket)
|
||||
end
|
||||
|
||||
defp process_discovery_result(device, result, socket) do
|
||||
Logger.info("Discovery results received from agent for #{device.name}, processing data")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue