From patchwork Sun Mar 4 00:36:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [v2] nodewatcher: Provide data about traffic control From: Adrian Schmutzler X-Patchwork-Id: 810 Message-Id: <1520123794-3889-1-git-send-email-freifunk@adrianschmutzler.de> To: franken-dev@freifunk.net Date: Sun, 4 Mar 2018 01:36:34 +0100 With this data, the Monitoring can show whether traffic control is enabled and which rates are set. Signed-off-by: Adrian Schmutzler Tested-by: Adrian Schmutzler --- 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(-) 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$w5_ACT$w5_BUS" 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="$tc_enabled$tc_in$tc_out" + err "$(date): Putting all information into a XML-File and save it at $SCRIPT_DATA_FILE" DATA="" @@ -292,6 +313,7 @@ crawl() { DATA=$DATA"$client_count" DATA=$DATA"$dataclient" DATA=$DATA"$dataair" + DATA=$DATA"$traffic_control" DATA=$DATA"" #write data to xml file that provides the data on httpd