Fix SNMP polling: remove invalid timeout option and normalize OID format

System.cmd :timeout option doesn't exist in Elixir 1.19, causing every
poll to crash silently. Also translate SNMPv2-SMI::enterprises prefix
to numeric OID so the lookup maps match correctly.
This commit is contained in:
Graham McIntire 2026-03-30 13:44:49 -05:00
parent d3f9f0443e
commit dd12a57c2d
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -47,8 +47,6 @@ defmodule Microwaveprop.Commercial.SnmpClient do
19 => {:remote_tx_power, :raw}
}
@snmp_timeout 5_000
def poll(host, community, "af11x"), do: poll_af11x(host, community)
def poll(host, community, "af60"), do: poll_af60(host, community)
@ -134,7 +132,7 @@ defmodule Microwaveprop.Commercial.SnmpClient do
end
defp run_cmd(cmd, args) do
System.cmd(cmd, args, stderr_to_stdout: true, timeout: @snmp_timeout)
System.cmd(cmd, args, stderr_to_stdout: true)
rescue
ErlangError -> {"command not found: #{cmd}", 127}
end
@ -154,6 +152,7 @@ defmodule Microwaveprop.Commercial.SnmpClient do
defp normalize_oid(oid) do
oid
|> String.replace(~r/^SNMPv2-SMI::enterprises\./, "1.3.6.1.4.1.")
|> String.replace(~r/^iso\./, "1.")
|> String.replace(~r/^\./, "")
end