[v2] nodewatcher: Provide data about traffic control

Submitted by Adrian Schmutzler on March 4, 2018, 12:36 a.m.

Details

Message ID 1520123794-3889-1-git-send-email-freifunk@adrianschmutzler.de
State New
Headers show

Commit Message

Adrian Schmutzler March 4, 2018, 12:36 a.m.
With this data, the Monitoring can show whether traffic control is
enabled and which rates are set.

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

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

---

Changes in v2:
- Used correct indentation
- Moved include to beginning

Anmerkung:
Man muss foreach machen, da die Bedingung "wan" = "$ifname" sich
auf eine option bezieht:

config interface 'example'
       option ifname 'wan'

Dies entspricht exakt dem eigentlichen Code von simple-tc. Sind
mehrere Blöcke mit ifname=wan vorhanden, wird also jeweils der
letzte ausgewertet, in dem das jeweilige Setting vorkommt.

Folglich kann ich hier das Interface nicht direkt anwählen.
---
 src/packages/fff/fff-nodewatcher/Makefile          |  2 +-
 .../fff/fff-nodewatcher/files/usr/sbin/nodewatcher | 24 +++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-nodewatcher/Makefile b/src/packages/fff/fff-nodewatcher/Makefile
index 11a0cb6..9d9cb28 100644
--- a/src/packages/fff/fff-nodewatcher/Makefile
+++ b/src/packages/fff/fff-nodewatcher/Makefile
@@ -1,7 +1,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-nodewatcher
-PKG_VERSION:=47
+PKG_VERSION:=48
 PKG_RELEASE:=1
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
diff --git a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
index 7b7bbd0..0823976 100755
--- a/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
+++ b/src/packages/fff/fff-nodewatcher/files/usr/sbin/nodewatcher
@@ -2,10 +2,13 @@ 
 # Netmon Nodewatcher (C) 2010-2012 Freifunk Oldenburg
 # License; GPL v3
 
-SCRIPT_VERSION="47"
+SCRIPT_VERSION="48"
 
 test -f /tmp/started || exit
 
+# Load libraries
+. /lib/functions.sh # Required for simple-tc
+
 #Get the configuration from the uci configuration file
 #If it does not exists, then get it from a normal bash file with variables.
 if [ -f /etc/config/nodewatcher ];then
@@ -280,6 +283,24 @@  crawl() {
         dataair="$dataair<airtime5><active>$w5_ACT</active><busy>$w5_BUS</busy></airtime5>"
     fi
 
+    # simple-tc information
+    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'
+    traffic_control="<traffic_control><wan><enabled>$tc_enabled</enabled><in>$tc_in</in><out>$tc_out</out></wan></traffic_control>"
+
     err "$(date): Putting all information into a XML-File and save it at $SCRIPT_DATA_FILE"
 
     DATA="<?xml version='1.0' standalone='yes'?><data>"
@@ -292,6 +313,7 @@  crawl() {
     DATA=$DATA"<client_count>$client_count</client_count>"
     DATA=$DATA"<clients>$dataclient</clients>"
     DATA=$DATA"$dataair"
+    DATA=$DATA"$traffic_control"
     DATA=$DATA"</data>"
 
     #write data to xml file that provides the data on httpd