From 210d77543369ab3f44e5aa4894ed82134019c1b5 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Fri, 17 Dec 2010 02:14:28 +0000 Subject: applications/luci-olsr: Add overview page, move old index to neigbors --- .../luci-olsr/luasrc/view/status-olsr/index.htm | 61 ------- .../luasrc/view/status-olsr/interfaces.htm | 45 ++++++ .../luasrc/view/status-olsr/neighbors.htm | 61 +++++++ .../luci-olsr/luasrc/view/status-olsr/overview.htm | 178 +++++++++++++++++++++ .../luci-olsr/luasrc/view/status-olsr/smartgw.htm | 5 +- 5 files changed, 286 insertions(+), 64 deletions(-) delete mode 100644 applications/luci-olsr/luasrc/view/status-olsr/index.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/interfaces.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm create mode 100644 applications/luci-olsr/luasrc/view/status-olsr/overview.htm (limited to 'applications/luci-olsr/luasrc/view/status-olsr') diff --git a/applications/luci-olsr/luasrc/view/status-olsr/index.htm b/applications/luci-olsr/luasrc/view/status-olsr/index.htm deleted file mode 100644 index 786c859545..0000000000 --- a/applications/luci-olsr/luasrc/view/status-olsr/index.htm +++ /dev/null @@ -1,61 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2008 Steven Barth -Copyright 2008 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - --%> -<%+header%> -

<%:OLSR connections%>

-

<%:Overview of currently established OLSR connections%>

-
- - - - - - - - - - -<% for k, link in ipairs(links) do - local color = "#bb3333" - - link.Cost = tonumber(link.Cost) or 0 - if link.Cost == 0 then - color = "#bb3333" - elseif link.Cost < 4 then - color = "#00cc00" - elseif link.Cost < 10 then - color = "#ffcb05" - elseif link.Cost < 100 then - color = "#ff6600" - end -%> - - - - - - - - - -<% end %> -
<%:Neighbour IP%><%:Hostname%><%:Local interface IP%><%:Device%>LQNLQETX
/cgi-bin-status.html"><%=link["Remote IP"]%>/cgi-bin-status.html"><%=link["Hostname"]%><%=link["Local IP"]%><%=link["Local Device"]%><%=link.LQ%><%=link.NLQ%><%=string.format("%.3f", link.Cost)%>
-
-

<%:Legend%>:

-
    -
  • LQ: <%:Success rate of packages received from the neighbour%>
  • -
  • NLQ: <%:Success rate of packages sent to the neighbour%>
  • -
  • ETX: <%:Expected retransmission count%>
  • -
-<%+footer%> diff --git a/applications/luci-olsr/luasrc/view/status-olsr/interfaces.htm b/applications/luci-olsr/luasrc/view/status-olsr/interfaces.htm new file mode 100644 index 0000000000..b409fede91 --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/interfaces.htm @@ -0,0 +1,45 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich +Copyright 2010 Manuel Munz + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: mid.htm 5448 2009-10-31 15:54:11Z jow $ + +-%> +<%+header%> +

<%:Interfaces%>

+

<%:Overview of interfaces where OLSR is running%>

+
+ + + + + + + + + + + +<% for k, i in ipairs(iface) do %> + + + + + + + + + +<% end %> + +
<%:Interface%><%:State%><%:MTU%><%:WLAN%><%:Source address%><%:Netmask%><%:Broadcast address%>
<%=i.Name%><%=i.State%><%=i.MTU%><%=i.WLAN%><%=i["Src-Adress"]%><%=i.Mask%><%=i["Dst-Adress"]%>
+
+<%+footer%> diff --git a/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm b/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm new file mode 100644 index 0000000000..60afdc37dd --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm @@ -0,0 +1,61 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: index.htm 6619 2010-12-05 15:02:44Z soma $ + +-%> +<%+header%> +

<%:OLSR connections%>

+

<%:Overview of currently established OLSR connections%>

+
+ + + + + + + + + + +<% for k, link in ipairs(links) do + local color = "#bb3333" + + link.Cost = tonumber(link.Cost) or 0 + if link.Cost == 0 then + color = "#bb3333" + elseif link.Cost < 4 then + color = "#00cc00" + elseif link.Cost < 10 then + color = "#ffcb05" + elseif link.Cost < 100 then + color = "#ff6600" + end +%> + + + + + + + + + +<% end %> +
<%:Neighbour IP%><%:Hostname%><%:Local interface IP%><%:Device%>LQNLQETX
/cgi-bin-status.html"><%=link["Remote IP"]%>/cgi-bin-status.html"><%=link["Hostname"]%><%=link["Local IP"]%><%=link["Local Device"]%><%=link.LQ%><%=link.NLQ%><%=string.format("%.3f", link.Cost)%>
+
+

