mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-04 09:50:09 +00:00
Removed useless imports in lua code upping the memory usage
This commit is contained in:
parent
2f76c9bf4b
commit
dbf4bf2a2b
53 changed files with 2981 additions and 3255 deletions
|
|
@ -4,13 +4,16 @@
|
|||
|
||||
local clock_start = os.clock()
|
||||
|
||||
require "lua_utils"
|
||||
require "label_utils"
|
||||
require "check_redis_prefs"
|
||||
local format_utils = require "format_utils"
|
||||
|
||||
local network_utils = {}
|
||||
|
||||
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")
|
||||
|
|
@ -19,7 +22,18 @@ local function getThroughputType()
|
|||
return throughput_type
|
||||
end
|
||||
|
||||
-- network_utils.throughput_type = getThroughputType()
|
||||
-- ##############################################
|
||||
|
||||
function network_utils.splitNetworkPrefix(net)
|
||||
if not net then
|
||||
tprint(debug.traceback())
|
||||
end
|
||||
local prefix = tonumber(net:match("/(.+)"))
|
||||
local address = net:gsub("/.+","")
|
||||
return address, prefix
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function network_utils.network2record(ifId, network)
|
||||
local record = {}
|
||||
|
|
@ -32,22 +46,22 @@ function network_utils.network2record(ifId, network)
|
|||
network["host_score_ratio"] = ternary(network["num_hosts"] and network["num_hosts"]>0, math.floor((network["score"] or 0) / (network["num_hosts"] or 0)) , '')
|
||||
|
||||
record["column_id"] = network_link
|
||||
record["column_score"] = format_high_num_value_for_tables(network, "score")
|
||||
record["column_hosts"] = format_high_num_value_for_tables(network, "num_hosts")
|
||||
record["column_alerted_flows"] = format_high_num_value_for_tables(network["alerted_flows"], "total")
|
||||
record["column_host_score_ratio"] = format_high_num_value_for_tables(network, "host_score_ratio")
|
||||
record["column_score"] = format_utils.format_high_num_value_for_tables(network, "score")
|
||||
record["column_hosts"] = format_utils.format_high_num_value_for_tables(network, "num_hosts")
|
||||
record["column_alerted_flows"] = format_utils.format_high_num_value_for_tables(network["alerted_flows"], "total")
|
||||
record["column_host_score_ratio"] = format_utils.format_high_num_value_for_tables(network, "host_score_ratio")
|
||||
|
||||
local sent2rcvd = round((network["bytes.sent"] * 100) / (network["bytes.sent"] + network["bytes.rcvd"]), 0)
|
||||
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
|
||||
record["column_thpt"] = pktsToSize(network["throughput_pps"])
|
||||
record["column_thpt"] = format_utils.pktsToSize(network["throughput_pps"])
|
||||
else
|
||||
record["column_thpt"] = bitsToSize(8*network["throughput_bps"])
|
||||
record["column_thpt"] = format_utils.bitsToSize(8*network["throughput_bps"])
|
||||
end
|
||||
|
||||
record["column_traffic"] = bytesToSize(network["bytes.sent"] + network["bytes.rcvd"])
|
||||
record["column_traffic"] = format_utils.bytesToSize(network["bytes.sent"] + network["bytes.rcvd"])
|
||||
|
||||
if not areInterfaceTimeseriesEnabled(ifId) then
|
||||
record["column_chart"] = ""
|
||||
|
|
@ -58,8 +72,4 @@ function network_utils.network2record(ifId, network)
|
|||
return record
|
||||
end
|
||||
|
||||
if(trace_script_duration ~= nil) then
|
||||
io.write(debug.getinfo(1,'S').source .." executed in ".. (os.clock()-clock_start)*1000 .. " ms\n")
|
||||
end
|
||||
|
||||
return network_utils
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue