diff --git a/lib/snmpkit/snmp_lib/cache.ex b/lib/snmpkit/snmp_lib/cache.ex index 22d2be72..4d0da691 100644 --- a/lib/snmpkit/snmp_lib/cache.ex +++ b/lib/snmpkit/snmp_lib/cache.ex @@ -354,9 +354,9 @@ defmodule SnmpKit.SnmpLib.Cache do @impl GenServer def init(opts) do # Create ETS tables - :ets.new(@cache_table, [:named_table, :set, :public, read_concurrency: true]) - :ets.new(@stats_table, [:named_table, :set, :public]) - :ets.new(@access_table, [:named_table, :bag, :public]) + _ = :ets.new(@cache_table, [:named_table, :set, :public, read_concurrency: true]) + _ = :ets.new(@stats_table, [:named_table, :set, :public]) + _ = :ets.new(@access_table, [:named_table, :bag, :public]) state = %__MODULE__{ max_size: Keyword.get(opts, :max_size, @default_max_size), diff --git a/lib/snmpkit/snmp_lib/config.ex b/lib/snmpkit/snmp_lib/config.ex index 6df1cd86..61579daf 100644 --- a/lib/snmpkit/snmp_lib/config.ex +++ b/lib/snmpkit/snmp_lib/config.ex @@ -350,9 +350,9 @@ defmodule SnmpKit.SnmpLib.Config do @impl GenServer def init(opts) do # Create ETS tables for fast access - :ets.new(@config_table, [:named_table, :set, :public, read_concurrency: true]) - :ets.new(@schema_table, [:named_table, :set, :public, read_concurrency: true]) - :ets.new(@watchers_table, [:named_table, :bag, :public]) + _ = :ets.new(@config_table, [:named_table, :set, :public, read_concurrency: true]) + _ = :ets.new(@schema_table, [:named_table, :set, :public, read_concurrency: true]) + _ = :ets.new(@watchers_table, [:named_table, :bag, :public]) # Detect environment environment = detect_environment(opts) diff --git a/lib/snmpkit/snmp_lib/dashboard.ex b/lib/snmpkit/snmp_lib/dashboard.ex index 669c48bf..ff065e03 100644 --- a/lib/snmpkit/snmp_lib/dashboard.ex +++ b/lib/snmpkit/snmp_lib/dashboard.ex @@ -332,9 +332,9 @@ defmodule SnmpKit.SnmpLib.Dashboard do @impl GenServer def init(opts) do # Create ETS tables for metrics storage - :ets.new(@metrics_table, [:named_table, :bag, :public]) - :ets.new(@alerts_table, [:named_table, :bag, :public]) - :ets.new(@timeseries_table, [:named_table, :ordered_set, :public]) + _ = :ets.new(@metrics_table, [:named_table, :bag, :public]) + _ = :ets.new(@alerts_table, [:named_table, :bag, :public]) + _ = :ets.new(@timeseries_table, [:named_table, :ordered_set, :public]) state = %__MODULE__{ port: Keyword.get(opts, :port, @default_port), diff --git a/lib/snmpkit/snmp_lib/error_handler.ex b/lib/snmpkit/snmp_lib/error_handler.ex index 3b71f680..0e370488 100644 --- a/lib/snmpkit/snmp_lib/error_handler.ex +++ b/lib/snmpkit/snmp_lib/error_handler.ex @@ -404,11 +404,9 @@ defmodule SnmpKit.SnmpLib.ErrorHandler do @spec quarantined?(device_id()) :: boolean() def quarantined?(device_id) do case get_device_stats(device_id) do - {:ok, stats} -> - case stats.quarantine_until do - nil -> false - until_time -> System.monotonic_time(:millisecond) < until_time - end + {:ok, _stats} -> + # quarantine_until is always nil in current implementation + false {:error, _} -> false @@ -649,16 +647,8 @@ defmodule SnmpKit.SnmpLib.ErrorHandler do # Simplified calculation - in production would use historical percentiles base_calculation = trunc(stats.avg_response_time * safety_factor) - # Adjust based on circuit state - adjustment = - case stats.circuit_state do - # Longer timeout for unhealthy devices - :open -> 2.0 - # Moderate timeout during testing - :half_open -> 1.5 - # Normal timeout for healthy devices - :closed -> 1.0 - end + # Adjust based on circuit state (currently always :closed) + adjustment = 1.0 calculated = trunc(base_calculation * adjustment) diff --git a/lib/snmpkit/snmp_lib/manager.ex b/lib/snmpkit/snmp_lib/manager.ex index f7ded5ff..ac005e94 100644 --- a/lib/snmpkit/snmp_lib/manager.ex +++ b/lib/snmpkit/snmp_lib/manager.ex @@ -65,7 +65,7 @@ defmodule SnmpKit.SnmpLib.Manager do @type version :: :v1 | :v2c @type operation_result :: {:ok, snmp_value()} | {:error, atom() | {atom(), any()}} @type bulk_result :: {:ok, [varbind()]} | {:error, atom() | {atom(), any()}} - @type varbind :: {oid(), snmp_value()} + @type varbind :: {oid(), atom(), snmp_value()} @type manager_opts :: [ community: community(), @@ -671,6 +671,10 @@ defmodule SnmpKit.SnmpLib.Manager do {:error, :invalid_response} end + defp extract_bulk_result(%{pdu: %{error_status: error_status}}) when error_status != 0 do + {:error, decode_error_status(error_status)} + end + defp extract_bulk_result(%{pdu: %{varbinds: varbinds}}) do valid_varbinds = Enum.filter(varbinds, fn {_oid, type, value} -> @@ -693,10 +697,6 @@ defmodule SnmpKit.SnmpLib.Manager do {:ok, valid_varbinds} end - defp extract_bulk_result(%{pdu: %{error_status: error_status}}) when error_status != 0 do - {:error, decode_error_status(error_status)} - end - defp extract_bulk_result(_), do: {:error, :invalid_response} defp extract_set_result(%{pdu: %{error_status: 0}}) do diff --git a/lib/snmpkit/snmp_lib/pdu.ex b/lib/snmpkit/snmp_lib/pdu.ex index bf297303..132c39f9 100644 --- a/lib/snmpkit/snmp_lib/pdu.ex +++ b/lib/snmpkit/snmp_lib/pdu.ex @@ -16,7 +16,7 @@ defmodule SnmpKit.SnmpLib.PDU do %{ type: :get_request | :get_next_request | :get_response | :set_request | :get_bulk_request, request_id: non_neg_integer(), - error_status: 0..5, + error_status: 0..18, error_index: non_neg_integer(), varbinds: [varbind()], # GETBULK only: diff --git a/lib/snmpkit/snmp_lib/pdu/constants.ex b/lib/snmpkit/snmp_lib/pdu/constants.ex index 5d61aa43..4eb182a0 100644 --- a/lib/snmpkit/snmp_lib/pdu/constants.ex +++ b/lib/snmpkit/snmp_lib/pdu/constants.ex @@ -57,7 +57,7 @@ defmodule SnmpKit.SnmpLib.PDU.Constants do @type snmp_version :: :v1 | :v2c | :v2 | :v3 | 0 | 1 | 3 @type pdu_type :: :get_request | :get_next_request | :get_response | :set_request | :get_bulk_request - @type error_status :: 0..5 + @type error_status :: 0..18 @type oid :: [non_neg_integer()] | binary() @type snmp_value :: any() @type varbind :: {oid(), atom(), snmp_value()} diff --git a/lib/towerops/application.ex b/lib/towerops/application.ex index 10a1f6a1..3d51adfd 100644 --- a/lib/towerops/application.ex +++ b/lib/towerops/application.ex @@ -22,9 +22,10 @@ defmodule Towerops.Application do # Note: With pre-compiled MIBs, this may no longer be needed snmpkit_ebin = Application.app_dir(:towerops, "../snmpkit/ebin") - if File.dir?(snmpkit_ebin) do - _ = :code.add_patha(to_charlist(snmpkit_ebin)) - end + _ = + if File.dir?(snmpkit_ebin) do + :code.add_patha(to_charlist(snmpkit_ebin)) + end # Run migrations on startup (Ecto handles locking for concurrent runs) _ = @@ -61,13 +62,7 @@ defmodule Towerops.Application do # Add each directory to net-snmp's search path Enum.each(mib_dirs, fn dir -> - case ToweropsNative.load_mib_directory(dir) do - :ok -> - :ok - - {:error, reason} -> - Logger.warning("Failed to load MIB directory #{dir}: #{inspect(reason)}") - end + :ok = ToweropsNative.load_mib_directory(dir) end) # Initialize the MIB library (loads all MIBs into memory) diff --git a/lib/towerops_web/live/device_live/show.ex b/lib/towerops_web/live/device_live/show.ex index b037488b..a54f5894 100644 --- a/lib/towerops_web/live/device_live/show.ex +++ b/lib/towerops_web/live/device_live/show.ex @@ -159,8 +159,8 @@ defmodule ToweropsWeb.DeviceLive.Show do defp maybe_subscribe_and_schedule_refresh(socket, device_id) do if connected?(socket) do - Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") - Process.send_after(self(), :refresh_data, 10_000) + _ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") + _ = Process.send_after(self(), :refresh_data, 10_000) end :ok diff --git a/lib/towerops_web/live/graph_live/show.ex b/lib/towerops_web/live/graph_live/show.ex index 18d0c796..a7b8b9ac 100644 --- a/lib/towerops_web/live/graph_live/show.ex +++ b/lib/towerops_web/live/graph_live/show.ex @@ -58,7 +58,7 @@ defmodule ToweropsWeb.GraphLive.Show do defp maybe_subscribe_to_device(socket, device_id) do if connected?(socket) do - Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") + _ = Phoenix.PubSub.subscribe(Towerops.PubSub, "device:#{device_id}") end :ok diff --git a/lib/towerops_web/plugs/remote_ip_logger.ex b/lib/towerops_web/plugs/remote_ip_logger.ex index 338c494e..708c4a8a 100644 --- a/lib/towerops_web/plugs/remote_ip_logger.ex +++ b/lib/towerops_web/plugs/remote_ip_logger.ex @@ -50,7 +50,6 @@ defmodule ToweropsWeb.Plugs.RemoteIpLogger do defp format_remote_ip({a, b, c, d}), do: "#{a}.#{b}.#{c}.#{d}" defp format_remote_ip({a, b, c, d, e, f, g, h}), do: format_ipv6({a, b, c, d, e, f, g, h}) - defp format_remote_ip(_), do: "unknown" defp format_ipv6({a, b, c, d, e, f, g, h}) do Enum.map_join([a, b, c, d, e, f, g, h], ":", &Integer.to_string(&1, 16)) diff --git a/lib/towerops_web/plugs/update_session_activity.ex b/lib/towerops_web/plugs/update_session_activity.ex index 580b2f72..bc4deabb 100644 --- a/lib/towerops_web/plugs/update_session_activity.ex +++ b/lib/towerops_web/plugs/update_session_activity.ex @@ -27,7 +27,7 @@ defmodule ToweropsWeb.Plugs.UpdateSessionActivity do token = get_session(conn, :user_token) if token do - Task.start(fn -> update_session_activity(token) end) + _ = Task.start(fn -> update_session_activity(token) end) end conn diff --git a/lib/towerops_web/user_auth.ex b/lib/towerops_web/user_auth.ex index 0de69030..f1aa016f 100644 --- a/lib/towerops_web/user_auth.ex +++ b/lib/towerops_web/user_auth.ex @@ -161,14 +161,16 @@ defmodule ToweropsWeb.UserAuth do remember_me = get_session(conn, :user_remember_me) # Create browser session in background with metadata - Task.start(fn -> - create_browser_session_from_conn(conn, user, user_token) - end) + _ = + Task.start(fn -> + create_browser_session_from_conn(conn, user, user_token) + end) # Record successful login attempt in background - Task.start(fn -> - record_successful_login(conn, user, params) - end) + _ = + Task.start(fn -> + record_successful_login(conn, user, params) + end) conn |> renew_session(user) diff --git a/mix.exs b/mix.exs index 2c84be3f..c9ee30c9 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,7 @@ defmodule Towerops.MixProject do start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), - compilers: [:towerops_nif, :phoenix_live_view] ++ Mix.compilers(), + compilers: [:phoenix_live_view] ++ Mix.compilers(), listeners: [Phoenix.CodeReloader], dialyzer: dialyzer() ]