Repository navigation
Conversation
Formality Check: Suggestions AvailableWe checked this pull request against the contribution guidelines. Here is what needs your attention:
|
4a8286f to
ea6f205
Compare
|
The build succeeds on every architecture here. The two failing CI jobs (x86_64, arm_cortex-a15_neon-vfpv4) are dying in the post-build Docker runtime smoke test, at |
ea6f205 to
7c7fa76
Compare
7c7fa76 to
f5073a0
Compare
f5073a0 to
633e140
Compare
Both MIB files had drifted from openwrt/packages#30547's copies, which picked up a new openwrtWirelessLinkTable (per-link MLO metrics), the pass_persist->AgentX rename, and broadened noSuchInstance semantics on several columns since this PR last touched them. Re-synced from the packages source of truth; both still smilint -l 6 clean. Openwrt.php's WL_ENTRY comment still called the device-side agent a "pass_persist handler" - same stale wording, fixed to "AgentX subagent". The device note documented installing shell scripts (openwrt-snmp-pass.sh, lm-sensors-pass.sh) that don't exist in librenms-agent - that implementation's PR (librenms-agent#613) was closed once the native package proved out, and only fragments of the old per-script approach remain there. Rewritten to state the two MIB subtrees this PR actually depends on and point at the native package as the reference implementation, without prescribing an install method - matches this PR's own description ("doesn't depend on any particular way of getting them there") and drops the version-specific install/troubleshooting steps laf asked to avoid on this same page in 2026-06. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TDZtSTSfXU8FJqs1cXGPSY
633e140 to
5e6cd1f
Compare
5e6cd1f to
521d532
Compare
cd67a0f to
3b476e7
Compare
| # start first, that is not fatal: net-snmp's AgentX subagent retries | ||
| # the master connection on its own alarm-driven schedule | ||
| # (agentx_reopen_session in agentx/subagent.c). The enabled check just | ||
| # avoids starting when snmpd is off entirely. |
There was a problem hiding this comment.
This should go into the commit message. If the order of the startup sequence ever changes, no one will remember that the comment here needs to be updated. And then the comment is wrong.
If anything, the agent it self tries to reconnect only if it hasn't started yet.
There was a problem hiding this comment.
Moved the ordering rationale out of the script and into the commit message ("Init ordering" paragraph), so the script no longer carries a comment that can go stale. Landed in e16b60b.
| # the master connection on its own alarm-driven schedule | ||
| # (agentx_reopen_session in agentx/subagent.c). The enabled check just | ||
| # avoids starting when snmpd is off entirely. | ||
| /etc/init.d/snmpd enabled || return 0 |
There was a problem hiding this comment.
A log message should be added so that we know why this did not start.
There was a problem hiding this comment.
Added: when snmpd is not enabled the script now logs "snmpd is not enabled, not starting" via logger (daemon.notice, tag openwrt-snmp-agent). Checked on a Flint 3 with snmpd disabled: the line shows up in logread and no agent process is started. Landed in e16b60b.
| /etc/init.d/snmpd enabled || return 0 | ||
|
|
||
| procd_open_instance | ||
| procd_set_param command "$PROG" -f -x /var/run/agentx.sock |
There was a problem hiding this comment.
The socket can be changed via uci
https://github.com/openwrt/packages/blob/master/net/net-snmp/files/snmpd.init#L21
There was a problem hiding this comment.
Good point, thanks. The init script now reads agentxsocket from the agentx section of /etc/config/snmpd (default /var/run/agentx.sock) and passes it to the agent with -x. Checked on a Flint 3 with the default and with a custom agentxsocket: the agent connects to the configured socket and the 1.3.6.1.4.1.66510 objects are served through snmpd. Landed in e16b60b.
There was a problem hiding this comment.
Has this file been checked for syntax errors using a linter?
|
|
||
| #include "collect.h" | ||
|
|
||
| #define AGENT_VERSION "1.0.0" |
There was a problem hiding this comment.
This should be provided via the Makefile. It's likely to be overlooked during an update.
There was a problem hiding this comment.
The closing */ should go into a new line
And multi line comments should look like this.
/* ------------------------------------------------------------------
* <message>
* ------------------------------------------------------------------
*/
There was a problem hiding this comment.
The closing */ should go into a new line
And multi line comments should look like this.
/* ------------------------------------------------------------------
* <message>
* ------------------------------------------------------------------
*/
| } else if (!strcmp(argv[i], "--version") || | ||
| !strcmp(argv[i], "-V") || | ||
| !strcmp(argv[i], "--help")) { | ||
| printf("openwrt-snmp-agent " AGENT_VERSION "\n"); |
There was a problem hiding this comment.
The name of the programm is available via argv[0]
3b476e7 to
e16b60b
Compare
Stock OpenWrt reports nothing useful about its wireless side or its
sensors over SNMP. The ieee802dot11 MIB module is compiled into net-snmp
but produces no data on mac80211 drivers, and net-snmp's lmSensors module
cannot be enabled because it still targets the libsensors 2 API that
lm-sensors 3 removed.
Add a small AgentX subagent serving three subtrees:
.1.3.6.1.4.1.66510.1.1 OPENWRT-MIB device metadata: release version,
build revision, target and model, so a manager
can identify the device without extend scripts
.1.3.6.1.4.1.66510.1.10 OPENWRT-WIRELESS-MIB, under OpenWrt's own IANA
enterprise number, indexed by ifIndex so rows
join IF-MIB: clients, frequency, noise floor,
tx/rx rate range, SNR range, channel
utilisation, tx power, and (for 802.11be
Multi-Link Operation interfaces, which have no
single value for those columns) a separate
per-radio-link table
.1.3.6.1.4.1.2021.13.16 LM-SENSORS-MIB temperature and fan tables
Wireless data comes from libiwinfo, MLO per-link data from a direct
nl80211 query (libiwinfo has no MLO awareness), and sensor data from
hwmon and thermal zones, taking the union of the two so a sensor with no
thermal zone (an MDIO PHY die sensor, for example) is still reported.
snmpd enables the AgentX master by default and listens on a known
socket, so the package needs no snmpd configuration at all: no pass
registration, no uci-defaults, no removal hook. If the socket was moved
with the agentxsocket option of the snmpd agentx section, the init script
reads it from there and passes it to the agent. Radios, VAPs and sensors
are discovered at request time, so there is nothing per-interface to
maintain either.
The SSID of each interface is read from hostapd over ubus, with libiwinfo
as the fallback, because libiwinfo returns no SSID for some VAPs on a
tri-band phy.
--dump also lists the temperature and fan sensors the agent finds, which
is what to check when a device reports no LM-SENSORS data.
Tested on a GL-BE9300 (qualcommbe/ipq53xx), including its 802.11be
multi-link (5GHz+6GHz) AP, and cross-checked against `iwinfo`/`iw`/sysfs
output and a live AgentX registration against snmpd with `snmpwalk`.
OPENWRT-MIB also defines openwrtDevice (.1.3.6.1.4.1.66510.3.1) as a
sysObjectID value for snmpd to report; setting it is left to snmpd's own
config.
Init ordering: the AgentX master lives in snmpd, which starts at START=99,
the top of the two-digit range (rc.common's glob-based enable/disable
needs two digits, see rc.common), so nothing can be ordered strictly
after it. The agent therefore starts at START=95 and relies on net-snmp's
AgentX subagent retrying the master connection on its own schedule
(agentx_reopen_session in agentx/subagent.c). The init script only
checks that snmpd is enabled and logs when it is not. If the startup
order of the base system ever changes, this is the assumption to
re-check.
Signed-off-by: Kamil Bienkiewicz <perceivalpercy@gmail.com>
e16b60b to
cecd716
Compare
📦 Package Details
Maintainer: @perceival
Description:
Stock OpenWrt reports nothing useful about its wireless side or its sensors over SNMP: the
ieee802dot11MIB module produces no data on mac80211 drivers, and net-snmp'slmSensorsmodule can't be enabled because it still targets the libsensors 2 API that lm-sensors 3 removed.This adds a small AgentX subagent that serves three subtrees under OpenWrt's own IANA enterprise number (66510) and the standard LM-SENSORS-MIB arc: device metadata (OpenWrt release, build revision, target and model, so a manager can identify the device without extend scripts), a per-interface wireless table (clients, frequency, noise floor, tx/rx rate range, SNR range, channel utilisation, tx power, indexed by ifIndex so it joins IF-MIB) plus a per-radio-link table for 802.11be Multi-Link Operation interfaces (which have no single value for those columns), and hwmon/thermal-zone temperature and fan readings. Wireless data comes from libiwinfo, MLO per-link data from a direct nl80211 query (libiwinfo has no MLO awareness), and sensor data from the union of hwmon and thermal zones. No snmpd configuration is required — the AgentX master is on by default.
OPENWRT-MIB also defines
openwrtDevice(.1.3.6.1.4.1.66510.3.1) as a sysObjectID value for snmpd to report, so a manager can recognise an OpenWrt device without querying anything extra. Setting it is left to snmpd's own config, not done by this package.This is the device-side implementation for LibreNMS PR librenms/librenms#19347, replacing the shell
pass_persistscript that PR originally described.🧪 Run Testing Details
Verified on all three:
--version/-V/--help, a full SNMP walk of both MIB tables against each device's realsnmpd(viasnmpwalk), and (on the two Flint 3 units) that the multi-link interface's per-link table matchesiw dev <iface> infoexactly while the main interface table correctly reports its radio-scoped columns as absent rather than a misleading single value. On the R7800 (no 802.11be hardware) confirmed the link table is genuinely absent rather than present-but-empty.The device metadata scalars were verified on the R7800 against that device's own
/etc/os-releaseand/tmp/sysinfo/model, including that a walk passes through them into the wireless subtree and that a field the device does not provide is simply not instantiated. Settingoption sysObjectIDin snmpd's config was confirmed to make snmpd report it.✅ Formalities
If your PR contains a patch:
N/A — this is a new package, not a patch.