nodewatcher: remove unused ip addresses from xml data

Signed-off-by: Tim Niemeyer <tim.niemeyer@mastersword.de>
Reviewed-by: Tobias Klaus <tk+ff@meskal.net>
This commit is contained in:
Tim Niemeyer 2015-10-10 10:24:59 +02:00
parent d6ac1df7ec
commit 368241ec28
2 changed files with 14 additions and 13 deletions

View File

@ -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

View File

@ -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 "<mac_addr>"$2"</mac_addr>" }
/inet / { split($2, a, "/"); printf "<ipv4_addr>"a[1]"</ipv4_addr>" }
/inet6/ && /scope global/ { printf "<ipv6_addr>"$2"</ipv6_addr>" }
/inet6/ && /scope link/ { printf "<ipv6_link_local_addr>"$2"</ipv6_link_local_addr>"}
/mtu/ { printf "<mtu>"$5"</mtu>" }
')"
#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 "<mtu>"$5"</mtu>" }'
if inArray "$IPWHITELIST" "$iface"; then
awkscript=$awkscript'
/inet / { split($2, a, "/"); printf "<ipv4_addr>"a[1]"</ipv4_addr>" }
/inet6/ && /scope global/ { printf "<ipv6_addr>"$2"</ipv6_addr>" }
/inet6/ && /scope link/ { printf "<ipv6_link_local_addr>"$2"</ipv6_link_local_addr>"}'
fi
addrs=$(ip addr show dev ${iface} | awk "$awkscript")
traffic_rx=`cat $ifpath/statistics/rx_bytes`
traffic_tx=`cat $ifpath/statistics/tx_bytes`