fix: suppress repetitive SNMP MIB resolution errors

Add logger filter to drop repetitive 'Cannot find module' errors
from net-snmp library. These errors occur when snmptranslate can't
find vendor-specific MIB modules but don't affect functionality
since the system falls back to numeric OIDs.

The errors were flooding production logs (hundreds of identical
messages) during polling of Morningstar devices that reference
TRISTAR MIB modules.

Changes:
- Add drop_snmp_mib_errors/2 filter to LoggerFilters module
- Register filter in production logger configuration
- Filter matches exact error format from snmptranslate stderr

The root cause (missing NIF binary) will be addressed separately
by compiling the towerops_nif.so during Docker build.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Graham McIntire 2026-02-08 14:09:26 -06:00
parent bc8e8a4261
commit 9df53b1629
No known key found for this signature in database
2 changed files with 26 additions and 1 deletions

View file

@ -1,11 +1,15 @@
import Config
# Filter out harmless Oban shutdown messages during deployments
# Filter out harmless Oban shutdown messages and repetitive SNMP MIB errors
config :logger, :default_handler,
filters: [
drop_oban_shutdown: {
&Towerops.LoggerFilters.drop_oban_shutdown/2,
[]
},
drop_snmp_mib_errors: {
&Towerops.LoggerFilters.drop_snmp_mib_errors/2,
[]
}
]

View file

@ -42,4 +42,25 @@ defmodule Towerops.LoggerFilters do
String.contains?(msg, "EXIT") and
String.contains?(msg, ":shutdown")
end
@doc """
Drops repetitive SNMP MIB resolution errors from net-snmp library.
These errors occur when snmptranslate can't find vendor-specific MIB modules.
The errors are logged repeatedly during polling but don't affect functionality
since the system falls back to numeric OIDs.
Example messages filtered:
- "Cannot find module (TRISTAR): At line 1 in (none)"
- "Cannot find module (VENDOR-MIB): At line 1 in (none)"
"""
def drop_snmp_mib_errors(log_event, _opts) do
if snmp_mib_error?(log_event), do: :stop, else: :ignore
end
defp snmp_mib_error?(%{msg: {:string, msg}}) when is_binary(msg) do
String.contains?(msg, "Cannot find module") and String.contains?(msg, "At line 1 in (none)")
end
defp snmp_mib_error?(_), do: false
end