OpenWrt Forum Archive

Topic: mwan3-luci interface broken. Need help debugging.

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

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 }
arfett wrote:

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.

Fixed this by replacing ip to /usr/bin/ip in mwan3.lua and /usr/sbin/ip to /usr/bin/ip in mwan3 hotplug scripts
seems like it happens cuz of busybox's ip used instead of separate ip binary

(Last edited by stas2z on 16 Oct 2015, 19:38)

stas2z wrote:
arfett wrote:

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.

Fixed this by replacing ip to /usr/bin/ip in mwan3.lua and /usr/sbin/ip to /usr/bin/ip in mwan3 hotplug scripts
seems like it happens cuz of busybox's ip used instead of separate ip binary

We already knew about the mwan3 scripts but it seems strange it would need to be changed here. The system should know where it's located since I don't hardcode a location anywhere. Oh well at least I know what to fix now. Thanks.

The discussion might have continued from here.