summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-mwan3/luasrc/controller/mwan3.lua
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2018-01-16 16:09:33 +0100
committerFlorian Eckert <fe@dev.tdt.de>2018-01-18 15:09:17 +0100
commit8371e40dbf5d4dbed6f4d64fde04865b76b4df8d (patch)
treec7d1b2efb6af98cd4d6e8ba3cf6cb8c3f1301af5 /applications/luci-app-mwan3/luasrc/controller/mwan3.lua
parent119730448df2776fbd8575f3a91dcc60f68780e0 (diff)
luci-app-mwan3: remove diagnostics service section
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-mwan3/luasrc/controller/mwan3.lua')
-rw-r--r--applications/luci-app-mwan3/luasrc/controller/mwan3.lua105
1 files changed, 47 insertions, 58 deletions
diff --git a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua
index 62e888c921..5d4ddfbdaf 100644
--- a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua
+++ b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua
@@ -96,69 +96,58 @@ function diagnosticsData(interface, tool, task)
local mArray = {}
local results = ""
- if tool == "service" then
- os.execute("/usr/sbin/mwan3 " .. task)
- if task == "restart" then
- results = "MWAN3 restarted"
- elseif task == "stop" then
- results = "MWAN3 stopped"
- else
- results = "MWAN3 started"
- end
- else
- local interfaceDevice = ut.trim(sys.exec("uci -q -p /var/state get network." .. interface .. ".ifname"))
- if interfaceDevice ~= "" then
- if tool == "ping" then
- local gateway = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2}'"))
- if gateway ~= "" then
- if task == "gateway" then
- local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
- results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
- else
- local tracked = ut.trim(sys.exec("uci -q -p /var/state get mwan3." .. interface .. ".track_ip"))
- if tracked ~= "" then
- for z in tracked:gmatch("[^ ]+") do
- local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
- results = results .. pingCommand .. "\n\n" .. sys.exec(pingCommand) .. "\n\n"
- end
- else
- results = "No tracking IP addresses configured on " .. interface
+ local interfaceDevice = ut.trim(sys.exec("uci -q -p /var/state get network." .. interface .. ".ifname"))
+ if interfaceDevice ~= "" then
+ if tool == "ping" then
+ local gateway = ut.trim(sys.exec("route -n | awk '{if ($8 == \"" .. interfaceDevice .. "\" && $1 == \"0.0.0.0\" && $3 == \"0.0.0.0\") print $2}'"))
+ if gateway ~= "" then
+ if task == "gateway" then
+ local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. gateway
+ results = pingCommand .. "\n\n" .. sys.exec(pingCommand)
+ else
+ local tracked = ut.trim(sys.exec("uci -q -p /var/state get mwan3." .. interface .. ".track_ip"))
+ if tracked ~= "" then
+ for z in tracked:gmatch("[^ ]+") do
+ local pingCommand = "ping -c 3 -W 2 -I " .. interfaceDevice .. " " .. z
+ results = results .. pingCommand .. "\n\n" .. sys.exec(pingCommand) .. "\n\n"
end
+ else
+ results = "No tracking IP addresses configured on " .. interface
end
- else
- results = "No default gateway for " .. interface .. " found. Default route does not exist or is configured incorrectly"
- end
- elseif tool == "rulechk" then
- getInterfaceNumber()
- local rule1 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 1000)))")
- local rule2 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 2000)))")
- if rule1 ~= "" and rule2 ~= "" then
- results = "All required interface IP rules found:\n\n" .. rule1 .. rule2
- elseif rule1 ~= "" or rule2 ~= "" then
- results = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
- else
- results = "Missing both of the required interface IP rules"
- end
- elseif tool == "routechk" then
- getInterfaceNumber()
- local routeTable = sys.exec(ip .. "route list table " .. interfaceNumber)
- if routeTable ~= "" then
- results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable
- else
- results = "Missing required interface routing table " .. interfaceNumber
- end
- elseif tool == "hotplug" then
- if task == "ifup" then
- os.execute("/usr/sbin/mwan3 ifup " .. interface)
- results = "Hotplug ifup sent to interface " .. interface .. "..."
- else
- os.execute("/usr/sbin/mwan3 ifdown " .. interface)
- results = "Hotplug ifdown sent to interface " .. interface .. "..."
end
+ else
+ results = "No default gateway for " .. interface .. " found. Default route does not exist or is configured incorrectly"
+ end
+ elseif tool == "rulechk" then
+ getInterfaceNumber()
+ local rule1 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 1000)))")
+ local rule2 = sys.exec(ip .. "rule | grep $(echo $((" .. interfaceNumber .. " + 2000)))")
+ if rule1 ~= "" and rule2 ~= "" then
+ results = "All required interface IP rules found:\n\n" .. rule1 .. rule2
+ elseif rule1 ~= "" or rule2 ~= "" then
+ results = "Missing 1 of the 2 required interface IP rules\n\n\nRules found:\n\n" .. rule1 .. rule2
+ else
+ results = "Missing both of the required interface IP rules"
+ end
+ elseif tool == "routechk" then
+ getInterfaceNumber()
+ local routeTable = sys.exec(ip .. "route list table " .. interfaceNumber)
+ if routeTable ~= "" then
+ results = "Interface routing table " .. interfaceNumber .. " was found:\n\n" .. routeTable
+ else
+ results = "Missing required interface routing table " .. interfaceNumber
+ end
+ elseif tool == "hotplug" then
+ if task == "ifup" then
+ os.execute("/usr/sbin/mwan3 ifup " .. interface)
+ results = "Hotplug ifup sent to interface " .. interface .. "..."
+ else
+ os.execute("/usr/sbin/mwan3 ifdown " .. interface)
+ results = "Hotplug ifdown sent to interface " .. interface .. "..."
end
- else
- results = "Unable to perform diagnostic tests on " .. interface .. ". There is no physical or virtual device associated with this interface"
end
+ else
+ results = "Unable to perform diagnostic tests on " .. interface .. ". There is no physical or virtual device associated with this interface"
end
if results ~= "" then
results = ut.trim(results)