From 4bc2b626105dd02115cba2f4b1a7f5e39d0be1df Mon Sep 17 00:00:00 2001 From: "Kim B. Heino" Date: Wed, 7 Oct 2020 13:16:35 +0300 Subject: [PATCH] wireless: add new plugin to get info about OpenWRT's APs Following info is returned, per AP: - Signal strength (dBm) - Number of associated clients --- Makefile | 2 +- muninlite.in | 5 +++++ plugins/wireless | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 plugins/wireless diff --git a/Makefile b/Makefile index 016f715..e96ae3a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PLUGINS ?= df cpu if_ if_err_ load memory processes swap netstat uptime interrupts irqstats ntpdate plugindir_ +PLUGINS ?= df cpu if_ if_err_ load memory processes swap netstat uptime interrupts irqstats ntpdate wireless plugindir_ CONFIGURATION_FILE ?= muninlite.conf INPUT_FILE ?= muninlite.in TARGET_FILE ?= muninlite diff --git a/muninlite.in b/muninlite.in index e9e421f..003b2c6 100755 --- a/muninlite.in +++ b/muninlite.in @@ -86,6 +86,11 @@ for PLUG in $PLUGINS; do RES="$RES netstat" fi ;; + wireless) + if iwinfo >/dev/null 2>&1; then + RES="${RES} ${PLUG}" + fi + ;; plugindir_) for MYPLUGIN in $(if [ -d "$PLUGIN_DIRECTORY" ]; then find -L "$PLUGIN_DIRECTORY" -type f -name "$PLUGINPATTERN"; fi); do if [ -f "$MYPLUGIN" ] && [ -x "$MYPLUGIN" ]; then diff --git a/plugins/wireless b/plugins/wireless new file mode 100644 index 0000000..f9de52f --- /dev/null +++ b/plugins/wireless @@ -0,0 +1,38 @@ +config_wireless() { + interfaces=$(iwinfo 2> /dev/null | sed '/^wlan/!d; s/ .*//g; /-/d') + for interface in ${interfaces} + do + echo "multigraph wireless_${interface} +graph_title WLAN ${interface} AP Statistics +graph_vlabel Strength (dBm) +graph_category network +graph_scale no +signal.label Signal +noise.label Noise" + done + interfaces=$(iwinfo 2> /dev/null | sed '/^wlan/!d; s/ .*//g') + for interface in ${interfaces} + do + echo "multigraph wireless_assoc_${interface/-/_} +graph_title WLAN ${interface} associations +graph_vlabel Clients +graph_args --lower-limit 0 +graph_category network +graph_scale no +clients.label Clients" + done +} +fetch_wireless() { + interfaces=$(iwinfo 2> /dev/null | sed '/^wlan/!d; s/ .*//g; /-/d') + for interface in ${interfaces} + do + echo "multigraph wireless_${interface}" + iwinfo ${interface} info | sed -r 's/unknown/0 dBm/g; /Signal.*Noise/!d; s/^.* Signal: ([-0-9]+) dBm Noise: ([-0-9]+) dBm/signal.value \1\nnoise.value \2/' + done + interfaces=$(iwinfo 2> /dev/null | sed '/^wlan/!d; s/ .*//g') + for interface in ${interfaces} + do + echo "multigraph wireless_assoc_${interface/-/_}" + echo "clients.value $(iwinfo ${interface} assoc | grep -c SNR)" + done +}