prometheus-node-exporter-lua: fix hostapd_stations ifname detection
Maintainer: Etienne CHAMPETIER [email protected] Compile tested: Nothing to compile - only scrpiting changes Run tested: arm_cortex-a7_neon-vfpv4, Google Wi-Fi, OpenWrt 23.05.3 r23809-234f1a2efa / LuCI openwrt-23.05 branch git-24.086.45142-09d5a38
Description:
ubus call wireless.network status currently lists ifname as a key under the "interfaces" list for each radio instead of the config subkey. Therefore no interfaces or stations are returned at scrape time.
This is currently the only way I've found to collect per-device bytes metrics without recompiling iwinfo. iwinfo_lua.c only exposes packet information for some reason, even though the relevant struct iwinfo_assoclist_entry contains tx_bytes and rx_bytes. I'm currently waiting on that PR to get merged as well. This would enable metrics collection using a basic version of wpad instead of a full one.
Tests done: Call `http://router:9100/metrics and observe hostapd station metrics are returned.
root@router:~# ubus call network.wireless status
{
"radio0": {
"up": true,
"pending": false,
"autostart": true,
"disabled": false,
"retry_setup_failed": false,
"config": {
"path": "platform/soc/a000000.wifi",
"channel": "1",
"band": "2g",
"htmode": "HT20",
"cell_density": 0,
"txpower": 27
},
"interfaces": [
{
"section": "wifinet0",
"ifname": "phy0-ap0",
"config": {
"mode": "ap",
"ssid": "SSIDName",
"encryption": "psk2",
"key": "PASSWORD",
"ieee80211r": true,
"ft_over_ds": false,
"ft_psk_generate_local": true,
"mode": "ap",
"network": [
"lan"
]
},
"vlans": [
],
"stations": [
]
}
]
},
"radio1": {
}
}
You can use the following command to replicate the changes made in this PR after installing the package:
sed -i "s/cfg\['ifname'\]/intf\['ifname'\]/g" /usr/lib/lua/prometheus-collectors/hostapd_stations.lua
Signed-off-by: Michael Payne [email protected]