[PATCH v2 4/5] nodewatcher: remove unused ip addresses from xml data
Tobias Klaus
tk+ff at meskal.net
Sa Okt 10 14:30:49 CEST 2015
Am Samstag, 10. Oktober 2015, 10:24:59 schrieb Tim Niemeyer:
> Signed-off-by: Tim Niemeyer <tim.niemeyer at mastersword.de>
Reviewed-by: Tobias Klaus <tk+ff at meskal.net>
Ich kann ja keine awk, aber es scheint in einer BASH-korrekten Art nur
weggelassen zu sein, was im commit steht :-)
Die gleich Anmerkung nochmal unten.
> ---
>
> Changes in v2:
> - add a whitelist to get IPs of specific interfaces
>
> .../root_file_system/etc/config/nodewatcher | 1 +
> bsp/default/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
> 38132e5..75c7afa 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 send to netmon
> at all + option 'ip_whitelist' 'br-mesh' # For this devices the IPs will be
> send to netmon diff --git a/bsp/default/root_file_system/etc/nodewatcher.sh
*sent
> 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. at network[0].mesh_interface`
> CLIENT_INTERFACES=`uci get nodewatcher. at network[0].client_interfaces`
> IFACEBLACKLIST=`uci get nodewatcher. at network[0].iface_blacklist`
> + IPWHITELIST=`uci get nodewatcher. at 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`
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname : signature.asc
Dateityp : application/pgp-signature
Dateigröße : 819 bytes
Beschreibung: This is a digitally signed message part.
URL : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20151010/32befeca/attachment-0002.sig>
Mehr Informationen über die Mailingliste franken-dev