<%:Legend%>:

+
    +
  • LQ: <%:Success rate of packages received from the neighbour%>
  • +
  • NLQ: <%:Success rate of packages sent to the neighbour%>
  • +
  • ETX: <%:Expected retransmission count%>
  • +
+<%+footer%> diff --git a/applications/luci-olsr/luasrc/view/status-olsr/overview.htm b/applications/luci-olsr/luasrc/view/status-olsr/overview.htm new file mode 100644 index 0000000000..673938c570 --- /dev/null +++ b/applications/luci-olsr/luasrc/view/status-olsr/overview.htm @@ -0,0 +1,178 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich +Copyright 2010 Manuel Munz + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 +-%> + +<% +local sys = require "luci.sys" +local utl = require "luci.util" +local fs = require "luci.fs" + +function get_version() + local data = utl.split((utl.trim(sys.exec("/rom/usr/sbin/olsrd -v")))) + local buildfull = utl.trim(utl.split(data[2],": ")[2]) + local ver = { + version = utl.trim(utl.split(data[1]," - ")[2]), + date = utl.trim(utl.split(buildfull, " ")[1]), + time = utl.trim(utl.split(buildfull, " ")[2]), + host = utl.trim(utl.split(buildfull, " ")[4]) + } + return ver +end +local ver = get_version() + +local ifaces = fetch_txtinfo("int") +if not ifaces or not ifaces.Interfaces then + luci.template.render("status-olsr/error_olsr") + return nil +end +local interfaces = "" +for k,v in pairs(ifaces.Interfaces) do + interfaces = utl.trim(interfaces.." "..v.Name) +end +interfaces = string.gsub(interfaces, " ", ", ") +local nr_ifaces = #ifaces.Interfaces + +local links = fetch_txtinfo("links") +local nr_neigh = #links.Links +local neighbors = "" +for k,v in pairs(links.Links) do + local link + if v.Hostname then + link = v.Hostname + else + link = v["Remote IP"] + end + neighbors = utl.trim(""..link.." "..neighbors) +end + +local data = fetch_txtinfo("topology") +local nr_topo = #data.Topology +local utable = {} +for k,v in pairs(data.Topology) do + if utl.contains(utable, v["Dest. IP"]) == false then + table.insert(utable, v["Dest. IP"]) + end +end +local nr_nodes = #utable + +local data = fetch_txtinfo("hna") +local nr_hna = #data.HNA + +local meshfactor = string.format("%.2f", nr_topo / nr_nodes) + +local ipv = luci.model.uci.cursor():get_first("olsrd", "olsrd", "IpVersion", "4") + +function write_conf(conf, file) + if fs.access(conf) then + luci.http.header("Content-Disposition", "attachment; filename="..file) + luci.http.prepare_content("text/plain") + luci.http.write(fs.readfile(conf)) + end +end + +conf = luci.http.formvalue() + +if conf.openwrt then + write_conf("/etc/config/olsrd", "olsrd") + return false +end + +if conf.conf_v4 then + write_conf("/var/etc/olsrd.conf.ipv4", "olsrd.conf.ipv4") + return false +end + +if conf.conf_v6 then + write_conf("/var/etc/olsrd.conf.ipv6", "olsrd.conf.ipv6") + return false +end + +if conf.conf then + write_conf("/var/etc/olsrd.conf", "olsrd.conf") + return false +end + +%> + +<%+header%> +

OLSR <%:Overview%>

+ +
+
+
+
+ +
+ <%=interfaces%> +
+
+
+ +
+
+ +
+ <%=neighbors%> +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
<%=meshfactor%> +
+
+
+
+ +

OLSR <%:Configuration%>

+ +
+
+
+
<%=ver.version%> (built <%=ver.date%> on <%=ver.host%>) +
+
+ +
+
+ OpenWrt, + <% if ipv == "6and4" then %> + OLSRD IPv4, + OLSRD IPv6 + <% else %> + OLSRD + <% end %> +
+
+
+
+ +<%+footer%> diff --git a/applications/luci-olsr/luasrc/view/status-olsr/smartgw.htm b/applications/luci-olsr/luasrc/view/status-olsr/smartgw.htm index a64c7bffdf..10d516cd35 100644 --- a/applications/luci-olsr/luasrc/view/status-olsr/smartgw.htm +++ b/applications/luci-olsr/luasrc/view/status-olsr/smartgw.htm @@ -2,16 +2,15 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth Copyright 2008 Jo-Philipp Wich +Copyright 2010 Manuel Munz Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - -$Id: mid.htm 5448 2009-10-31 15:54:11Z jow $ - -%> + <% require("luci.model.uci") local uci = luci.model.uci.cursor_state() -- cgit v1.2.3