diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index 8dd85260..19dc67b3 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -951,8 +951,11 @@ defmodule ToweropsWeb.AgentChannel do # Fetch interfaces once for reuse across multiple operations interfaces = Towerops.Snmp.list_interfaces(device.snmp_device.id) + # Add device_id to interfaces for neighbor discovery (required by build_neighbor_record) + interfaces_with_device_id = Enum.map(interfaces, &Map.put(&1, :device_id, device.id)) + # Process neighbors (LLDP/CDP) - case NeighborDiscovery.discover_neighbors(client_opts, interfaces) do + case NeighborDiscovery.discover_neighbors(client_opts, interfaces_with_device_id) do {:ok, neighbors} when neighbors != [] -> Towerops.Snmp.Discovery.save_neighbors(device.id, neighbors)