mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Reworks top-talkers to greatly improve speed
This commit is contained in:
parent
a51706ca98
commit
4a9c17c8dd
4 changed files with 226 additions and 35 deletions
|
|
@ -98,6 +98,11 @@ function callback_utils.getLocalHostsIterator(...)
|
|||
return getBatchedIterator(interface.getBatchedLocalHostsInfo, "hosts", { ... })
|
||||
end
|
||||
|
||||
-- A batched iterator over the hosts (both local and remote)
|
||||
function callback_utils.getHostsIterator(...)
|
||||
return getBatchedIterator(interface.getBatchedHostsInfo, "hosts", { ... })
|
||||
end
|
||||
|
||||
-- A batched iterator over the l2 devices
|
||||
function callback_utils.getDevicesIterator(...)
|
||||
return getBatchedIterator(interface.getBatchedMacsInfo, "macs", { ... })
|
||||
|
|
@ -141,6 +146,31 @@ function callback_utils.foreachLocalHost(ifname, deadline, callback)
|
|||
return true
|
||||
end
|
||||
|
||||
-- ########################################################
|
||||
|
||||
-- Iterates each active host on the ifname interface.
|
||||
-- Each host is passed to the callback with some more information.
|
||||
function callback_utils.foreachHost(ifname, deadline, callback)
|
||||
local hostbase
|
||||
|
||||
interface.select(ifname)
|
||||
|
||||
local iterator = callback_utils.getHostsIterator(false --[[ no details ]])
|
||||
|
||||
for hostname, hoststats in iterator do
|
||||
if ((deadline ~= nil) and (os.time() >= deadline)) then
|
||||
-- Out of time
|
||||
return false
|
||||
end
|
||||
|
||||
if callback(hostname, hoststats) == false then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- Iterates each device on the ifname interface.
|
||||
-- Each device is passed to the callback with some more information.
|
||||
function callback_utils.foreachDevice(ifname, deadline, callback)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue