Repository navigation
snmpd-openwrt-metrics: add new package #30547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
perceival
wants to merge
1
commit into
openwrt:master
Choose a base branch
from
perceival:snmpd-openwrt-metrics-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). | ||
| -- | ||
| -- 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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.