mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Fix flow alerts with undefined pool/network. Cleanup code.
This commit is contained in:
parent
9f2724d91a
commit
98e077a7f8
5 changed files with 29 additions and 18 deletions
|
|
@ -5,10 +5,20 @@
|
|||
require "lua_utils"
|
||||
local format_utils = require "format_utils"
|
||||
|
||||
-- Get from redis the throughput type bps or pps
|
||||
local throughput_type = getThroughputType()
|
||||
local network_utils = {}
|
||||
|
||||
function network2record(ifId, network)
|
||||
network_utils.UNKNOWN_NETWORK = 65535 -- uint16 (-1)
|
||||
|
||||
-- Get from redis the throughput type bps or pps
|
||||
local function getThroughputType()
|
||||
local throughput_type = ntop.getCache("ntopng.prefs.thpt_content")
|
||||
if throughput_type == "" then throughput_type = "bps" end
|
||||
return throughput_type
|
||||
end
|
||||
|
||||
network_utils.throughput_type = getThroughputType()
|
||||
|
||||
function network_utils.network2record(ifId, network)
|
||||
local record = {}
|
||||
record["key"] = tostring(network["network_id"])
|
||||
|
||||
|
|
@ -21,7 +31,7 @@ function network2record(ifId, network)
|
|||
record["column_breakdown"] = "<div class='progress'><div class='progress-bar bg-warning' style='width: "
|
||||
.. sent2rcvd .."%;'>Sent</div><div class='progress-bar bg-success' style='width: " .. (100-sent2rcvd) .. "%;'>Rcvd</div></div>"
|
||||
|
||||
if(throughput_type == "pps") then
|
||||
if(network_utils.throughput_type == "pps") then
|
||||
record["column_thpt"] = pktsToSize(network["throughput_pps"])
|
||||
else
|
||||
record["column_thpt"] = bitsToSize(8*network["throughput_bps"])
|
||||
|
|
@ -38,3 +48,4 @@ function network2record(ifId, network)
|
|||
return record
|
||||
end
|
||||
|
||||
return network_utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue