From 35761aa3a07e6a9ee75cd9a2f4536c11f1cdd9dd Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Fri, 18 Dec 2020 19:17:07 +0100 Subject: luci-app-babeld: add babeld overview Add overview of babeld status, xroutes and routes. Signed-off-by: Nick Hainke --- .../luci-app-babeld/luasrc/model/cbi/babeld.lua | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 applications/luci-app-babeld/luasrc/model/cbi/babeld.lua (limited to 'applications/luci-app-babeld/luasrc/model/cbi/babeld.lua') diff --git a/applications/luci-app-babeld/luasrc/model/cbi/babeld.lua b/applications/luci-app-babeld/luasrc/model/cbi/babeld.lua new file mode 100644 index 0000000000..2169de4731 --- /dev/null +++ b/applications/luci-app-babeld/luasrc/model/cbi/babeld.lua @@ -0,0 +1,127 @@ +m = Map("babeld", translate("Babeld Overview")) +m.pageaction = false + +s = m:section(NamedSection, "__babeldoverview__") + +function s.render(self, sid) + local tpl = require "luci.template" + + tpl.render_string([[ + <% + local utl = require "luci.util" + local v6_port = 33123 + -- FIXME: check if call is correct + local dump = utl.exec("(echo dump | nc ::1 %d)" % v6_port) + local t = {} + + for strline in string.gmatch(dump, "[^\n]+") do + t[#t+1] = strline; + end + + local babel_version = t[1] + local babeld_version = t[2] + local babeld_host = string.split(t[3], " ")[2] + local babeld_id = string.split(t[4], " ")[2] + local babeld_status = t[5] + + %> +
+

Babel-Info

+
+
+
Version
+
Version-Daemon
+
Host
+
ID
+
Status
+
+
+
<%= babel_version %>
+
<%= babeld_version %>
+
<%= babeld_host %>
+
<%= babeld_id %>
+
<%= babeld_status %>
+
+
+
+ + <% + local xroutes = {} + for key,value in ipairs(t) do + if string.match(value, "xroute") then + xroutes[#xroutes+1] = value + end + end + %> + +
+

X-Routes

+
+
+
Route
+
Prefix
+
From
+
Metric
+
+ <% + for key,route in ipairs(xroutes) do + local route_sep = string.split(route," ") + %> +
+
<%= route_sep[3] %>
+
<%= route_sep[5] %>
+
<%= route_sep[7] %>
+
<%= route_sep[9] %>
+
+ <% + end + %> +
+
+ + <% + local routes = {} + for key,value in ipairs(t) do + if string.match(value, "add route") then + routes[#routes+1] = value + end + end + %> + +
+

Routes

+
+
+
Prefix
+
From
+
Installed
+
ID
+
Metric
+
Ref-Metric
+
Via
+
Interface
+
+ <% + for key,route in ipairs(routes) do + local route_sep = string.split(route," ") + %> + +
+
<%= route_sep[5] %>
+
<%= route_sep[7] %>
+
<%= route_sep[9] %>
+
<%= route_sep[11] %>
+
<%= route_sep[13] %>
+
<%= route_sep[15] %>
+
<%= route_sep[17] %>
+
<%= route_sep[19] %>
+
+ <% + end + %> +
+
+ ]]) +end + +return m -- cgit v1.2.3