m5 = Map("mwan3", translate("MWAN - Interfaces"),
interfaceWarnings(configCheck()))
- m5:append(Template("mwan/config_css"))
mwan_interface = m5:section(TypedSection, "interface", nil,
end
end
-track_ip = mwan_interface:option(DummyValue, "track_ip", translate("Tracking IP"))
- track_ip.rawhtml = true
- function track_ip.cfgvalue(self, s)
- tracked = self.map:get(s, "track_ip")
- if tracked then
- local ipList = ""
- for k,v in pairs(tracked) do
- ipList = ipList .. v .. "<br />"
- end
- return ipList
- else
- return "—"
- end
- end
-
track_method = mwan_interface:option(DummyValue, "track_method", translate("Tracking method"))
track_method.rawhtml = true
function track_method.cfgvalue(self, s)
+ local tracked = self.map:get(s, "track_ip")
if tracked then
return self.map:get(s, "track_method") or "—"
else
reliability = mwan_interface:option(DummyValue, "reliability", translate("Tracking reliability"))
reliability.rawhtml = true
function reliability.cfgvalue(self, s)
+ local tracked = self.map:get(s, "track_ip")
if tracked then
return self.map:get(s, "reliability") or "—"
else
end
end
-count = mwan_interface:option(DummyValue, "count", translate("Ping count"))
- count.rawhtml = true
- function count.cfgvalue(self, s)
- if tracked then
- return self.map:get(s, "count") or "—"
- else
- return "—"
- end
- end
-
-timeout = mwan_interface:option(DummyValue, "timeout", translate("Ping timeout"))
- timeout.rawhtml = true
- function timeout.cfgvalue(self, s)
- if tracked then
- local timeoutValue = self.map:get(s, "timeout")
- if timeoutValue then
- return timeoutValue .. "s"
- else
- return "—"
- end
- else
- return "—"
- end
- end
-
interval = mwan_interface:option(DummyValue, "interval", translate("Ping interval"))
interval.rawhtml = true
function interval.cfgvalue(self, s)
+ local tracked = self.map:get(s, "track_ip")
if tracked then
local intervalValue = self.map:get(s, "interval")
if intervalValue then
down = mwan_interface:option(DummyValue, "down", translate("Interface down"))
down.rawhtml = true
function down.cfgvalue(self, s)
+ local tracked = self.map:get(s, "track_ip")
if tracked then
return self.map:get(s, "down") or "—"
else
up = mwan_interface:option(DummyValue, "up", translate("Interface up"))
up.rawhtml = true
function up.cfgvalue(self, s)
+ local tracked = self.map:get(s, "track_ip")
if tracked then
return self.map:get(s, "up") or "—"
else
metric = mwan_interface:option(DummyValue, "metric", translate("Metric"))
metric.rawhtml = true
function metric.cfgvalue(self, s)
- local metricValue = sys.exec("uci -p /var/state get network." .. s .. ".metric")
- if metricValue ~= "" then
- return metricValue
+ local uci = uci.cursor(nil, "/var/state")
+ local metric = uci:get("network", s, "metric")
+ if metric then
+ return metric
else
return "—"
end