diff --git a/lib/towerops/snmp/deferred_discovery.ex b/lib/towerops/snmp/deferred_discovery.ex index 807a0d7b..516e3f95 100644 --- a/lib/towerops/snmp/deferred_discovery.ex +++ b/lib/towerops/snmp/deferred_discovery.ex @@ -181,12 +181,18 @@ defmodule Towerops.Snmp.DeferredDiscovery do port = Keyword.get(client_opts, :port, 161) adapter = Keyword.get(client_opts, :adapter, "Real SNMP") + # Safely format community string (may be nil) + community_display = + if community && String.length(community) > 0, + do: String.slice(community, 0..3) <> "***", + else: "(none)" + Logger.warning( "Device #{ip} categorized as unresponsive - SNMP GET failed", ip: ip, port: port, version: version, - community: String.slice(community, 0..3) <> "***", + community: community_display, adapter: inspect(adapter), error: inspect(reason) )