summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-status
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-status')
-rw-r--r--modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js222
-rw-r--r--modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js253
-rw-r--r--modules/luci-mod-status/luasrc/controller/admin/status.lua22
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/bandwidth.htm11
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/connections.htm30
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index.htm382
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm29
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm31
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm17
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm14
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm20
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm26
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/iptables.htm148
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/load.htm26
-rw-r--r--modules/luci-mod-status/luasrc/view/admin_status/wireless.htm27
15 files changed, 735 insertions, 523 deletions
diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js
new file mode 100644
index 0000000000..3a895eca18
--- /dev/null
+++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js
@@ -0,0 +1,222 @@
+function progressbar(query, value, max, byte)
+{
+ var pg = document.querySelector(query),
+ vn = parseInt(value) || 0,
+ mn = parseInt(max) || 100,
+ fv = byte ? String.format('%1024.2mB', value) : value,
+ fm = byte ? String.format('%1024.2mB', max) : max,
+ pc = Math.floor((100 / mn) * vn);
+
+ if (pg) {
+ pg.firstElementChild.style.width = pc + '%';
+ pg.setAttribute('title', '%s / %s (%d%%)'.format(fv, fm, pc));
+ }
+}
+
+function renderBox(title, active, childs) {
+ childs = childs || [];
+ childs.unshift(L.itemlist(E('span'), [].slice.call(arguments, 3)));
+
+ return E('div', { class: 'ifacebox' }, [
+ E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
+ E('strong', title)),
+ E('div', { class: 'ifacebox-body left' }, childs)
+ ]);
+}
+
+function renderBadge(icon, title) {
+ return E('span', { class: 'ifacebadge' }, [
+ E('img', { src: icon, title: title || '' }),
+ L.itemlist(E('span'), [].slice.call(arguments, 2))
+ ]);
+}
+
+L.poll(5, L.location(), { status: 1 },
+ function(x, info)
+ {
+ var us = document.getElementById('upstream_status_table');
+
+ while (us.lastElementChild)
+ us.removeChild(us.lastElementChild);
+
+ var wan_list = info.wan || [];
+
+ for (var i = 0; i < wan_list.length; i++) {
+ var ifc = wan_list[i];
+
+ us.appendChild(renderBox(
+ _('IPv4 Upstream'),
+ (ifc.ifname && ifc.proto != 'none'),
+ [ E('div', {}, renderBadge(
+ L.resource('icons/%s.png').format((ifc && ifc.type) ? ifc.type : 'ethernet_disabled'), null,
+ _('Device'), ifc ? (ifc.name || ifc.ifname || '-') : '-',
+ _('MAC-Address'), (ifc && ifc.ether) ? ifc.mac : null)) ],
+ _('Protocol'), ifc.i18n || E('em', _('Not connected')),
+ _('Address'), (ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0',
+ _('Netmask'), (ifc.netmask && ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255',
+ _('Gateway'), (ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0',
+ _('DNS') + ' 1', (ifc.dns) ? ifc.dns[0] : null,
+ _('DNS') + ' 2', (ifc.dns) ? ifc.dns[1] : null,
+ _('DNS') + ' 3', (ifc.dns) ? ifc.dns[2] : null,
+ _('DNS') + ' 4', (ifc.dns) ? ifc.dns[3] : null,
+ _('DNS') + ' 5', (ifc.dns) ? ifc.dns[4] : null,
+ _('Expires'), (ifc.expires > -1) ? '%t'.format(ifc.expires) : null,
+ _('Connected'), (ifc.uptime > 0) ? '%t'.format(ifc.uptime) : null));
+ }
+
+ var wan6_list = info.wan6 || [];
+
+ for (var i = 0; i < wan6_list.length; i++) {
+ var ifc6 = wan6_list[i];
+
+ us.appendChild(renderBox(
+ _('IPv6 Upstream'),
+ (ifc6.ifname && ifc6.proto != 'none'),
+ [ E('div', {}, renderBadge(
+ L.resource('icons/%s.png').format(ifc6.type || 'ethernet_disabled'), null,
+ _('Device'), ifc6 ? (ifc6.name || ifc6.ifname || '-') : '-',
+ _('MAC-Address'), (ifc6 && ifc6.ether) ? ifc6.mac : null)) ],
+ _('Protocol'), ifc6.i18n ? (ifc6.i18n + (ifc6.proto === 'dhcp' && ifc6.ip6prefix ? '-PD' : '')) : E('em', _('Not connected')),
+ _('Prefix Delegated'), ifc6.ip6prefix,
+ _('Address'), (ifc6.ip6prefix) ? (ifc6.ip6addr || null) : (ifc6.ip6addr || '::'),
+ _('Gateway'), (ifc6.gw6addr) ? ifc6.gw6addr : '::',
+ _('DNS') + ' 1', (ifc6.dns) ? ifc6.dns[0] : null,
+ _('DNS') + ' 2', (ifc6.dns) ? ifc6.dns[1] : null,
+ _('DNS') + ' 3', (ifc6.dns) ? ifc6.dns[2] : null,
+ _('DNS') + ' 4', (ifc6.dns) ? ifc6.dns[3] : null,
+ _('DNS') + ' 5', (ifc6.dns) ? ifc6.dns[4] : null,
+ _('Connected'), (ifc6.uptime > 0) ? '%t'.format(ifc6.uptime) : null));
+ }
+
+ var ds = document.getElementById('dsl_status_table');
+ if (ds) {
+ while (ds.lastElementChild)
+ ds.removeChild(ds.lastElementChild);
+
+ ds.appendChild(renderBox(
+ _('DSL Status'),
+ (info.dsl.line_state === 'UP'), [ ],
+ _('Line State'), '%s [0x%x]'.format(info.dsl.line_state, info.dsl.line_state_detail),
+ _('Line Mode'), info.dsl.line_mode_s || '-',
+ _('Line Uptime'), info.dsl.line_uptime_s || '-',
+ _('Annex'), info.dsl.annex_s || '-',
+ _('Profile'), info.dsl.profile_s || '-',
+ _('Data Rate'), '%s/s / %s/s'.format(info.dsl.data_rate_down_s, info.dsl.data_rate_up_s),
+ _('Max. Attainable Data Rate (ATTNDR)'), '%s/s / %s/s'.format(info.dsl.max_data_rate_down_s, info.dsl.max_data_rate_up_s),
+ _('Latency'), '%s / %s'.format(info.dsl.latency_num_down, info.dsl.latency_num_up),
+ _('Line Attenuation (LATN)'), '%.1f dB / %.1f dB'.format(info.dsl.line_attenuation_down, info.dsl.line_attenuation_up),
+ _('Signal Attenuation (SATN)'), '%.1f dB / %.1f dB'.format(info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up),
+ _('Noise Margin (SNR)'), '%.1f dB / %.1f dB'.format(info.dsl.noise_margin_down, info.dsl.noise_margin_up),
+ _('Aggregate Transmit Power(ACTATP)'), '%.1f dB / %.1f dB'.format(info.dsl.actatp_down, info.dsl.actatp_up),
+ _('Forward Error Correction Seconds (FECS)'), '%d / %d'.format(info.dsl.errors_fec_near, info.dsl.errors_fec_far),
+ _('Errored seconds (ES)'), '%d / %d'.format(info.dsl.errors_es_near, info.dsl.errors_es_far),
+ _('Severely Errored Seconds (SES)'), '%d / %d'.format(info.dsl.errors_ses_near, info.dsl.errors_ses_far),
+ _('Loss of Signal Seconds (LOSS)'), '%d / %d'.format(info.dsl.errors_loss_near, info.dsl.errors_loss_far),
+ _('Unavailable Seconds (UAS)'), '%d / %d'.format(info.dsl.errors_uas_near, info.dsl.errors_uas_far),
+ _('Header Error Code Errors (HEC)'), '%d / %d'.format(info.dsl.errors_hec_near, info.dsl.errors_hec_far),
+ _('Non Pre-emtive CRC errors (CRC_P)'), '%d / %d'.format(info.dsl.errors_crc_p_near, info.dsl.errors_crc_p_far),
+ _('Pre-emtive CRC errors (CRCP_P)'), '%d / %d'.format(info.dsl.errors_crcp_p_near, info.dsl.errors_crcp_p_far),
+ _('ATU-C System Vendor ID'), info.dsl.atuc_vendor_id,
+ _('Power Management Mode'), info.dsl.power_mode_s));
+ }
+
+ var ws = document.getElementById('wifi_status_table');
+ if (ws)
+ {
+ while (ws.lastElementChild)
+ ws.removeChild(ws.lastElementChild);
+
+ for (var didx = 0; didx < info.wifinets.length; didx++)
+ {
+ var dev = info.wifinets[didx];
+ var net0 = (dev.networks && dev.networks[0]) ? dev.networks[0] : {};
+ var vifs = [];
+
+ for (var nidx = 0; nidx < dev.networks.length; nidx++)
+ {
+ var net = dev.networks[nidx];
+ var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
+
+ var icon;
+ if (net.disabled)
+ icon = L.resource('icons/signal-none.png');
+ else if (net.quality <= 0)
+ icon = L.resource('icons/signal-0.png');
+ else if (net.quality < 25)
+ icon = L.resource('icons/signal-0-25.png');
+ else if (net.quality < 50)
+ icon = L.resource('icons/signal-25-50.png');
+ else if (net.quality < 75)
+ icon = L.resource('icons/signal-50-75.png');
+ else
+ icon = L.resource('icons/signal-75-100.png');
+
+ vifs.push(renderBadge(
+ icon,
+ '%s: %d dBm / %s: %d%%'.format(_('Signal'), net.signal, _('Quality'), net.quality),
+ _('SSID'), E('a', { href: net.link }, [ net.ssid || '?' ]),
+ _('Mode'), net.mode,
+ _('BSSID'), is_assoc ? (net.bssid || '-') : null,
+ _('Encryption'), is_assoc ? net.encryption : null,
+ _('Associations'), is_assoc ? (net.num_assoc || '-') : null,
+ null, is_assoc ? null : E('em', net.disabled ? _('Wireless is disabled') : _('Wireless is not associated'))));
+ }
+
+ ws.appendChild(renderBox(
+ dev.device, dev.up || net0.up,
+ [ E('div', vifs) ],
+ _('Type'), dev.name.replace(/^Generic | Wireless Controller .+$/g, ''),
+ _('Channel'), net0.channel ? '%d (%.3f %s)'.format(net0.channel, net0.frequency, _('GHz')) : '-',
+ _('Bitrate'), net0.bitrate ? '%d %s'.format(net0.bitrate, _('Mbit/s')) : '-'));
+ }
+
+ if (!ws.lastElementChild)
+ ws.appendChild(E('em', _('No information available')));
+ }
+
+ var e;
+
+ if (e = document.getElementById('localtime'))
+ e.innerHTML = info.localtime;
+
+ if (e = document.getElementById('uptime'))
+ e.innerHTML = String.format('%t', info.uptime);
+
+ if (e = document.getElementById('loadavg'))
+ e.innerHTML = String.format(
+ '%.02f, %.02f, %.02f',
+ info.loadavg[0] / 65535.0,
+ info.loadavg[1] / 65535.0,
+ info.loadavg[2] / 65535.0
+ );
+
+ progressbar('#memtotal',
+ info.memory.free + info.memory.buffered,
+ info.memory.total,
+ true);
+
+ progressbar('#memfree',
+ info.memory.free,
+ info.memory.total,
+ true);
+
+ progressbar('#membuff',
+ info.memory.buffered,
+ info.memory.total,
+ true);
+
+ progressbar('#swaptotal',
+ info.swap.free,
+ info.swap.total,
+ true);
+
+ progressbar('#swapfree',
+ info.swap.free,
+ info.swap.total,
+ true);
+
+ progressbar('#conns',
+ info.conncount, info.connmax, false);
+
+ }
+);
diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js
new file mode 100644
index 0000000000..a742243a03
--- /dev/null
+++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/iptables.js
@@ -0,0 +1,253 @@
+var table_names = [ 'Filter', 'NAT', 'Mangle', 'Raw' ],
+ current_mode = document.querySelector('.cbi-tab[data-mode="6"]') ? 6 : 4;
+
+function create_table_section(table)
+{
+ var idiv = document.getElementById('iptables'),
+ tdiv = idiv.querySelector('[data-table="%s"]'.format(table)),
+ title = '%s: %s'.format(_('Table'), table);
+
+ if (!tdiv) {
+ tdiv = E('div', { 'data-table': table }, [
+ E('h3', {}, title),
+ E('div')
+ ]);
+
+ if (idiv.firstElementChild.nodeName.toLowerCase() === 'p')
+ idiv.removeChild(idiv.firstElementChild);
+
+ var added = false, thisIdx = table_names.indexOf(table);
+
+ idiv.querySelectorAll('[data-table]').forEach(function(child) {
+ var childIdx = table_names.indexOf(child.getAttribute('data-table'));
+
+ if (added === false && childIdx > thisIdx) {
+ idiv.insertBefore(tdiv, child);
+ added = true;
+ }
+ });
+
+ if (added === false)
+ idiv.appendChild(tdiv);
+ }
+
+ return tdiv.lastElementChild;
+}
+
+function create_chain_section(table, chain, policy, packets, bytes, references)
+{
+ var tdiv = create_table_section(table),
+ cdiv = tdiv.querySelector('[data-chain="%s"]'.format(chain)),
+ title;
+
+ if (policy)
+ title = '%s <em>%s</em> <span>(%s: <em>%s</em>, %d %s, %.2mB %s)</span>'
+ .format(_('Chain'), chain, _('Policy'), policy, packets, _('Packets'), bytes, _('Traffic'));
+ else
+ title = '%s <em>%s</em> <span class="references">(%d %s)</span>'
+ .format(_('Chain'), chain, references, _('References'));
+
+ if (!cdiv) {
+ cdiv = E('div', { 'data-chain': chain }, [
+ E('h4', { 'id': 'rule_%s_%s'.format(table.toLowerCase(), chain) }, title),
+ E('div', { 'class': 'table' }, [
+ E('div', { 'class': 'tr table-titles' }, [
+ E('div', { 'class': 'th center' }, _('Pkts.')),
+ E('div', { 'class': 'th center' }, _('Traffic')),
+ E('div', { 'class': 'th' }, _('Target')),
+ E('div', { 'class': 'th' }, _('Prot.')),
+ E('div', { 'class': 'th' }, _('In')),
+ E('div', { 'class': 'th' }, _('Out')),
+ E('div', { 'class': 'th' }, _('Source')),
+ E('div', { 'class': 'th' }, _('Destination')),
+ E('div', { 'class': 'th' }, _('Options')),
+ E('div', { 'class': 'th' }, _('Comment'))
+ ])
+ ])
+ ]);
+
+ tdiv.appendChild(cdiv);
+ }
+ else {
+ cdiv.firstElementChild.innerHTML = title;
+ }
+
+ return cdiv.lastElementChild;
+}
+
+function update_chain_section(chaintable, rows)
+{
+ if (!chaintable)
+ return;
+
+ cbi_update_table(chaintable, rows, _('No rules in this chain.'));
+
+ if (rows.length === 0 &&
+ document.querySelector('form > [data-hide-empty="true"]'))
+ chaintable.parentNode.style.display = 'none';
+ else
+ chaintable.parentNode.style.display = '';
+
+ chaintable.parentNode.setAttribute('data-empty', rows.length === 0);
+}
+
+function hide_empty(btn)
+{
+ var hide = (btn.getAttribute('data-hide-empty') === 'false');
+
+ btn.setAttribute('data-hide-empty', hide);
+ btn.value = hide ? _('Show empty chains') : _('Hide empty chains');
+ btn.blur();
+
+ document.querySelectorAll('[data-chain][data-empty="true"]')
+ .forEach(function(chaintable) {
+ chaintable.style.display = hide ? 'none' : '';
+ });
+}
+
+function jump_target(ev)
+{
+ var link = ev.target,
+ table = findParent(link, '[data-table]').getAttribute('data-table'),
+ chain = link.textContent,
+ num = +link.getAttribute('data-num'),
+ elem = document.getElementById('rule_%s_%s'.format(table.toLowerCase(), chain));
+
+ if (elem) {
+ (document.documentElement || document.body.parentNode || document.body).scrollTop = elem.offsetTop - 40;
+ elem.classList.remove('flash');
+ void elem.offsetWidth;
+ elem.classList.add('flash');
+
+ if (num) {
+ var rule = elem.nextElementSibling.childNodes[num];
+ if (rule) {
+ rule.classList.remove('flash');
+ void rule.offsetWidth;
+ rule.classList.add('flash');
+ }
+ }
+ }
+}
+
+function parse_output(table, s)
+{
+ var current_chain = null;
+ var current_rules = [];
+ var seen_chains = {};
+ var chain_refs = {};
+ var re = /([^\n]*)\n/g;
+ var m, m2;
+
+ while ((m = re.exec(s)) != null) {
+ if (m[1].match(/^Chain (.+) \(policy (\w+) (\d+) packets, (\d+) bytes\)$/)) {
+ var chain = RegExp.$1,
+ policy = RegExp.$2,
+ packets = +RegExp.$3,
+ bytes = +RegExp.$4;
+
+ update_chain_section(current_chain, current_rules);
+
+ seen_chains[chain] = true;
+ current_chain = create_chain_section(table, chain, policy, packets, bytes);
+ current_rules = [];
+ }
+ else if (m[1].match(/^Chain (.+) \((\d+) references\)$/)) {
+ var chain = RegExp.$1,
+ references = +RegExp.$2;
+
+ update_chain_section(current_chain, current_rules);
+
+ seen_chains[chain] = true;
+ current_chain = create_chain_section(table, chain, null, null, null, references);
+ current_rules = [];
+ }
+ else if (m[1].match(/^num /)) {
+ continue;
+ }
+ else if ((m2 = m[1].match(/^(\d+) +(\d+) +(\d+) +(.*?) +(\S+) +(\S*) +(\S+) +(\S+) +([a-f0-9:.]+(?:\/[a-f0-9:.]+)?) +([a-f0-9:.]+(?:\/[a-f0-9:.]+)?) +(.+)$/)) !== null) {
+ var num = +m2[1],
+ pkts = +m2[2],
+ bytes = +m2[3],
+ target = m2[4],
+ proto = m2[5],
+ indev = m2[7],
+ outdev = m2[8],
+ srcnet = m2[9],
+ dstnet = m2[10],
+ options = m2[11] || '-',
+ comment = '-';
+
+ options = options.trim().replace(/(?:^| )\/\* (.+) \*\//,
+ function(m1, m2) {
+ comment = m2.replace(/^!fw3(: |$)/, '').trim() || '-';
+ return '';
+ }) || '-';
+
+ current_rules.push([
+ '%.2m'.format(pkts).nobr(),
+ '%.2mB'.format(bytes).nobr(),
+ target ? '<span class="target">%s</span>'.format(target) : '-',
+ proto,
+ (indev !== '*') ? '<span class="ifacebadge">%s</span>'.format(indev) : '*',
+ (outdev !== '*') ? '<span class="ifacebadge">%s</span>'.format(outdev) : '*',
+ srcnet,
+ dstnet,
+ options,
+ comment
+ ]);
+
+ if (target) {
+ chain_refs[target] = chain_refs[target] || [];
+ chain_refs[target].push([ current_chain, num ]);
+ }
+ }
+ }
+
+ update_chain_section(current_chain, current_rules);
+
+ document.querySelectorAll('[data-table="%s"] [data-chain]'.format(table))
+ .forEach(function(cdiv) {
+ if (!seen_chains[cdiv.getAttribute('data-chain')]) {
+ cdiv.parentNode.removeChild(cdiv);
+ return;
+ }
+
+ cdiv.querySelectorAll('.target').forEach(function(tspan) {
+ if (seen_chains[tspan.textContent]) {
+ tspan.classList.add('jump');
+ tspan.addEventListener('click', jump_target);
+ }
+ });
+
+ cdiv.querySelectorAll('.references').forEach(function(rspan) {
+ var refs = chain_refs[cdiv.getAttribute('data-chain')];
+ if (refs && refs.length) {
+ rspan.classList.add('cbi-tooltip-container');
+ rspan.appendChild(E('small', { 'class': 'cbi-tooltip ifacebadge', 'style': 'top:1em; left:auto' }, [ E('ul') ]));
+
+ refs.forEach(function(ref) {
+ var chain = ref[0].parentNode.getAttribute('data-chain'),
+ num = ref[1];
+
+ rspan.lastElementChild.lastElementChild.appendChild(E('li', {}, [
+ _('Chain'), ' ',
+ E('span', {
+ 'class': 'jump',
+ 'data-num': num,
+ 'onclick': 'jump_target(event)'
+ }, chain),
+ ', %s #%d'.format(_('Rule'), num)
+ ]));
+ });
+ }
+ });
+ });
+}
+
+table_names.forEach(function(table) {
+ L.poll(5, L.url('admin/status/iptables_dump', current_mode, table.toLowerCase()), null,
+ function (xhr) {
+ parse_output(table, xhr.responseText);
+ });
+});
diff --git a/modules/luci-mod-status/luasrc/controller/admin/status.lua b/modules/luci-mod-status/luasrc/controller/admin/status.lua
index 4f04cce545..0d955c95fe 100644
--- a/modules/luci-mod-status/luasrc/controller/admin/status.lua
+++ b/modules/luci-mod-status/luasrc/controller/admin/status.lua
@@ -8,6 +8,7 @@ function index()
entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1)
entry({"admin", "status", "iptables"}, template("admin_status/iptables"), _("Firewall"), 2).leaf = true
+ entry({"admin", "status", "iptables_dump"}, call("dump_iptables")).leaf = true
entry({"admin", "status", "iptables_action"}, post("action_iptables")).leaf = true
entry({"admin", "status", "routes"}, template("admin_status/routes"), _("Routes"), 3)
@@ -44,6 +45,27 @@ function action_dmesg()
luci.template.render("admin_status/dmesg", {dmesg=dmesg})
end
+function dump_iptables(family, table)
+ local prefix = (family == "6") and "ip6" or "ip"
+ local ok, lines = pcall(io.lines, "/proc/net/%s_tables_names" % prefix)
+ if ok and lines then
+ local s
+ for s in lines do
+ if s == table then
+ luci.http.prepare_content("text/plain")
+ luci.sys.process.exec({
+ "/usr/sbin/%stables" % prefix, "-w", "-t", table,
+ "--line-numbers", "-nxvL"
+ }, luci.http.write)
+ return
+ end
+ end
+ end
+
+ luci.http.status(404, "No such table")
+ luci.http.prepare_content("text/plain")
+end
+
function action_iptables()
if luci.http.formvalue("zero") then
if luci.http.formvalue("family") == "6" then
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/bandwidth.htm b/modules/luci-mod-status/luasrc/view/admin_status/bandwidth.htm
index 3bb55f9054..5cc661ad17 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/bandwidth.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/bandwidth.htm
@@ -1,5 +1,5 @@
<%#
- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
+ Copyright 2010-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
@@ -34,7 +34,7 @@
var step = 5;
var data_wanted = Math.floor(width / step);
- var data_fill = 0;
+ var data_fill = 1;
var data_stamp = 0;
var data_rx = [ ];
@@ -178,6 +178,8 @@
if (data[i][TIME] <= data_stamp)
continue;
+ data_fill++;
+
/* normalize difference against time interval */
if (i > 0)
{
@@ -193,6 +195,7 @@
/* cut off outdated entries */
data_rx = data_rx.slice(data_rx.length - data_wanted, data_rx.length);
data_tx = data_tx.slice(data_tx.length - data_wanted, data_tx.length);
+ data_fill = Math.min(data_fill, data_wanted);
/* find peak */
for (var i = 0; i < data_rx.length; i++)
@@ -207,8 +210,8 @@
data_tx_avg += data_tx[i];
}
- data_rx_avg = (data_rx_avg / Math.max(data_rx.length, 1));
- data_tx_avg = (data_tx_avg / Math.max(data_tx.length, 1));
+ data_rx_avg = (data_rx_avg / data_fill);
+ data_tx_avg = (data_tx_avg / data_fill);
var size = Math.floor(Math.log2(data_max)),
div = Math.pow(2, size - (size % 10)),
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/connections.htm b/modules/luci-mod-status/luasrc/view/admin_status/connections.htm
index 0a0db3be78..e3dd39d607 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/connections.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/connections.htm
@@ -1,5 +1,5 @@
<%#
- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
+ Copyright 2010-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
@@ -19,7 +19,7 @@
var step = 5;
var data_wanted = Math.floor(width / step);
- var data_fill = 0;
+ var data_fill = 1;
var data_stamp = 0;
var data_udp = [ ];
@@ -165,8 +165,8 @@
rows.push([
c.layer3.toUpperCase(),
c.layer4.toUpperCase(),
- src + ':' + c.sport,
- dst + ':' + c.dport,
+ c.hasOwnProperty('sport') ? (src + ':' + c.sport) : src,
+ c.hasOwnProperty('dport') ? (dst + ':' + c.dport) : dst,
'%1024.2mB (%d <%:Pkts.%>)'.format(c.bytes, c.packets)
]);
}
@@ -202,12 +202,15 @@
if (data[i][TIME] <= data_stamp)
continue;
+ data_fill++;
+
data_udp.push(data[i][UDP]);
data_tcp.push(data[i][TCP]);
data_otr.push(data[i][OTHER]);
}
/* cut off outdated entries */
+ data_fill = Math.min(data_fill, data_wanted);
data_udp = data_udp.slice(data_udp.length - data_wanted, data_udp.length);
data_tcp = data_tcp.slice(data_tcp.length - data_wanted, data_tcp.length);
data_otr = data_otr.slice(data_otr.length - data_wanted, data_otr.length);
@@ -223,20 +226,15 @@
data_tcp_peak = Math.max(data_tcp_peak, data_tcp[i]);
data_otr_peak = Math.max(data_otr_peak, data_otr[i]);
- if (i > 0)
- {
- data_udp_avg = (data_udp_avg + data_udp[i]) / 2;
- data_tcp_avg = (data_tcp_avg + data_tcp[i]) / 2;
- data_otr_avg = (data_otr_avg + data_otr[i]) / 2;
- }
- else
- {
- data_udp_avg = data_udp[i];
- data_tcp_avg = data_tcp[i];
- data_otr_avg = data_otr[i];
- }
+ data_udp_avg += data_udp[i];
+ data_tcp_avg += data_tcp[i];
+ data_otr_avg += data_otr[i];
}
+ data_udp_avg = data_udp_avg / data_fill;
+ data_tcp_avg = data_tcp_avg / data_fill;
+ data_otr_avg = data_otr_avg / data_fill;
+
/* remember current timestamp, calculate horizontal scale */
data_stamp = data[data.length-1][TIME];
data_scale = height / (data_max * 1.1);
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index.htm b/modules/luci-mod-status/luasrc/view/admin_status/index.htm
index 54e35b82a0..465226fe09 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index.htm
@@ -1,6 +1,6 @@
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
@@ -11,29 +11,24 @@
local stat = require "luci.tools.status"
local ver = require "luci.version"
- local has_ipv6 = fs.access("/proc/net/ipv6_route")
- local has_dhcp = fs.access("/etc/config/dhcp")
- local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
+ if luci.http.formvalue("status") == "1" then
- local sysinfo = luci.util.ubus("system", "info") or { }
- local boardinfo = luci.util.ubus("system", "board") or { }
- local unameinfo = nixio.uname() or { }
+ local sysinfo = luci.util.ubus("system", "info") or { }
- local meminfo = sysinfo.memory or {
- total = 0,
- free = 0,
- buffered = 0,
- shared = 0
- }
+ local meminfo = sysinfo.memory or {
+ total = 0,
+ free = 0,
+ buffered = 0,
+ shared = 0
+ }
- local swapinfo = sysinfo.swap or {
- total = 0,
- free = 0
- }
+ local swapinfo = sysinfo.swap or {
+ total = 0,
+ free = 0
+ }
- local has_dsl = fs.access("/etc/init.d/dsl_control")
+ local has_dsl = fs.access("/etc/init.d/dsl_control")
- if luci.http.formvalue("status") == "1" then
local ntm = require "luci.model.network".init()
local wan_nets = ntm:get_wan_networks()
local wan6_nets = ntm:get_wan6_networks()
@@ -131,357 +126,24 @@
<%+header%>
-<script type="text/javascript">//<![CDATA[
- function progressbar(v, m)
- {
- var vn = parseInt(v) || 0;
- var mn = parseInt(m) || 100;
- var pc = Math.floor((100 / mn) * vn);
-
- return String.format(
- '<div style="width:100%%; max-width:200px; position:relative; border:1px solid #999999">' +
- '<div style="background-color:#CCCCCC; width:%d%%; height:15px">' +
- '<div style="position:absolute; left:0; top:0; text-align:center; width:100%%; color:#000000">' +
- '<small>%s / %s (%d%%)</small>' +
- '</div>' +
- '</div>' +
- '</div>', pc, v, m, pc
- );
- }
-
- function labelList(items, offset) {
- var rv = [ ];
-
- for (var i = offset || 0; i < items.length; i += 2) {
- var label = items[i],
- value = items[i+1];
-
- if (value === undefined || value === null)
- continue;
-
- if (label)
- rv.push(E('strong', [label, ': ']));
-
- rv.push(value, E('br'));
- }
-
- return rv;
- }
-
- function renderBox(title, active, childs) {
- childs = childs || [];
- childs.unshift(E('span', labelList(arguments, 3)));
-
- return E('div', { class: 'ifacebox' }, [
- E('div', { class: 'ifacebox-head center ' + (active ? 'active' : '') },
- E('strong', title)),
- E('div', { class: 'ifacebox-body left' }, childs)
- ]);
- }
-
- function renderBadge(icon, title) {
- return E('span', { class: 'ifacebadge' }, [
- E('img', { src: icon, title: title || '' }),
- E('span', labelList(arguments, 2))
- ]);
- }
-
- XHR.poll(5, '<%=REQUEST_URI%>', { status: 1 },
- function(x, info)
- {
- var us = document.getElementById('upstream_status_table');
-
- while (us.lastElementChild)
- us.removeChild(us.lastElementChild);
-
- var wan_list = info.wan || [];
-
- for (var i = 0; i < wan_list.length; i++) {
- var ifc = wan_list[i];
-
- us.appendChild(renderBox(
- '<%:IPv4 Upstream%>',
- (ifc.ifname && ifc.proto != 'none'),
- [ E('div', {}, renderBadge(
- '<%=resource%>' + '/icons/%s.png'.format((ifc && ifc.type) ? ifc.type : 'ethernet_disabled'), null,
- '<%:Device%>', ifc ? (ifc.name || ifc.ifname || '-') : '-',
- '<%:MAC-Address%>', (ifc && ifc.ether) ? ifc.mac : null)) ],
- '<%:Protocol%>', ifc.i18n || E('em', '<%:Not connected%>'),
- '<%:Address%>', (ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0',
- '<%:Netmask%>', (ifc.netmask && ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255',
- '<%:Gateway%>', (ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0',
- '<%:DNS%> 1', (ifc.dns) ? ifc.dns[0] : null,
- '<%:DNS%> 2', (ifc.dns) ? ifc.dns[1] : null,
- '<%:DNS%> 3', (ifc.dns) ? ifc.dns[2] : null,
- '<%:DNS%> 4', (ifc.dns) ? ifc.dns[3] : null,
- '<%:DNS%> 5', (ifc.dns) ? ifc.dns[4] : null,
- '<%:Expires%>', (ifc.expires > -1) ? '%t'.format(ifc.expires) : null,
- '<%:Connected%>', (ifc.uptime > 0) ? '%t'.format(ifc.uptime) : null));
- }
-
- <% if has_ipv6 then %>
- var wan6_list = info.wan6 || [];
-
- for (var i = 0; i < wan6_list.length; i++) {
- var ifc6 = wan6_list[i];
-
- us.appendChild(renderBox(
- '<%:IPv6 Upstream%>',
- (ifc6.ifname && ifc6.proto != 'none'),
- [ E('div', {}, renderBadge(
- '<%=resource%>/icons/%s.png'.format(ifc6.type || 'ethernet_disabled'), null,
- '<%:Device%>', ifc6 ? (ifc6.name || ifc6.ifname || '-') : '-',
- '<%:MAC-Address%>', (ifc6 && ifc6.ether) ? ifc6.mac : null)) ],
- '<%:Protocol%>', ifc6.i18n ? (ifc6.i18n + (ifc6.proto === 'dhcp' && ifc6.ip6prefix ? '-PD' : '')) : E('em', '<%:Not connected%>'),
- '<%:Prefix Delegated%>', ifc6.ip6prefix,
- '<%:Address%>', (ifc6.ip6prefix) ? (ifc6.ip6addr || null) : (ifc6.ip6addr || '::'),
- '<%:Gateway%>', (ifc6.gw6addr) ? ifc6.gw6addr : '::',
- '<%:DNS%> 1', (ifc6.dns) ? ifc6.dns[0] : null,
- '<%:DNS%> 2', (ifc6.dns) ? ifc6.dns[1] : null,
- '<%:DNS%> 3', (ifc6.dns) ? ifc6.dns[2] : null,
- '<%:DNS%> 4', (ifc6.dns) ? ifc6.dns[3] : null,
- '<%:DNS%> 5', (ifc6.dns) ? ifc6.dns[4] : null,
- '<%:Connected%>', (ifc6.uptime > 0) ? '%t'.format(ifc6.uptime) : null));
- }
- <% end %>
-
- <% if has_dsl then %>
- var ds = document.getElementById('dsl_status_table');
-
- while (ds.lastElementChild)
- ds.removeChild(ds.lastElementChild);
-
- ds.appendChild(renderBox(
- '<%:DSL Status%>',
- (info.dsl.line_state === 'UP'), [ ],
- '<%:Line State%>', '%s [0x%x]'.format(info.dsl.line_state, info.dsl.line_state_detail),
- '<%:Line Mode%>', info.dsl.line_mode_s || '-',
- '<%:Line Uptime%>', info.dsl.line_uptime_s || '-',
- '<%:Annex%>', info.dsl.annex_s || '-',
- '<%:Profile%>', info.dsl.profile_s || '-',
- '<%:Data Rate%>', '%s/s / %s/s'.format(info.dsl.data_rate_down_s, info.dsl.data_rate_up_s),
- '<%:Max. Attainable Data Rate (ATTNDR)%>', '%s/s / %s/s'.format(info.dsl.max_data_rate_down_s, info.dsl.max_data_rate_up_s),
- '<%:Latency%>', '%s / %s'.format(info.dsl.latency_num_down, info.dsl.latency_num_up),
- '<%:Line Attenuation (LATN)%>', '%.1f dB / %.1f dB'.format(info.dsl.line_attenuation_down, info.dsl.line_attenuation_up),
- '<%:Signal Attenuation (SATN)%>', '%.1f dB / %.1f dB'.format(info.dsl.signal_attenuation_down, info.dsl.signal_attenuation_up),
- '<%:Noise Margin (SNR)%>', '%.1f dB / %.1f dB'.format(info.dsl.noise_margin_down, info.dsl.noise_margin_up),
- '<%:Aggregate Transmit Power(ACTATP)%>', '%.1f dB / %.1f dB'.format(info.dsl.actatp_down, info.dsl.actatp_up),
- '<%:Forward Error Correction Seconds (FECS)%>', '%d / %d'.format(info.dsl.errors_fec_near, info.dsl.errors_fec_far),
- '<%:Errored seconds (ES)%>', '%d / %d'.format(info.dsl.errors_es_near, info.dsl.errors_es_far),
- '<%:Severely Errored Seconds (SES)%>', '%d / %d'.format(info.dsl.errors_ses_near, info.dsl.errors_ses_far),
- '<%:Loss of Signal Seconds (LOSS)%>', '%d / %d'.format(info.dsl.errors_loss_near, info.dsl.errors_loss_far),
- '<%:Unavailable Seconds (UAS)%>', '%d / %d'.format(info.dsl.errors_uas_near, info.dsl.errors_uas_far),
- '<%:Header Error Code Errors (HEC)%>', '%d / %d'.format(info.dsl.errors_hec_near, info.dsl.errors_hec_far),
- '<%:Non Pre-emtive CRC errors (CRC_P)%>', '%d / %d'.format(info.dsl.errors_crc_p_near, info.dsl.errors_crc_p_far),
- '<%:Pre-emtive CRC errors (CRCP_P)%>', '%d / %d'.format(info.dsl.errors_crcp_p_near, info.dsl.errors_crcp_p_far),
- '<%:ATU-C System Vendor ID%>', info.dsl.atuc_vendor_id,
- '<%:Power Management Mode%>', info.dsl.power_mode_s));
- <% end %>
-
- <% if has_wifi then %>
- var ws = document.getElementById('wifi_status_table');
- if (ws)
- {
- while (ws.lastElementChild)
- ws.removeChild(ws.lastElementChild);
-
- for (var didx = 0; didx < info.wifinets.length; didx++)
- {
- var dev = info.wifinets[didx];
- var net0 = (dev.networks && dev.networks[0]) ? dev.networks[0] : {};
- var vifs = [];
-
- for (var nidx = 0; nidx < dev.networks.length; nidx++)
- {
- var net = dev.networks[nidx];
- var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
-
- var icon;
- if (net.disabled)
- icon = "<%=resource%>/icons/signal-none.png";
- else if (net.quality <= 0)
- icon = "<%=resource%>/icons/signal-0.png";
- else if (net.quality < 25)
- icon = "<%=resource%>/icons/signal-0-25.png";
- else if (net.quality < 50)
- icon = "<%=resource%>/icons/signal-25-50.png";
- else if (net.quality < 75)
- icon = "<%=resource%>/icons/signal-50-75.png";
- else
- icon = "<%=resource%>/icons/signal-75-100.png";
-
- vifs.push(renderBadge(
- icon,
- '<%:Signal%>: %d dBm / <%:Quality%>: %d%%'.format(net.signal, net.quality),
- '<%:SSID%>', E('a', { href: net.link }, [ net.ssid || '?' ]),
- '<%:Mode%>', net.mode,
- '<%:BSSID%>', is_assoc ? (net.bssid || '-') : null,
- '<%:Encryption%>', is_assoc ? net.encryption : null,
- '<%:Associations%>', is_assoc ? (net.num_assoc || '-') : null,
- null, is_assoc ? null : E('em', net.disabled ? '<%:Wireless is disabled%>' : '<%:Wireless is not associated%>')));
- }
-
- ws.appendChild(renderBox(
- dev.device, dev.up || net0.up,
- [ E('div', vifs) ],
- '<%:Type%>', dev.name.replace(/^Generic | Wireless Controller .+$/g, ''),
- '<%:Channel%>', net0.channel ? '%d (%.3f <%:GHz%>)'.format(net0.channel, net0.frequency) : '-',
- '<%:Bitrate%>', net0.bitrate ? '%d <%:Mbit/s%>'.format(net0.bitrate) : '-'));
- }
-
- if (!ws.lastElementChild)
- ws.appendChild(E('<em><%:No information available%></em>'));
- }
- <% end %>
-
- var e;
-
- if (e = document.getElementById('localtime'))
- e.innerHTML = info.localtime;
-
- if (e = document.getElementById('uptime'))
- e.innerHTML = String.format('%t', info.uptime);
-
- if (e = document.getElementById('loadavg'))
- e.innerHTML = String.format(
- '%.02f, %.02f, %.02f',
- info.loadavg[0] / 65535.0,
- info.loadavg[1] / 65535.0,
- info.loadavg[2] / 65535.0
- );
-
- if (e = document.getElementById('memtotal'))
- e.innerHTML = progressbar(
- ((info.memory.free + info.memory.buffered) / 1024) + " <%:kB%>",
- (info.memory.total / 1024) + " <%:kB%>"
- );
-
- if (e = document.getElementById('memfree'))
- e.innerHTML = progressbar(
- (info.memory.free / 1024) + " <%:kB%>",
- (info.memory.total / 1024) + " <%:kB%>"
- );
-
- if (e = document.getElementById('membuff'))
- e.innerHTML = progressbar(
- (info.memory.buffered / 1024) + " <%:kB%>",
- (info.memory.total / 1024) + " <%:kB%>"
- );
-
- if (e = document.getElementById('swaptotal'))
- e.innerHTML = progressbar(
- (info.swap.free / 1024) + " <%:kB%>",
- (info.swap.total / 1024) + " <%:kB%>"
- );
-
- if (e = document.getElementById('swapfree'))
- e.innerHTML = progressbar(
- (info.swap.free / 1024) + " <%:kB%>",
- (info.swap.total / 1024) + " <%:kB%>"
- );
-
- if (e = document.getElementById('conns'))
- e.innerHTML = progressbar(info.conncount, info.connmax);
-
- }
- );
-//]]></script>
-
<h2 name="content"><%:Status%></h2>
-<div class="cbi-section">
- <h3><%:System%></h3>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Hostname%></div><div class="td left"><%=luci.sys.hostname() or "?"%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Model%></div><div class="td left"><%=pcdata(boardinfo.model or "?")%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Architecture%></div><div class="td left"><%=pcdata(boardinfo.system or "?")%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Firmware Version%></div><div class="td left">
- <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
- <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
- </div></div>
- <div class="tr"><div class="td left" width="33%"><%:Kernel Version%></div><div class="td left"><%=unameinfo.release or "?"%></div></div>
- <div class="tr"><div class="td left" width="33%"><%:Local Time%></div><div class="td left" id="localtime">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Uptime%></div><div class="td left" id="uptime">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Load Average%></div><div class="td left" id="loadavg">-</div></div>
- </div>
-</div>
-
-<div class="cbi-section">
- <h3><%:Memory%></h3>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left" id="memtotal">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left" id="memfree">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Buffered%></div><div class="td left" id="membuff">-</div></div>
- </div>
-</div>
-
-<% if swapinfo.total > 0 then %>
-<div class="cbi-section">
- <h3><%:Swap%></h3>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left" id="swaptotal">-</div></div>
- <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left" id="swapfree">-</div></div>
- </div>
-</div>
-<% end %>
-
-<div class="cbi-section">
- <h3><%:Network%></h3>
-
- <div id="upstream_status_table" class="network-status-table">
- <p><em><%:Collecting data...%></em></p>
- </div>
-
- <div class="table" width="100%">
- <div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left" id="conns">-</div></div>
- </div>
-</div>
-
-<%
- if has_dhcp then
- include("lease_status")
- end
-%>
-
-<% if has_dsl then %>
-<div class="cbi-section">
- <h3><%:DSL%></h3>
-
- <div id="dsl_status_table" class="network-status-table">
- <p><em><%:Collecting data...%></em></p>
- </div>
-</div>
-<% end %>
-
-<% if has_wifi then %>
-<div class="cbi-section">
- <h3><%:Wireless%></h3>
-
- <div id="wifi_status_table" class="network-status-table">
- <p><em><%:Collecting data...%></em></p>
- </div>
-</div>
-
-<div class="cbi-section">
- <h3><%:Associated Stations%></h3>
-
- <%+wifi_assoclist%>
-</div>
-<% end %>
-
<%-
local incdir = util.libpath() .. "/view/admin_status/index/"
if fs.access(incdir) then
- local inc
+ local _, inc
+ local includes = {}
for inc in fs.dir(incdir) do
if inc:match("%.htm$") then
- include("admin_status/index/" .. inc:gsub("%.htm$", ""))
+ includes[#includes + 1] = inc:gsub("%.htm$", "")
end
end
+ for _, inc in luci.util.vspairs(includes) do
+ include("admin_status/index/" .. inc)
+ end
end
-%>
+<script type="text/javascript" src="<%=resource%>/view/status/index.js"></script>
+
<%+footer%>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm
new file mode 100644
index 0000000000..994550ec2b
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/10-system.htm
@@ -0,0 +1,29 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local boardinfo = luci.util.ubus("system", "board") or { }
+ local unameinfo = nixio.uname() or { }
+ local ver = require "luci.version"
+%>
+
+<div class="cbi-section">
+ <h3><%:System%></h3>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Hostname%></div><div class="td left"><%=luci.sys.hostname() or "?"%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Model%></div><div class="td left"><%=pcdata(boardinfo.model or "?")%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Architecture%></div><div class="td left"><%=pcdata(boardinfo.system or "?")%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Firmware Version%></div><div class="td left">
+ <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
+ <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
+ </div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Kernel Version%></div><div class="td left"><%=unameinfo.release or "?"%></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Local Time%></div><div class="td left" id="localtime">-</div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Uptime%></div><div class="td left" id="uptime">-</div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Load Average%></div><div class="td left" id="loadavg">-</div></div>
+ </div>
+</div>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm
new file mode 100644
index 0000000000..13774704fe
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/20-memory.htm
@@ -0,0 +1,31 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local sysinfo = luci.util.ubus("system", "info") or { }
+ local has_swap = sysinfo.swap and sysinfo.swap.total > 0 or false
+%>
+
+<div class="cbi-section">
+ <h3><%:Memory%></h3>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="memtotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="memfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Buffered%></div><div class="td left"><div id="membuff" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ </div>
+</div>
+
+<% if has_swap then %>
+<div class="cbi-section">
+ <h3><%:Swap%></h3>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Total Available%></div><div class="td left"><div id="swaptotal" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ <div class="tr"><div class="td left" width="33%"><%:Free%></div><div class="td left"><div id="swapfree" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ </div>
+</div>
+<% end %>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm
new file mode 100644
index 0000000000..945a31b2e5
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/30-network.htm
@@ -0,0 +1,17 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<div class="cbi-section">
+ <h3><%:Network%></h3>
+
+ <div id="upstream_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
+ </div>
+
+ <div class="table" width="100%">
+ <div class="tr"><div class="td left" width="33%"><%:Active Connections%></div><div class="td left"><div id="conns" class="cbi-progressbar" title="-"><div></div></div></div></div>
+ </div>
+</div>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm
new file mode 100644
index 0000000000..aaf3661442
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/40-dhcp-leases.htm
@@ -0,0 +1,14 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local fs = require "nixio.fs"
+ local has_dhcp = fs.access("/etc/config/dhcp")
+
+ if has_dhcp then
+ include("lease_status")
+ end
+%>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm
new file mode 100644
index 0000000000..f37bf147a3
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/50-dsl.htm
@@ -0,0 +1,20 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local fs = require "nixio.fs"
+ local has_dsl = fs.access("/etc/init.d/dsl_control")
+%>
+
+<% if has_dsl then %>
+<div class="cbi-section">
+ <h3><%:DSL%></h3>
+
+ <div id="dsl_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
+ </div>
+</div>
+<% end %>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm b/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm
new file mode 100644
index 0000000000..7338bc77f1
--- /dev/null
+++ b/modules/luci-mod-status/luasrc/view/admin_status/index/60-wifi.htm
@@ -0,0 +1,26 @@
+<%#
+ Copyright 2008 Steven Barth <steven@midlink.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
+ Licensed to the public under the Apache License 2.0.
+-%>
+
+<%
+ local fs = require "nixio.fs"
+ local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
+%>
+
+<% if has_wifi then %>
+<div class="cbi-section">
+ <h3><%:Wireless%></h3>
+
+ <div id="wifi_status_table" class="network-status-table">
+ <p><em><%:Collecting data...%></em></p>
+ </div>
+</div>
+
+<div class="cbi-section">
+ <h3><%:Associated Stations%></h3>
+
+ <%+wifi_assoclist%>
+</div>
+<% end %>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm b/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm
index 51e428e40e..89f229f3ba 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/iptables.htm
@@ -1,16 +1,11 @@
<%#
Copyright 2008-2009 Steven Barth <steven@midlink.org>
- Copyright 2008-2015 Jo-Philipp Wich <jow@openwrt.org>
+ Copyright 2008-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
<%-
-
- require "luci.sys.iptparser"
- local wba = require "luci.tools.webadmin"
local fs = require "nixio.fs"
- local io = require "io"
-
local has_ip6tables = fs.access("/usr/sbin/ip6tables")
local mode = 4
@@ -18,54 +13,31 @@
mode = luci.dispatcher.context.requestpath
mode = tonumber(mode[#mode] ~= "iptables" and mode[#mode]) or 4
end
+-%>
- local ipt = luci.sys.iptparser.IptParser(mode)
-
- local rowcnt = 1
- function rowstyle()
- rowcnt = rowcnt + 1
- return (rowcnt % 2) + 1
- end
-
- function link_target(t,c)
- if ipt:is_custom_target(c) then
- return '<a href="#rule_%s_%s">%s</a>' %{ t:lower(), c, c }
- end
- return c
- end
+<%+header%>
- function link_iface(i)
- local net = wba.iface_get_network(i)
- if net and i ~= "lo" then
- return '<a href="%s">%s</a>' %{
- url("admin/network/network", net), i
- }
+<style type="text/css">
+ span.jump, .cbi-tooltip-container {
+ border-bottom: 1px dotted blue;
+ cursor: pointer;
+ }
- end
- return i
- end
+ ul {
+ list-style: none;
+ }
- local tables = { "Filter", "NAT", "Mangle", "Raw" }
- if mode == 6 then
- tables = { "Filter", "Mangle", "Raw" }
- local ok, lines = pcall(io.lines, "/proc/net/ip6_tables_names")
- if ok and lines then
- local line
- for line in lines do
- if line == "nat" then
- tables = { "Filter", "NAT", "Mangle", "Raw" }
- end
- end
- end
- end
--%>
+ .references {
+ position: relative;
+ }
-<%+header%>
+ .references .cbi-tooltip {
+ left: 0 !important;
+ top: 1.5em !important;
+ }
-<style type="text/css">
- span:target {
- color: blue;
- text-decoration: underline;
+ h4 > span {
+ font-size: 90%;
}
</style>
@@ -73,83 +45,29 @@
<% if has_ip6tables then %>
<ul class="cbi-tabmenu">
- <li class="cbi-tab<%= mode ~= 4 and "-disabled" %>"><a href="<%=url("admin/status/iptables/4")%>"><%:IPv4 Firewall%></a></li>
- <li class="cbi-tab<%= mode ~= 6 and "-disabled" %>"><a href="<%=url("admin/status/iptables/6")%>"><%:IPv6 Firewall%></a></li>
+ <li data-mode="4" class="cbi-tab<%= mode ~= 4 and "-disabled" %>">
+ <a href="<%=url("admin/status/iptables/4")%>"><%:IPv4 Firewall%></a>
+ </li>
+ <li data-mode="6" class="cbi-tab<%= mode ~= 6 and "-disabled" %>">
+ <a href="<%=url("admin/status/iptables/6")%>"><%:IPv6 Firewall%></a>
+ </li>
</ul>
<% end %>
-<div class="cbi-map" style="position: relative">
-
+<div style="position: relative">
<form method="post" action="<%=url("admin/status/iptables_action")%>" style="position: absolute; right: 0">
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="family" value="<%=mode%>" />
+ <input type="button" class="cbi-button" data-hide-empty="false" value="<%:Hide empty chains%>" onclick="hide_empty(this)" />
<input type="submit" class="cbi-button" name="zero" value="<%:Reset Counters%>" />
<input type="submit" class="cbi-button" name="restart" value="<%:Restart Firewall%>" />
</form>
+</div>
- <div class="cbi-section">
-
- <% for _, tbl in ipairs(tables) do chaincnt = 0 %>
- <h3><%:Table%>: <%=tbl%></h3>
-
- <% for _, chain in ipairs(ipt:chains(tbl)) do
- rowcnt = 0
- chaincnt = chaincnt + 1
- chaininfo = ipt:chain(tbl, chain)
- %>
- <h4 id="rule_<%=tbl:lower()%>_<%=chain%>">
- <%:Chain%> <em><%=chain%></em>
- (<%- if chaininfo.policy then -%>
- <%:Policy%>: <em><%=chaininfo.policy%></em>, <%:Packets%>: <%=chaininfo.packets%>, <%:Traffic%>: <%=wba.byte_format(chaininfo.bytes)-%>
- <%- else -%>
- <%:References%>: <%=chaininfo.references-%>
- <%- end -%>)
- </h4>
-
- <div class="cbi-section-node">
- <div class="table" style="font-size:90%">
- <div class="tr table-titles cbi-rowstyle-<%=rowstyle()%>">
- <div class="th hide-xs"><%:Pkts.%></div>
- <div class="th nowrap"><%:Traffic%></div>
- <div class="th col-5"><%:Target%></div>
- <div class="th"><%:Prot.%></div>
- <div class="th"><%:In%></div>
- <div class="th"><%:Out%></div>
- <div class="th"><%:Source%></div>
- <div class="th"><%:Destination%></div>
- <div class="th col-9 hide-xs"><%:Options%></div>
- </div>
-
- <% for _, rule in ipairs(ipt:find({table=tbl, chain=chain})) do %>
- <div class="tr cbi-rowstyle-<%=rowstyle()%>">
- <div class="td"><%=rule.packets%></div>
- <div class="td nowrap"><%=wba.byte_format(rule.bytes)%></div>
- <div class="td col-5"><%=rule.target and link_target(tbl, rule.target) or "-"%></div>
- <div class="td"><%=rule.protocol%></div>
- <div class="td"><%=link_iface(rule.inputif)%></div>
- <div class="td"><%=link_iface(rule.outputif)%></div>
- <div class="td"><%=rule.source%></div>
- <div class="td"><%=rule.destination%></div>
- <div class="td col-9 hide-xs"><%=#rule.options > 0 and luci.util.pcdata(table.concat(rule.options, " ")) or "-"%></div>
- </div>
- <% end %>
-
- <% if rowcnt == 1 then %>
- <div class="tr cbi-rowstyle-<%=rowstyle()%>">
- <div class="td" colspan="9"><em><%:No rules in this chain%></em></div>
- </div>
- <% end %>
- </div>
- </div>
- <% end %>
-
- <% if chaincnt == 0 then %>
- <em><%:No chains in this table%></em>
- <% end %>
-
- <br /><br />
- <% end %>
- </div>
+<div id="iptables">
+ <p><em class="spinning"><%:Collecting data...%></em></p>
</div>
+<script type="text/javascript" src="<%=resource%>/view/status/iptables.js"></script>
+
<%+footer%>
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/load.htm b/modules/luci-mod-status/luasrc/view/admin_status/load.htm
index bced06fa22..d31d340621 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/load.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/load.htm
@@ -1,5 +1,5 @@
<%#
- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
+ Copyright 2010-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
@@ -19,7 +19,7 @@
var step = 5;
var data_wanted = Math.floor(width / step);
- var data_fill = 0;
+ var data_fill = 1;
var data_stamp = 0;
var data_01 = [ ];
@@ -148,12 +148,15 @@
if (data[i][TIME] <= data_stamp)
continue;
+ data_fill++;
+
data_01.push(data[i][L01]);
data_05.push(data[i][L05]);
data_15.push(data[i][L15]);
}
/* cut off outdated entries */
+ data_fill = Math.min(data_fill, data_wanted);
data_01 = data_01.slice(data_01.length - data_wanted, data_01.length);
data_05 = data_05.slice(data_05.length - data_wanted, data_05.length);
data_15 = data_15.slice(data_15.length - data_wanted, data_15.length);
@@ -169,20 +172,15 @@
data_05_peak = Math.max(data_05_peak, data_05[i]);
data_15_peak = Math.max(data_15_peak, data_15[i]);
- if (i > 0)
- {
- data_01_avg = (data_01_avg + data_01[i]) / 2;
- data_05_avg = (data_05_avg + data_05[i]) / 2;
- data_15_avg = (data_15_avg + data_15[i]) / 2;
- }
- else
- {
- data_01_avg = data_01[i];
- data_05_avg = data_05[i];
- data_15_avg = data_15[i];
- }
+ data_01_avg += data_01[i];
+ data_05_avg += data_05[i];
+ data_15_avg += data_15[i];
}
+ data_01_avg = data_01_avg / data_fill;
+ data_05_avg = data_05_avg / data_fill;
+ data_15_avg = data_15_avg / data_fill;
+
/* remember current timestamp, calculate horizontal scale */
data_stamp = data[data.length-1][TIME];
data_scale = height / (data_max * 1.1);
diff --git a/modules/luci-mod-status/luasrc/view/admin_status/wireless.htm b/modules/luci-mod-status/luasrc/view/admin_status/wireless.htm
index 8ec43cb0e6..5ac2eb462d 100644
--- a/modules/luci-mod-status/luasrc/view/admin_status/wireless.htm
+++ b/modules/luci-mod-status/luasrc/view/admin_status/wireless.htm
@@ -1,5 +1,5 @@
<%#
- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
+ Copyright 2011-2018 Jo-Philipp Wich <jo@mein.io>
Licensed to the public under the Apache License 2.0.
-%>
@@ -33,7 +33,7 @@
var step = 5;
var data_wanted = Math.floor(width / step);
- var data_fill = 0;
+ var data_fill = 1;
var data_stamp = 0;
var data_rssi = [ ];
@@ -61,6 +61,7 @@
var label_rate_peak;
var label_scale;
+ var label_scale_2;
/* wait for SVG */
@@ -200,12 +201,15 @@
if (data[i][TIME] <= data_stamp)
continue;
+ data_fill++;
+
data_rssi.push(data[i][RSSI] - noise_floor);
data_noise.push(data[i][NOISE] - noise_floor);
data_rate.push(Math.floor(data[i][RATE] / 1000));
}
/* cut off outdated entries */
+ data_fill = Math.min(data_fill, data_wanted);
data_rssi = data_rssi.slice(data_rssi.length - data_wanted, data_rssi.length);
data_noise = data_noise.slice(data_noise.length - data_wanted, data_noise.length);
data_rate = data_rate.slice(data_rate.length - data_wanted, data_rate.length);
@@ -220,20 +224,15 @@
data_noise_peak = Math.max(data_noise_peak, data_noise[i]);
data_rate_peak = Math.max(data_rate_peak, data_rate[i]);
- if (i > 0)
- {
- data_rssi_avg = (data_rssi_avg + data_rssi[i]) / 2;
- data_noise_avg = (data_noise_avg + data_noise[i]) / 2;
- data_rate_avg = (data_rate_avg + data_rate[i]) / 2;
- }
- else
- {
- data_rssi_avg = data_rssi[i];
- data_noise_avg = data_noise[i];
- data_rate_avg = data_rate[i];
- }
+ data_rssi_avg += data_rssi[i];
+ data_noise_avg += data_noise[i];
+ data_rate_avg += data_rate[i];
}
+ data_rssi_avg = data_rssi_avg / data_fill;
+ data_noise_avg = data_noise_avg / data_fill;
+ data_rate_avg = data_rate_avg / data_fill;
+
/* remember current timestamp, calculate horizontal scale */
data_stamp = data[data.length-1][TIME];
data_scale = (height / (data_max * 1.1)).toFixed(1);