https://github.com/openwrt/packages/tre … b/lua/luci
What it comes down do is the Lua script is running the commands via sys.exec and seeing an empty string and returning "offline" or "No data found". Running these commands manually in the terminal work as expected and return the data I'm looking for.
These 3 code blocks are from /usr/lib/lua/luci/controller/mwan3.lua
function getInterfaceStatus(ruleNumber, interfaceName)
if ut.trim(sys.exec("uci -p /var/state get mwan3." .. interfaceName .. ".enabled")) == "1" then
if ut.trim(sys.exec("ip route list table " .. ruleNumber)) ~= "" then
if ut.trim(sys.exec("uci -p /var/state get mwan3." .. interfaceName .. ".track_ip")) ~= "" then
return "online"
else
return "notMonitored"
end
else
return "offline"
end
else
return "notEnabled"
end
end
-- ip rule show
local ipRuleShow = ut.trim(sys.exec("ip rule show"))
if ipRuleShow == "" then
ipRuleShow = "No data found"
end
mArray.iprule = { ipRuleShow }
-- ip route list table 1-250
local routeList, routeString = ut.trim(sys.exec("ip rule | sed 's/://g' | awk '$1>=2001 && $1<=2250' | awk '{print $NF}'")), ""
if routeList ~= "" then
for line in routeList:gmatch("[^\r\n]+") do
routeString = routeString .. line .. "\n" .. sys.exec("ip route list table " .. line)
end
routeString = ut.trim(routeString)
else
routeString = "No data found"
end
mArray.routelist = { routeString }