From 368241ec287f527b79e7f144641bed37ab4d7977 Mon Sep 17 00:00:00 2001 From: Tim Niemeyer Date: Sat, 10 Oct 2015 10:24:59 +0200 Subject: [PATCH] nodewatcher: remove unused ip addresses from xml data Signed-off-by: Tim Niemeyer Reviewed-by: Tobias Klaus --- .../root_file_system/etc/config/nodewatcher | 1 + .../root_file_system/etc/nodewatcher.sh | 26 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bsp/default/root_file_system/etc/config/nodewatcher b/bsp/default/root_file_system/etc/config/nodewatcher index 9571220..702a7a3 100644 --- a/bsp/default/root_file_system/etc/config/nodewatcher +++ b/bsp/default/root_file_system/etc/config/nodewatcher @@ -7,3 +7,4 @@ config 'script' config 'network' option 'mesh_interface' 'br-mesh' option 'iface_blacklist' 'lo ifb0' # This devices won't be sent to netmon at all + option 'ip_whitelist' 'br-mesh' # For this devices the IPs will be sent to netmon diff --git a/bsp/default/root_file_system/etc/nodewatcher.sh b/bsp/default/root_file_system/etc/nodewatcher.sh index cdb6760..1c85cc0 100755 --- a/bsp/default/root_file_system/etc/nodewatcher.sh +++ b/bsp/default/root_file_system/etc/nodewatcher.sh @@ -15,6 +15,7 @@ if [ -f /etc/config/nodewatcher ];then MESH_INTERFACE=`uci get nodewatcher.@network[0].mesh_interface` CLIENT_INTERFACES=`uci get nodewatcher.@network[0].client_interfaces` IFACEBLACKLIST=`uci get nodewatcher.@network[0].iface_blacklist` + IPWHITELIST=`uci get nodewatcher.@network[0].ip_whitelist` else . `dirname $0`/nodewatcher_config fi @@ -111,20 +112,19 @@ crawl() { if inArray "$IFACEBLACKLIST" "$iface"; then continue fi - - #Get interface data - addrs="$(ip addr show dev ${iface} | awk ' + + #Get interface data for whitelisted interfaces + awkscript=' /ether/ { printf ""$2"" } - /inet / { split($2, a, "/"); printf ""a[1]"" } - /inet6/ && /scope global/ { printf ""$2"" } - /inet6/ && /scope link/ { printf ""$2""} - /mtu/ { printf ""$5"" } - ')" - #mac_addr="`cat $ifpath/address`" - #ipv4_addr="`ip addr show dev ${iface} | awk '/inet / { split($2, a, "/"); print a[1] }'`" - #ipv6_addr="`ip addr show dev ${iface} scope global | awk '/inet6/ { print $2 }'`" - #ipv6_link_local_addr="`ip addr show dev ${iface} scope link | awk '/inet6/ { print $2 }'`" - #mtu=`cat $ifpath/mtu` + /mtu/ { printf ""$5"" }' + if inArray "$IPWHITELIST" "$iface"; then + awkscript=$awkscript' + /inet / { split($2, a, "/"); printf ""a[1]"" } + /inet6/ && /scope global/ { printf ""$2"" } + /inet6/ && /scope link/ { printf ""$2""}' + fi + addrs=$(ip addr show dev ${iface} | awk "$awkscript") + traffic_rx=`cat $ifpath/statistics/rx_bytes` traffic_tx=`cat $ifpath/statistics/tx_bytes`