mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-02 00:40:10 +00:00
Widgets update
This commit is contained in:
parent
ed64370093
commit
1c76667b21
7 changed files with 244 additions and 42 deletions
71
scripts/lua/datasources/iface_pkt_distro.lua
Normal file
71
scripts/lua/datasources/iface_pkt_distro.lua
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
--
|
||||
-- (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_utils")
|
||||
|
||||
local function reportError(msg)
|
||||
print(json.encode({ error = msg, success = false, csrf = ntop.getRandomCSRFValue() }))
|
||||
end
|
||||
|
||||
local pkt_distribution = {
|
||||
['upTo64'] = '<= 64',
|
||||
['upTo128'] = '64 <= 128',
|
||||
['upTo256'] = '128 <= 256',
|
||||
['upTo512'] = '256 <= 512',
|
||||
['upTo1024'] = '512 <= 1024',
|
||||
['upTo1518'] = '1024 <= 1518',
|
||||
['upTo2500'] = '1518 <= 2500',
|
||||
['upTo6500'] = '2500 <= 6500',
|
||||
['upTo9000'] = '6500 <= 9000',
|
||||
['above9000'] = '> 9000'
|
||||
}
|
||||
|
||||
local ifid = _GET["ifid"] or 0
|
||||
local ifname = getInterfaceName(ifid)
|
||||
local chart_type = _GET["chart_type"] or "size"
|
||||
|
||||
interface.select(ifname)
|
||||
local ifstats = interface.getStats()
|
||||
|
||||
what = ifstats["pktSizeDistribution"]["size"]
|
||||
|
||||
local tot = 0
|
||||
for key, value in pairs(what) do
|
||||
tot = tot + value
|
||||
end
|
||||
|
||||
local threshold = (tot * 5) / 100
|
||||
local sum = 0
|
||||
|
||||
local labels = {}
|
||||
local slices = {}
|
||||
|
||||
for key, value in pairs(what) do
|
||||
if(value > threshold) then
|
||||
if(pkt_distribution[key] ~= nil) then
|
||||
table.insert(labels, pkt_distribution[key])
|
||||
table.insert(slices, value)
|
||||
sum = sum + value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if(sum < tot) then
|
||||
table.insert(labels, "Other")
|
||||
table.insert(slices, tot-sum)
|
||||
end
|
||||
|
||||
-- Prepare the results
|
||||
|
||||
local m = datamodel:create(labels)
|
||||
local dataset = ifname.." Packet Distribution"
|
||||
|
||||
m:appendRow(when, dataset, slices)
|
||||
|
||||
return(m)
|
||||
26
scripts/lua/datasources/iface_pkt_version.lua
Normal file
26
scripts/lua/datasources/iface_pkt_version.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
--
|
||||
-- (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_utils")
|
||||
|
||||
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)
|
||||
local chart_type = _GET["chart_type"] or "size"
|
||||
|
||||
interface.select(ifname)
|
||||
local ifstats = interface.getStats()
|
||||
local m = nil
|
||||
|
||||
local m = datamodel:create({"IPv4", "IPv6"})
|
||||
m:appendRow(when, "IP Version Distribution", { ifstats.eth.IPv4_packets, ifstats.eth.IPv6_packets })
|
||||
return(m)
|
||||
50
scripts/lua/datasources/iface_tcpflags_pkt_distro.lua
Normal file
50
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_utils")
|
||||
|
||||
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:create(labels)
|
||||
local dataset = ifname.." TCP Flags"
|
||||
|
||||
m:appendRow(when, dataset, slices)
|
||||
|
||||
return(m)
|
||||
Loading…
Add table
Add a link
Reference in a new issue