add diagnostic logging for agent result handling

This commit is contained in:
Graham McIntire 2026-02-11 12:00:04 -06:00
parent e4623f0c3d
commit bd24dfcbed
No known key found for this signature in database

View file

@ -334,6 +334,8 @@ defmodule ToweropsWeb.AgentChannel do
@impl true
@spec handle_in(String.t(), map(), socket()) :: {:noreply, socket()}
def handle_in("result", %{"binary" => binary_b64}, socket) when is_binary(binary_b64) do
Logger.info("Received SNMP result from agent (binary size: #{byte_size(binary_b64)})")
with {:ok, binary} <- safe_base64_decode(binary_b64),
{:ok, result} <- Validator.validate_snmp_result(binary) do
maybe_debug_log(socket, "Received SNMP result from agent",
@ -547,6 +549,17 @@ defmodule ToweropsWeb.AgentChannel do
end
end
# Catch-all for unmatched events (diagnostic)
def handle_in(event, payload, socket) do
Logger.warning("Unhandled agent channel event",
event: event,
payload_keys: Map.keys(payload),
agent_token_id: socket.assigns.agent_token_id
)
{:noreply, socket}
end
# Private helpers
@spec handle_validated_mikrotik_result(MikrotikResult.t(), socket()) :: {:noreply, socket()}