") end -- run program to band width usage update binary to update DB util.appendDebugOut("Exec = " .. os.execute("/pfrm2.0/bin/fwBwMon /tmp/system.db update")) stats = db.getRow("SystemStatistics","_ROWID_","1") or {} lanInterface=db.getRow("interfaceStats","interfaceName","bdg1") or {} --[[ If connection type is not Dhcp or ifstatic then get row from ppp1 interface for WAN1 --]] -- Check for connection type for WAN1 local logIfName = "WAN1" local connectionType = "" local wanInterface = nil local connectionTypeRow = db.getRowWhere("NimfConf", "LogicalIfName = '".. logIfName .."' and AddressFamily = 2") if(connectionTypeRow ~= nil) then connectionType = connectionTypeRow["NimfConf.ConnectionType"] end if(connectionType ~= "dhcpc" and connectionType ~= "ifStatic")then wanInterface = db.getRow ("interfaceStats","interfaceName","ppp1") or {} else wanInterface = db.getRow ("interfaceStats", "interfaceName", "eth1") or {} end local portConfig = db.getRow("ConfigPort", "_ROWID_", "1") local dmzInterface = nil --[[ If connection type is not Dhcp or ifstatic then get row from ppp2 interface for WAN2 --]] -- Check for connection type for WAN2 if(portConfig["ConfigPort.LogicalIfName"] == "WAN2") then connectionTypeRow = db.getRowWhere("NimfConf", "LogicalIfName = '".. portConfig["ConfigPort.LogicalIfName"] .."' and AddressFamily = 2") if(connectionTypeRow ~= nil) then connectionType = connectionTypeRow["NimfConf.ConnectionType"] end if(connectionType ~= "dhcpc" and connectionType ~= "ifStatic")then dmzInterface = db.getRow ("interfaceStats", "interfaceName", "ppp2") or {} else dmzInterface = db.getRow ("interfaceStats", "interfaceName", "eth2") or {} end else dmzInterface = db.getRow ("interfaceStats", "interfaceName", "eth2") or {} end -- Getting Bandwidth Counters. local appNames = db.getDistinctValues("BwMonStat", "AppName") local bwCounters = {} local usedAppsCounter = {} local idx = 1 for k,v in pairs (appNames) do local counterSum = nil bwCounters[idx] = {} usedAppsCounter[idx] = {} bwCounters[idx]["BwMonStat.AppName"] = v["BwMonStat.AppName"] or '' usedAppsCounter[idx]["BwMonStat.AppName"] = v["BwMonStat.AppName"] or '' if (intName1 == "ALL") then counterSum = db.getTable("BwMonStat", false, "SELECT sum(Counter) Counter FROM BwMonStat where AppName='" .. v["BwMonStat.AppName"] .. "'") else counterSum = db.getTable("BwMonStat", false, "SELECT sum(Counter) Counter FROM BwMonStat where LogicalIfName='" .. intName1 .. "' and AppName='" .. v["BwMonStat.AppName"] .. "'") end if (counterSum ~= nil and #counterSum == 1) then bwCounters[idx]["BwMonStat.Counter"] = counterSum[1]["Counter"] or '0' else bwCounters[idx]["BwMonStat.Counter"] = '0' end if (intName2 == "ALL") then counterSum = db.getTable("BwMonStat", false, "SELECT sum(Counter) Counter FROM BwMonStat where AppName='" .. v["BwMonStat.AppName"] .. "'") else counterSum = db.getTable("BwMonStat", false, "SELECT sum(Counter) Counter FROM BwMonStat where LogicalIfName='" .. intName2 .. "' and AppName='" .. v["BwMonStat.AppName"] .. "'") end if (counterSum ~= nil and #counterSum == 1) then usedAppsCounter[idx]["BwMonStat.Counter"] = counterSum[1]["Counter"] or '0' else usedAppsCounter[idx]["BwMonStat.Counter"] = '0' end idx = idx + 1 end ?>