mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Implements per-host per-l7protocol throughput statistics
Example endpoint to retrieve results is: http://localhost:3000/lua/host_get_json.lua?ifname=0&host=192.168.2.130&host_stats_flows=1
This commit is contained in:
parent
b0a806453b
commit
ea0e3d7f85
1 changed files with 29 additions and 0 deletions
|
|
@ -26,6 +26,33 @@ if(host_info["host"] == nil) then
|
|||
return
|
||||
end
|
||||
|
||||
function flows2protocolthpt(flows)
|
||||
local protocol_thpt = {}
|
||||
for _, flow in pairs(flows) do
|
||||
local proto_ndpi = ""
|
||||
if flow["proto.ndpi"] == nil or flow["proto.ndpi"] == "" then
|
||||
goto continue
|
||||
else
|
||||
proto_ndpi = flow["proto.ndpi"]
|
||||
end
|
||||
|
||||
if protocol_thpt[proto_ndpi] == nil then
|
||||
protocol_thpt[proto_ndpi] =
|
||||
{["cli2srv"]={["throughput_bps"]=0, ["throughput_pps"]=0},
|
||||
["srv2cli"]={["throughput_bps"]=0, ["throughput_pps"]=0}}
|
||||
end
|
||||
|
||||
for _, dir in pairs({"cli2srv", "srv2cli"}) do
|
||||
for _, dim in pairs({"bps", "pps"}) do
|
||||
protocol_thpt[proto_ndpi][dir]["throughput_"..dim] =
|
||||
protocol_thpt[proto_ndpi][dir]["throughput_"..dim] + flow[dir..".throughput_"..dim]
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
return protocol_thpt
|
||||
end
|
||||
|
||||
interface.select(ifname)
|
||||
host = interface.getHostInfo(host_info["host"], host_info["vlan"])
|
||||
|
||||
|
|
@ -69,8 +96,10 @@ else
|
|||
["srv2cli.throughput_pps"] = round(fl["throughput_srv2cli_pps"], 2)
|
||||
}
|
||||
end
|
||||
hj["ndpiThroughputStats"] = flows2protocolthpt(flows)
|
||||
hj["flows"] = flows
|
||||
hj["flows_count"] = total
|
||||
end
|
||||
print(json.encode(hj, nil))
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue