Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions net/snmpd-openwrt-metrics/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# Copyright (C) 2026 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=snmpd-openwrt-metrics
PKG_VERSION:=1.0.0
PKG_RELEASE:=1

PKG_MAINTAINER:=Kamil Bienkiewicz <perceivalpercy@gmail.com>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=LICENSE

include $(INCLUDE_DIR)/package.mk

define Package/snmpd-openwrt-metrics
SECTION:=net
CATEGORY:=Network
TITLE:=OpenWrt wireless and sensor metrics over SNMP
URL:=https://openwrt.org
DEPENDS:=+snmpd +libnetsnmp +libiwinfo +libnl-tiny +libubus +libubox
endef

define Package/snmpd-openwrt-metrics/description
An AgentX subagent that exports per-interface wireless metrics under
OpenWrt's IANA enterprise number 66510 (OPENWRT-WIRELESS-MIB: clients,
frequency, noise floor, tx/rx rates, SNR, channel utilisation, tx power,
indexed by ifIndex so the table joins IF-MIB), the device's OpenWrt
release, build revision, target and model (OPENWRT-MIB), and hwmon
temperature and fan readings as LM-SENSORS-MIB, which net-snmp cannot
serve on OpenWrt because its lmSensors module predates the libsensors 3
API.

Wireless data comes from libiwinfo (SSIDs are asked of hostapd over
ubus first), so nothing needs configuring per radio or per VAP;
a multi-link (MLO) interface's per-link channel/tx power is queried
directly over nl80211 instead, since libiwinfo has no MLO
awareness. snmpd enables the AgentX master by default, so no snmpd
configuration is required either.
endef

TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include/libnl-tiny \
-D_GNU_SOURCE

define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Package/snmpd-openwrt-metrics/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt-snmp-agent $(1)/usr/sbin/

$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/openwrt-snmp-agent.init $(1)/etc/init.d/openwrt-snmp-agent

$(INSTALL_DIR) $(1)/usr/share/snmp/mibs
$(INSTALL_DATA) ./files/OPENWRT-MIB $(1)/usr/share/snmp/mibs/OPENWRT-MIB
$(INSTALL_DATA) ./files/OPENWRT-WIRELESS-MIB $(1)/usr/share/snmp/mibs/OPENWRT-WIRELESS-MIB
endef

$(eval $(call BuildPackage,snmpd-openwrt-metrics))
154 changes: 154 additions & 0 deletions net/snmpd-openwrt-metrics/files/OPENWRT-MIB
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
-- **********************************************************
-- OPENWRT-MIB
--
-- Base registration module for OpenWrt metrics exported by the
-- OpenWrt SNMP metrics agent (a net-snmp AgentX subagent).
Comment thread
perceival marked this conversation as resolved.
--
-- This module establishes the OpenWrt OID structure, defines the device
-- metadata scalars under openwrtSystem, and the openwrtProducts values an
-- agent may report as sysObjectID. The metrics themselves live in
-- per-subsystem modules that register beneath openwrtObjects, for example
-- OPENWRT-WIRELESS-MIB at { openwrtObjects 10 }.
--
-- Enterprise Number: 66510 (OpenWrt, IANA PEN)
-- OID Base: .1.3.6.1.4.1.66510
--
-- openwrtMIB is rooted directly under OpenWrt's own IANA-assigned enterprise
-- number, with no intermediate node.
--
-- Temperature/thermal data is exported separately via LM-SENSORS-MIB.
-- **********************************************************

OPENWRT-MIB DEFINITIONS ::= BEGIN

IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, enterprises
FROM SNMPv2-SMI
DisplayString
FROM SNMPv2-TC
MODULE-COMPLIANCE, OBJECT-GROUP
FROM SNMPv2-CONF;

openwrtMIB MODULE-IDENTITY
LAST-UPDATED "202609220000Z"
ORGANIZATION "OpenWrt"
CONTACT-INFO
" OpenWrt Project
https://openwrt.org
https://github.com/openwrt/openwrt
"
DESCRIPTION
"Base module describing the OpenWrt OID structure used by the
OpenWrt SNMP metrics agent, the device metadata scalars under
openwrtSystem, and the sysObjectID values under openwrtProducts.
Per-subsystem metrics register under openwrtObjects (wireless at
{ openwrtObjects 10 }); conformance registers under
openwrtConformance."
REVISION "202609220000Z"
DESCRIPTION
"Added openwrtSystem device metadata scalars (release version,
build revision, target and device model) and openwrtProducts, so
a manager can identify an OpenWrt device and its release without
extend scripts."
REVISION "202608130000Z"
DESCRIPTION
"Initial version: base registration nodes for the OpenWrt subtree."
::= { enterprises 66510 }

-- **********************************************************
-- Structure
-- **********************************************************

openwrtObjects OBJECT IDENTIFIER ::= { openwrtMIB 1 }
openwrtConformance OBJECT IDENTIFIER ::= { openwrtMIB 2 }
openwrtProducts OBJECT IDENTIFIER ::= { openwrtMIB 3 }

-- **********************************************************
-- Products (sysObjectID values)
-- **********************************************************

-- sysObjectID for a device running OpenWrt, whatever the hardware; the
-- device model is in openwrtSysModel. snmpd reports this only when
-- configured to (net-snmp's own default is its generic Linux value).
openwrtDevice OBJECT IDENTIFIER ::= { openwrtProducts 1 }

-- **********************************************************
-- Device metadata
-- **********************************************************

openwrtSystem OBJECT IDENTIFIER ::= { openwrtObjects 1 }

openwrtSysVersion OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"OpenWrt release version, for example 24.10.2, or SNAPSHOT for a
development build: the VERSION field of /etc/os-release.
Not instantiated if the device does not provide it."
::= { openwrtSystem 1 }

openwrtSysRevision OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Source revision the running firmware was built from, for example
r28427-6df0e3d02a: the BUILD_ID field of /etc/os-release. This is
what tells one SNAPSHOT build from another. Not instantiated if the
device does not provide it."
::= { openwrtSystem 2 }

openwrtSysTarget OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"OpenWrt target and subtarget the firmware was built for, for
example mediatek/filogic: the OPENWRT_BOARD field of
/etc/os-release. Not instantiated if the device does not provide
it."
::= { openwrtSystem 3 }

openwrtSysModel OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Human-readable device model, for example Linksys WRT1200AC, as
OpenWrt determined it at boot (/tmp/sysinfo/model). Not
instantiated if the device does not provide it."
::= { openwrtSystem 4 }

-- **********************************************************
-- Conformance
-- **********************************************************

openwrtCompliances OBJECT IDENTIFIER ::= { openwrtConformance 1 }
openwrtGroups OBJECT IDENTIFIER ::= { openwrtConformance 2 }

openwrtSystemGroup OBJECT-GROUP
OBJECTS {
openwrtSysVersion,
openwrtSysRevision,
openwrtSysTarget,
openwrtSysModel
}
STATUS current
DESCRIPTION
"OpenWrt device metadata."
::= { openwrtGroups 1 }

openwrtCompliance MODULE-COMPLIANCE
STATUS current
DESCRIPTION
"Compliance statement for OpenWrt SNMP agents."
MODULE -- this module
GROUP openwrtSystemGroup
DESCRIPTION
"Optional: each object in this group is instantiated only when the
device provides the underlying value, so an agent may implement
any subset of it."
::= { openwrtCompliances 1 }

END
Loading
Loading