diff --git a/lib/towerops/snmp/client.ex b/lib/towerops/snmp/client.ex index 014830cb..f26532ea 100644 --- a/lib/towerops/snmp/client.ex +++ b/lib/towerops/snmp/client.ex @@ -45,17 +45,22 @@ defmodule Towerops.Snmp.Client do # Only log warnings for actual communication errors, not missing OIDs case reason do :no_such_object -> - Logger.debug("SNMP object not found: #{inspect(oid)}") + Logger.debug("SNMP object not found for #{target}: #{inspect(oid)}") :no_such_instance -> - Logger.debug("SNMP instance not found: #{inspect(oid)}") + Logger.debug("SNMP instance not found for #{target}: #{inspect(oid)}") :end_of_mib_view -> - Logger.debug("End of MIB view reached: #{inspect(oid)}") + Logger.debug("End of MIB view reached for #{target}: #{inspect(oid)}") _ -> # Actual errors like timeout, network issues, etc. - Logger.warning("SNMP GET failed for #{inspect(oid)}: #{inspect(reason)}") + timeout = Keyword.get(opts, :timeout, @default_timeout) + version = Keyword.fetch!(opts, :version) + + Logger.warning( + "SNMP GET failed for #{target} (v#{version}, timeout: #{timeout}ms) OID #{inspect(oid)}: #{inspect(reason)}" + ) end error @@ -123,16 +128,21 @@ defmodule Towerops.Snmp.Client do # Only log warnings for actual communication errors case reason do :no_such_object -> - Logger.debug("SNMP WALK: object not found at #{inspect(start_oid)}") + Logger.debug("SNMP WALK: object not found for #{target} at #{inspect(start_oid)}") :no_such_instance -> - Logger.debug("SNMP WALK: instance not found at #{inspect(start_oid)}") + Logger.debug("SNMP WALK: instance not found for #{target} at #{inspect(start_oid)}") :end_of_mib_view -> - Logger.debug("SNMP WALK: end of MIB view at #{inspect(start_oid)}") + Logger.debug("SNMP WALK: end of MIB view for #{target} at #{inspect(start_oid)}") _ -> - Logger.warning("SNMP WALK failed for #{inspect(start_oid)}: #{inspect(reason)}") + timeout = Keyword.get(opts, :timeout, @default_timeout) + version = Keyword.fetch!(opts, :version) + + Logger.warning( + "SNMP WALK failed for #{target} (v#{version}, timeout: #{timeout}ms) OID #{inspect(start_oid)}: #{inspect(reason)}" + ) end error @@ -170,16 +180,21 @@ defmodule Towerops.Snmp.Client do # Only log warnings for actual communication errors case reason do :no_such_object -> - Logger.debug("SNMP GET-BULK: object not found at #{inspect(start_oid)}") + Logger.debug("SNMP GET-BULK: object not found for #{target} at #{inspect(start_oid)}") :no_such_instance -> - Logger.debug("SNMP GET-BULK: instance not found at #{inspect(start_oid)}") + Logger.debug("SNMP GET-BULK: instance not found for #{target} at #{inspect(start_oid)}") :end_of_mib_view -> - Logger.debug("SNMP GET-BULK: end of MIB view at #{inspect(start_oid)}") + Logger.debug("SNMP GET-BULK: end of MIB view for #{target} at #{inspect(start_oid)}") _ -> - Logger.warning("SNMP GET-BULK failed for #{inspect(start_oid)}: #{inspect(reason)}") + timeout = Keyword.get(opts, :timeout, @default_timeout) + version = Keyword.fetch!(opts, :version) + + Logger.warning( + "SNMP GET-BULK failed for #{target} (v#{version}, timeout: #{timeout}ms) OID #{inspect(start_oid)}: #{inspect(reason)}" + ) end error