mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 10:41:34 +00:00
Implements ability to consolidate widgets (slices and values)
This commit is contained in:
parent
3c6674e32d
commit
727a5d56fc
11 changed files with 178 additions and 179 deletions
50
attic/scripts/lua/datasources/iface_tcpflags_pkt_distro.lua
Normal file
50
attic/scripts/lua/datasources/iface_tcpflags_pkt_distro.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
--
|
||||
-- (C) 2020 - ntop.org
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require("lua_utils")
|
||||
local datasources_utils = require("datasources_utils")
|
||||
local datamodel = require("datamodel")
|
||||
|
||||
local pkt_distribution = {
|
||||
['syn'] = 'SYN',
|
||||
['synack'] = 'SYN/ACK',
|
||||
['finack'] = 'FIN/ACK',
|
||||
['rst'] = 'RST',
|
||||
}
|
||||
|
||||
local function reportError(msg)
|
||||
print(json.encode({ error = msg, success = false, csrf = ntop.getRandomCSRFValue() }))
|
||||
end
|
||||
|
||||
local ifid = _GET["ifid"] or 0
|
||||
local if_name = getInterfaceName(ifid)
|
||||
|
||||
interface.select(ifname)
|
||||
local ifstats = interface.getStats()
|
||||
local labels = {}
|
||||
local slices = {}
|
||||
|
||||
local res = {}
|
||||
for key, value in pairs(ifstats["pktSizeDistribution"]["tcp_flags"]) do
|
||||
if value > 0 then
|
||||
table.insert(labels, pkt_distribution[key])
|
||||
table.insert(slices, value)
|
||||
end
|
||||
end
|
||||
|
||||
if(table.len(res) == 0) then
|
||||
table.insert(labels, "Other")
|
||||
table.insert(slices, 100)
|
||||
end
|
||||
|
||||
-- Prepare the results
|
||||
local m = datamodel:new(labels)
|
||||
local dataset = ifname.." TCP Flags"
|
||||
|
||||
m:appendRow(when, dataset, slices)
|
||||
|
||||
return(m)
|
||||
Loading…
Add table
Add a link
Reference in a new issue