summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-mwan3/luasrc
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2018-12-29 14:05:26 +0200
committerGitHub <noreply@github.com>2018-12-29 14:05:26 +0200
commit8cecff2197ab148bdf6dcec1594b7c54b0f95fb5 (patch)
treeda82f31410e95c8b9603d869e4002e3d665dbcc8 /applications/luci-app-mwan3/luasrc
parent1d3a8739a29c15f2274a8ec7043ef5cb2274ff97 (diff)
parentb5bf69d2b29ff99f444b16db103f4344a5f96934 (diff)
Merge pull request #2387 from TDT-AG/pr/20181220-luci-app-mwan3
luci-app-mwan3: some changes
Diffstat (limited to 'applications/luci-app-mwan3/luasrc')
-rw-r--r--applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua16
-rw-r--r--applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm26
2 files changed, 39 insertions, 3 deletions
diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua
index ed9d94ac7e..4c970d4fa1 100644
--- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua
+++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interfaceconfig.lua
@@ -34,8 +34,20 @@ track_ip.datatype = "host"
track_method = mwan_interface:option(ListValue, "track_method", translate("Tracking method"))
track_method.default = "ping"
track_method:value("ping")
-track_method:value("arping")
-track_method:value("httping")
+if os.execute("which nping 1>/dev/null") == 0 then
+ track_method:value("nping-tcp")
+ track_method:value("nping-udp")
+ track_method:value("nping-icmp")
+ track_method:value("nping-arp")
+end
+
+if os.execute("which arping 1>/dev/null") == 0 then
+ track_method:value("arping")
+end
+
+if os.execute("which httping 1>/dev/null") == 0 then
+ track_method:value("httping")
+end
reliability = mwan_interface:option(Value, "reliability", translate("Tracking reliability"),
translate("Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up"))
diff --git a/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm b/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm
index 259f3c975b..2e7b490f4f 100644
--- a/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm
+++ b/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm
@@ -5,6 +5,17 @@
-%>
<script type="text/javascript">//<![CDATA[
+
+function secondsToString(time) {
+ var seconds = parseInt(time, 10);
+
+ var hrs = Math.floor(seconds / 3600);
+ seconds -= hrs*3600;
+ var mnts = Math.floor(seconds / 60);
+ seconds -= mnts*60;
+ return String.format("%sh:%sm:%ss", hrs, mnts, seconds);
+}
+
XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_status")%>', null,
function(x, status)
{
@@ -15,15 +26,24 @@ XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface
for ( var iface in status.interfaces)
{
var state = '';
- var css = ''
+ var css = '';
+ var time = '';
switch (status.interfaces[iface].status)
{
case 'online':
state = '<%:Online%>';
+ time = String.format(
+ '<div><strong>Uptime: </strong>%s</div>',
+ secondsToString(status.interfaces[iface].uptime)
+ );
css = 'success';
break;
case 'offline':
state = '<%:Offline%>';
+ time = String.format(
+ '<div><strong>Downtime: </strong>%s</div>',
+ secondsToString(status.interfaces[iface].downtime)
+ );
css = 'danger';
break;
default:
@@ -43,6 +63,10 @@ XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface
'<div><strong>Status: </strong>%s</div>',
state
);
+ if (time)
+ {
+ statusview += time;
+ }
statusview += '</div>'
}
statusDiv.innerHTML = statusview;