[v3] fff-simple-tc: provide status via nodewatcher

Submitted by Adrian Schmutzler on April 22, 2020, 2:54 p.m.

Details

Message ID 20200422145445.3764-1-freifunk@adrianschmutzler.de
State Accepted
Headers show

Commit Message

Adrian Schmutzler April 22, 2020, 2:54 p.m.
Add traffic control status and rates to alfred data, which is also
available for the Monitoring then.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

---

Changes in v3:
- Adapt for split nodewatcher
---
 src/packages/fff/fff-simple-tc/Makefile       |  2 +-
 .../usr/lib/nodewatcher.d/70-simple-tc.sh     | 23 +++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100755 src/packages/fff/fff-simple-tc/files/usr/lib/nodewatcher.d/70-simple-tc.sh

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-simple-tc/Makefile b/src/packages/fff/fff-simple-tc/Makefile
index 28f44052..015f85eb 100644
--- a/src/packages/fff/fff-simple-tc/Makefile
+++ b/src/packages/fff/fff-simple-tc/Makefile
@@ -1,7 +1,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-simple-tc
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
diff --git a/src/packages/fff/fff-simple-tc/files/usr/lib/nodewatcher.d/70-simple-tc.sh b/src/packages/fff/fff-simple-tc/files/usr/lib/nodewatcher.d/70-simple-tc.sh
new file mode 100755
index 00000000..309b62d7
--- /dev/null
+++ b/src/packages/fff/fff-simple-tc/files/usr/lib/nodewatcher.d/70-simple-tc.sh
@@ -0,0 +1,23 @@ 
+#!/bin/sh
+
+. /lib/functions.sh
+
+config_load simple-tc
+tc_enabled="0"
+tc_in="0"
+tc_out="0"
+parseTcInterface() {
+	local iface="$1"
+
+	config_get ifname "$iface" ifname
+	[ "wan" = "$ifname" ] || return
+
+	config_get tc_enabled "$iface" enabled "0"
+	config_get tc_in "$iface" limit_ingress "0"
+	config_get tc_out "$iface" limit_egress "0"
+}
+config_foreach parseTcInterface 'interface'
+
+echo -n "<traffic_control><wan><enabled>$tc_enabled</enabled><in>$tc_in</in><out>$tc_out</out></wan></traffic_control>"
+
+exit 0

Comments

Fabian Blaese April 22, 2020, 3:12 p.m.
Reviewed-by: Fabian Bläse <fabian@blaese.de>
Fabian Blaese April 23, 2020, 10:07 a.m.
applied.