mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Added ifid to rest/get/interface/data.lua
This commit is contained in:
parent
0d9833dbf7
commit
a76059bb11
2 changed files with 8 additions and 7 deletions
|
|
@ -46,8 +46,8 @@ local function countHosts()
|
|||
return res
|
||||
end
|
||||
|
||||
function dumpInterfaceStats(interface_name)
|
||||
local ifid = getInterfaceId(interface_name)
|
||||
function dumpInterfaceStats(ifid)
|
||||
local interface_name = getInterfaceName(ifid)
|
||||
interface.select(ifid..'')
|
||||
|
||||
local ifstats = interface.getStats()
|
||||
|
|
@ -62,6 +62,7 @@ function dumpInterfaceStats(interface_name)
|
|||
local flows_pctg = math.floor(1+((ifstats.stats.flows*100)/prefs.max_num_flows))
|
||||
local macs_pctg = math.floor(1+((ifstats.stats.current_macs*100)/prefs.max_num_hosts))
|
||||
|
||||
res["ifid"] = ifid
|
||||
res["ifname"] = interface_name
|
||||
res["speed"] = getInterfaceSpeed(ifstats.id)
|
||||
-- network load is used by web pages that are shown to the user
|
||||
|
|
@ -183,16 +184,16 @@ if(_GET["iffilter"] == "all") then
|
|||
local ifid = getInterfaceId(ifname)
|
||||
-- ifid in the key must be a string or json.encode will think
|
||||
-- its a lua array and will look for integers starting at one
|
||||
res[ifid..""] = dumpInterfaceStats(ifname)
|
||||
res[ifid..""] = dumpInterfaceStats(ifid)
|
||||
end
|
||||
elseif not isEmptyString(_GET["iffilter"]) then
|
||||
res = dumpInterfaceStats(_GET["iffilter"])
|
||||
else
|
||||
local ifname = nil
|
||||
local ifid = nil
|
||||
if not isEmptyString(_GET["ifid"]) then
|
||||
ifname = getInterfaceName(_GET["ifid"])
|
||||
ifid = getInterfaceName(_GET["ifid"])
|
||||
end
|
||||
res = dumpInterfaceStats(ifname)
|
||||
res = dumpInterfaceStats(ifid)
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue