fff-web-ui: Add more information about babel

Add a litte bit morge information about babel on the public page of the router

Signed-off-by: Christian Dresel <freifunk@dresel.systems>
This commit is contained in:
Christian Dresel 2022-04-16 11:16:55 +02:00
parent ae970828a1
commit 230c258ca6
1 changed files with 41 additions and 0 deletions

View File

@ -67,6 +67,47 @@ contact="$(uci -q get "fff.system.contact")"
<tr><th>Lokale Clients:</th><td><% echo -n $(batctl tl -H 2> /dev/null | grep -c 'W') %></td></tr>
</table>
</fieldset>
<% fi
if birdc show status >/dev/null 2>&1 || pgrep babeld >/dev/null; then %>
<fieldset style="min-height: 15em;">
<legend>Status</legend>
<table>
<% #Count Clients
client_count=$(bridge fdb show br br_client brport $(ls "/sys/class/net/br-client/brif" | grep -v '^bat') | grep -v self | grep -v permanent -c)
%>
<tr><th>Lokale Clients:</th><td><% echo $client_count %></td></tr>
</table>
</fieldset>
<fieldset style="min-height: 15em;">
<legend>Babel Status</legend>
<table>
<tr><th>IP</th><th>Interface</th><th>Kosten</th></tr>
<% if birdc show status >/dev/null 2>&1; then
neighbours="$(birdc -r show babel neighbors | tail -n +5 | awk '{ printf "<tr><td>%s</td><td>%s</td><td>%s</td></tr>", $1, $2, $3 }')"
fi
if
pgrep babeld >/dev/null; then
lockfile="/tmp/fff-web-ui.babel.lock"
if [ -e $lockfile ] && [ 30 -gt $(( $(date +%s) - $(date -r $lockfile +%s) )) ] ; then
neighbours=$(cat /tmp/fff-web-ui.babel)
else
neighbours="$(echo dump | nc ::1 33123 | grep '^add neighbour' |
awk '{
for (i=2; i < NF; i += 2) {
vars[$i] = $(i+1)
}
}
{
printf "<tr><td>%s</td><td>%s</td><td>%s</td></tr>", vars["address"], vars["if"], vars["cost"]
}')"
echo "$neighbours" > /tmp/fff-web-ui.babel
touch $lockfile
fi
fi
echo -n "$neighbours"
%>
</table>
</fieldset>
<% fi %>
</td></tr>
</table>