entry({"admin", "status"}, alias("admin", "status", "interfaces"), i18n("Status"), 20).index = true
entry({"admin", "status", "interfaces"}, template("admin_status/index"), i18n("Overview"), 1)
entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("Firewall"), 2).leaf = true
- entry({"admin", "status", "conntrack"}, template("admin_status/conntrack"), i18n("Active Connections"), 3)
- entry({"admin", "status", "routes"}, template("admin_status/routes"), i18n("Routes"), 4)
- entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("System Log"), 5)
- entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("Kernel Log"), 6)
+ entry({"admin", "status", "routes"}, template("admin_status/routes"), i18n("Routes"), 3)
+ entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("System Log"), 4)
+ entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("Kernel Log"), 5)
- entry({"admin", "status", "load"}, template("admin_status/load"), i18n("Realtime Load"), 7).leaf = true
+ entry({"admin", "status", "load"}, template("admin_status/load"), i18n("Realtime Load"), 6).leaf = true
entry({"admin", "status", "load_status"}, call("action_load")).leaf = true
- entry({"admin", "status", "bandwidth"}, template("admin_status/bandwidth"), i18n("Realtime Traffic"), 8).leaf = true
+ entry({"admin", "status", "bandwidth"}, template("admin_status/bandwidth"), i18n("Realtime Traffic"), 7).leaf = true
entry({"admin", "status", "bandwidth_status"}, call("action_bandwidth")).leaf = true
- entry({"admin", "status", "connections"}, template("admin_status/connections"), i18n("Realtime Connections"), 9).leaf = true
+ entry({"admin", "status", "connections"}, template("admin_status/connections"), i18n("Realtime Connections"), 8).leaf = true
entry({"admin", "status", "connections_status"}, call("action_connections")).leaf = true
end
end
function action_connections()
- local fs = require "luci.fs"
- if fs.access("/var/lib/luci-bwc/connections") then
- luci.http.prepare_content("application/json")
+ local fs = require "luci.fs"
+ local sys = require "luci.sys"
+
+ luci.http.prepare_content("application/json")
+
+ luci.http.write("{ connections: ")
+ luci.http.write_json(sys.net.conntrack())
+ if fs.access("/var/lib/luci-bwc/connections") then
local bwc = io.popen("luci-bwc -c 2>/dev/null")
if bwc then
- luci.http.write("[")
+ luci.http.write(", statistics: [")
while true do
local ln = bwc:read("*l")
luci.http.write("]")
bwc:close()
end
-
- return
end
- luci.http.status(404, "No data available")
+ luci.http.write(" }")
end
var label_scale;
+ var conn_table;
+
function update_graph()
{
bwxhr.get('<%=build_url("admin/status/connections_status")%>', null,
- function(x, data)
+ function(x, json)
{
+ var conn = json.connections;
+
+ while (conn_table.rows.length > 1)
+ conn_table.rows[0].parentNode.deleteRow(-1);
+
+ for (var i = 0; i < conn.length; i++)
+ {
+ var c = conn[i];
+ var tr = conn_table.rows[0].parentNode.insertRow(-1);
+ tr.className = 'cbi-section-table-row cbi-rowstyle-' + (1 + (i % 2));
+
+ tr.insertCell(-1).innerHTML = c.layer3.toUpperCase();
+ tr.insertCell(-1).innerHTML = c.layer4.toUpperCase();
+ tr.insertCell(-1).innerHTML = String.format(c.layer3 == 'ipv6' ? '[%s]:%d' : '%s:%d', c.src, c.sport);
+ tr.insertCell(-1).innerHTML = String.format(c.layer3 == 'ipv6' ? '[%s]:%d' : '%s:%d', c.dst, c.dport);
+ tr.insertCell(-1).innerHTML = String.format('%1024.2mB (%d <%:Pkts.%>)', c.bytes, c.packets);
+ }
+
+
+ var data = json.statistics;
+
var data_max = 0;
var data_scale = 0;
window.setTimeout(
function() {
var svg = document.getElementById('bwsvg');
-
+
try {
G = svg.getSVGDocument
? svg.getSVGDocument() : svg.contentDocument;
label_otr_avg = document.getElementById('lb_otr_avg');
label_otr_peak = document.getElementById('lb_otr_peak');
- label_scale = document.getElementById('scale');
+ label_scale = document.getElementById('scale');
+
+ conn_table = document.getElementById('connections');
/* plot horizontal time interval lines */
<h2><a id="content" name="content"><%:Realtime Connections%></a></h2>
-<embed id="bwsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/connections.svg" />
-<div style="text-align:right"><small id="scale">-</small></div>
-<br />
-
-<table style="width:100%; table-layout:fixed" cellspacing="5">
- <tr>
- <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid blue"><%:UDP:%></strong></td>
- <td id="lb_udp_cur">0</td>
-
- <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td>
- <td id="lb_udp_avg">0</td>
-
- <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td>
- <td id="lb_udp_peak">0</td>
- </tr>
- <tr>
- <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid green"><%:TCP:%></strong></td>
- <td id="lb_tcp_cur">0</td>
-
- <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td>
- <td id="lb_tcp_avg">0</td>
-
- <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td>
- <td id="lb_tcp_peak">0</td>
- </tr>
- <tr>
- <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid red"><%:Other:%></strong></td>
- <td id="lb_otr_cur">0</td>
-
- <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td>
- <td id="lb_otr_avg">0</td>
-
- <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td>
- <td id="lb_otr_peak">0</td>
- </tr>
-</table>
+<div class="cbi-map-descr"><%:This page gives an overview over currently active network connections.%></div>
+
+<fieldset class="cbi-section" id="cbi-table-table">
+ <legend><%:Active Connections%></legend>
+
+ <embed id="bwsvg" style="width:100%; height:300px; border:1px solid #000000; background-color:#FFFFFF" src="<%=resource%>/connections.svg" />
+ <div style="text-align:right"><small id="scale">-</small></div>
+ <br />
+
+ <table style="width:100%; table-layout:fixed" cellspacing="5">
+ <tr>
+ <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid blue"><%:UDP:%></strong></td>
+ <td id="lb_udp_cur">0</td>
+
+ <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td>
+ <td id="lb_udp_avg">0</td>
+
+ <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td>
+ <td id="lb_udp_peak">0</td>
+ </tr>
+ <tr>
+ <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid green"><%:TCP:%></strong></td>
+ <td id="lb_tcp_cur">0</td>
+
+ <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td>
+ <td id="lb_tcp_avg">0</td>
+
+ <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td>
+ <td id="lb_tcp_peak">0</td>
+ </tr>
+ <tr>
+ <td style="text-align:right; vertical-align:top"><strong style="border-bottom:2px solid red"><%:Other:%></strong></td>
+ <td id="lb_otr_cur">0</td>
+
+ <td style="text-align:right; vertical-align:top"><strong><%:Average:%></strong></td>
+ <td id="lb_otr_avg">0</td>
+
+ <td style="text-align:right; vertical-align:top"><strong><%:Peak:%></strong></td>
+ <td id="lb_otr_peak">0</td>
+ </tr>
+ </table>
+ <br />
+
+ <div class="cbi-section-node">
+ <table class="cbi-section-table" id="connections">
+ <tr class="cbi-section-table-titles">
+ <th class="cbi-section-table-cell"><%:Network%></th>
+ <th class="cbi-section-table-cell"><%:Protocol%></th>
+ <th class="cbi-section-table-cell"><%:Source%></th>
+ <th class="cbi-section-table-cell"><%:Destination%></th>
+ <th class="cbi-section-table-cell"><%:Transfer%></th>
+ </tr>
+
+ <tr><td colspan="5"><em><%:Collecting data...%></em></td></tr>
+ </table>
+ </div>
+</fieldset>
<%+footer%>
+++ /dev/null
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008-2009 Steven Barth <steven@midlink.org>
-Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
-
-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$
-
--%>
-
-<%-
- require "luci.sys"
- local style = true
--%>
-
-<%+header%>
-
-<div class="cbi-map" id="cbi-conntrack">
- <h2><a id="content" name="content"><%:Active Connections%></a></h2>
- <div class="cbi-map-descr"><%:This page gives an overview over currently active network connections.%></div>
-
- <fieldset class="cbi-section" id="cbi-table-table">
- <legend>ARP</legend>
- <div class="cbi-section-node">
- <table class="cbi-section-table">
- <tr class="cbi-section-table-titles">
- <th class="cbi-section-table-cell"><%_<abbr title="Internet Protocol Version 4">IPv4</abbr>-Address%></th>
- <th class="cbi-section-table-cell"><%_<abbr title="Media Access Control">MAC</abbr>-Address%></th>
- <th class="cbi-section-table-cell"><%:Interface%></th>
- </tr>
-
- <% luci.sys.net.arptable(function(e) %>
- <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
- <td class="cbi-value-field"><%=e["IP address"]%></td>
- <td class="cbi-value-field"><%=e["HW address"]%></td>
- <td class="cbi-value-field"><%=e["Device"]%></td>
- </tr>
- <% style = not style; end) %>
- </table>
- </div>
- </fieldset>
- <br />
-
- <fieldset class="cbi-section" id="cbi-table-table">
- <legend><%:Active Connections%></legend>
- <div class="cbi-section-node">
- <table class="cbi-section-table">
- <tr class="cbi-section-table-titles">
- <th class="cbi-section-table-cell"><%:Network%></th>
- <th class="cbi-section-table-cell"><%:Protocol%></th>
- <th class="cbi-section-table-cell"><%:Source%></th>
- <th class="cbi-section-table-cell"><%:Destination%></th>
- </tr>
-
- <% style = true; luci.sys.net.conntrack(function(c) %>
- <tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
- <td class="cbi-value-field"><%=c.layer3:upper()%></td>
- <td class="cbi-value-field"><%=c.layer4:upper()%></td>
- <td class="cbi-value-field"><%=
- c.layer3 == "ipv6"
- and "[%s]:%d" %{ c.src, c.sport }
- or "%s:%d" %{ c.src, c.sport }
- %></td>
- <td class="cbi-value-field"><%=
- c.layer3 == "ipv6"
- and "[%s]:%d" %{ c.dst, c.dport }
- or "%s:%d" %{ c.dst, c.dport }
- %></td>
- </tr>
- <% style = not style; end) %>
- </table>
- </div>
- </fieldset>
- <br />
-</div>
-
-<%+footer%>