forked from freifunk-franken/firmware
batman-adv: Move from DEBUGFS to batctl
The debug filesystem will be deprecated and disabled by default in newer versions of B.A.T.M.A.N. This patch switches our code to the batctl, as recommended. Since batctl can suppress headers, this actually makes our life easier ... Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Reviewed-by: Robert Langhammer <rlanghammer@web.de>
This commit is contained in:
parent
7c6978cdde
commit
d9ec8edb15
|
@ -1,8 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-nodewatcher
|
||||
PKG_VERSION:=51
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=52
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ if ! lock -n "$lockfile"; then
|
|||
fi
|
||||
trap "lock -u \"$lockfile\"" INT TERM EXIT
|
||||
|
||||
SCRIPT_VERSION="51"
|
||||
SCRIPT_VERSION="52"
|
||||
|
||||
#Get the configuration from the uci configuration file
|
||||
#If it does not exists, then get it from a normal bash file with variables.
|
||||
|
@ -227,14 +227,13 @@ crawl() {
|
|||
done
|
||||
|
||||
# Build a list of direct neighbors
|
||||
batman_adv_originators=$(awk \
|
||||
batman_adv_originators=$(/usr/sbin/batctl o -H | awk \
|
||||
'BEGIN { FS=" "; i=0 } # set the delimiter to " "
|
||||
/O/ { next } # ignore lines with O (will remove second line)
|
||||
/B/ { next } # ignore line with B (will remove first line)
|
||||
{ sub("\\(", "", $0) # remove parentheses
|
||||
sub("\\)", "", $0)
|
||||
sub("\\[", "", $0)
|
||||
sub("\\]:", "", $0)
|
||||
sub("\\]", "", $0)
|
||||
sub("\\*", "", $0)
|
||||
sub(" ", " ", $0)
|
||||
o=$1".*"$1 # build a regex to find lines that contains the $1 (=originator) twice
|
||||
if ($0 ~ o) # filter for this regex (will remove entries without direct neighbor)
|
||||
|
@ -242,24 +241,22 @@ crawl() {
|
|||
printf "<originator_"i"><originator>"$1"</originator><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><last_seen>"$2"</last_seen><outgoing_interface>"$5"</outgoing_interface></originator_"i">"
|
||||
i++
|
||||
}
|
||||
}' /sys/kernel/debug/batman_adv/bat0/originators)
|
||||
}')
|
||||
|
||||
batman_adv_gateway_mode=$(batctl gw)
|
||||
batman_adv_gateway_mode=$(/usr/sbin/batctl gw)
|
||||
|
||||
batman_adv_gateway_list=$(awk \
|
||||
batman_adv_gateway_list=$(/usr/sbin/batctl gwl -H | awk \
|
||||
'BEGIN { FS=" "; i=0 }
|
||||
/B.A.T.M.A.N./ { next }
|
||||
/Gateway/ { next }
|
||||
/No gateways/ { next }
|
||||
{ sub("\\(", "", $0)
|
||||
sub("\\)", "", $0)
|
||||
sub("\\[ *", "", $0)
|
||||
sub("\\]:", "", $0)
|
||||
sub("=> ", "true ", $0)
|
||||
sub(" ", "false ", $0)
|
||||
sub("\\* ", "true ", $0)
|
||||
sub(" ", "false ", $0)
|
||||
printf "<gateway_"i"><selected>"$1"</selected><gateway>"$2"</gateway><link_quality>"$3"</link_quality><nexthop>"$4"</nexthop><outgoing_interface>"$5"</outgoing_interface><gw_class>"$6" "$7" "$8"</gw_class></gateway_"i">"
|
||||
i++
|
||||
}' /sys/kernel/debug/batman_adv/bat0/gateways)
|
||||
}')
|
||||
fi
|
||||
err "$(date): Collecting information about conected clients"
|
||||
#CLIENTS
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-support
|
||||
PKG_VERSION:=0.0.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
|
|
@ -98,8 +98,8 @@ echo "-> SYSTEM"
|
|||
echo "Name: ${HOSTNAME}"
|
||||
echo "Modell: $(cat /tmp/sysinfo/model 2>/dev/null)"
|
||||
echo "MAC-Adresse: $(cat /sys/class/net/br-mesh/address)"
|
||||
echo "Bekannte Knoten: $((`cat /sys/kernel/debug/batman_adv/bat0/transtable_global | grep '^ [^ ]' | cut -b 39-55 | sort | uniq | wc -l 2>/dev/null`+1))"
|
||||
echo "Nachbarknoten: $(cat /sys/kernel/debug/batman_adv/bat0/originators | grep '^[0-9a-f]' | cut -b 37-53 | sort | uniq | wc -l 2>/dev/null)"
|
||||
echo "Bekannte Knoten: $(($(batctl tg -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null)+1))"
|
||||
echo "Nachbarknoten: $(batctl o -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null)"
|
||||
echo "VPN via fastd: ${vpn_active}"
|
||||
echo "VPN via L2TP: ${l2tp_active}"
|
||||
echo "Laufzeit: ${uptime}"
|
||||
|
@ -128,7 +128,7 @@ echo "Fastd Version: $(fastd --version 2> /dev/null | cut -d' ' -f 2)"
|
|||
|
||||
echo ""
|
||||
echo "-> Netz: FREIFUNK"
|
||||
echo "Nutzer: $(cat /sys/kernel/debug/batman_adv/bat0/transtable_local 2> /dev/null | grep -c 'W')"
|
||||
echo "Nutzer: $(batctl tl -H 2> /dev/null | grep -c 'W')"
|
||||
echo "Empfangen: $(cat /sys/class/net/br-mesh/statistics/rx_bytes 2> /dev/null | human_bytes)"
|
||||
echo "Gesendet: $(cat /sys/class/net/br-mesh/statistics/tx_bytes 2> /dev/null | human_bytes)"
|
||||
echo "IPv4 Adressen: $(addr 4 br-mesh)"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-web
|
||||
PKG_VERSION:=6
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=7
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ contact="$(uci -q get "fff.system.contact")"
|
|||
<legend>Status</legend>
|
||||
<table>
|
||||
<tr><th>Hood:</th><td><% echo "$hood" %></td></tr>
|
||||
<tr><th>Nachbarknoten:</th><td><% echo -n $(cat /sys/kernel/debug/batman_adv/bat0/originators | grep '^[0-9a-f]' | cut -b 37-53 | sort | uniq | wc -l 2> /dev/null) %></td></tr>
|
||||
<tr><th>Bekannte Knoten:</th><td><% echo -n $((`cat /sys/kernel/debug/batman_adv/bat0/transtable_global | grep '^ [^ ]' | cut -b 39-55 | sort | uniq | wc -l 2> /dev/null`+1)) %></td></tr>
|
||||
<tr><th>Lokale Clients:</th><td><% echo -n $(cat /sys/kernel/debug/batman_adv/bat0/transtable_local 2> /dev/null | grep -c 'W') %></td></tr>
|
||||
<tr><th>Bekannte Knoten:</th><td><% echo -n $(($(batctl tg -H | cut -b 40-56 | sort | uniq | wc -l 2> /dev/null)+1)) %></td></tr>
|
||||
<tr><th>Nachbarknoten:</th><td><% echo -n $(batctl o -H | cut -b 40-56 | sort | uniq | wc -l 2> /dev/null) %></td></tr>
|
||||
<tr><th>Lokale Clients:</th><td><% echo -n $(batctl tl -H 2> /dev/null | grep -c 'W') %></td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</td></tr>
|
||||
|
|
|
@ -59,8 +59,8 @@ fi
|
|||
<tr><th>Name:</th><td><%= ${HOSTNAME} %></td></tr>
|
||||
<tr><th>Modell:</th><td><% cat /tmp/sysinfo/model 2>/dev/null %></td></tr>
|
||||
<tr><th>MAC-Adresse:</th><td><%= $(cat /sys/class/net/br-mesh/address) %></td></tr>
|
||||
<tr><th>Bekannte Knoten:</th><td><%= $((`cat /sys/kernel/debug/batman_adv/bat0/transtable_global | grep '^ [^ ]' | cut -b 39-55 | sort | uniq | wc -l 2>/dev/null`+1)) %></td></tr>
|
||||
<tr><th>Nachbarknoten:</th><td><%= $(cat /sys/kernel/debug/batman_adv/bat0/originators | grep '^[0-9a-f]' | cut -b 37-53 | sort | uniq | wc -l 2>/dev/null) %></td></tr>
|
||||
<tr><th>Bekannte Knoten:</th><td><%= $(($(batctl tg -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null)+1)) %></td></tr>
|
||||
<tr><th>Nachbarknoten:</th><td><%= $(batctl o -H | cut -b 40-56 | sort | uniq | wc -l 2>/dev/null) %></td></tr>
|
||||
<tr><th>VPN via fastd:</th><td><%= ${vpn_active} %></td></tr>
|
||||
<tr><th>VPN via L2TP:</th><td><%= ${l2tp_active} %></td></tr>
|
||||
<tr><th>Laufzeit:</th><td><%= ${uptime} %></td></tr>
|
||||
|
@ -71,7 +71,7 @@ fi
|
|||
<fieldset style="padding-bottom:12px">
|
||||
<legend>Netz: Freifunk</legend>
|
||||
<table>
|
||||
<tr><th>Nutzer:</th><td><% cat /sys/kernel/debug/batman_adv/bat0/transtable_local 2> /dev/null | grep -c 'W' %></td></tr>
|
||||
<tr><th>Nutzer:</th><td><% batctl tl -H 2> /dev/null | grep -c 'W' %></td></tr>
|
||||
<tr><th>Empfangen:</th><td><% cat /sys/class/net/br-mesh/statistics/rx_bytes 2> /dev/null | human_bytes %></td></tr>
|
||||
<tr><th>Gesendet:</th><td><% cat /sys/class/net/br-mesh/statistics/tx_bytes 2> /dev/null | human_bytes %></td></tr>
|
||||
<tr><th>IPv4 Adressen:</th><td><% addr 4 br-mesh %></td></tr>
|
||||
|
|
Loading…
Reference in New Issue
Block a user