-- -- (C) 2013-23 - ntop.org -- local clock_start = os.clock() require "lua_utils" 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") 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 = {} local throughput_type = getThroughputType() record["key"] = tostring(network["network_id"]) local network_link = ""..getFullLocalNetworkName(network["network_key"])..'' 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") local sent2rcvd = round((network["bytes.sent"] * 100) / (network["bytes.sent"] + network["bytes.rcvd"]), 0) record["column_breakdown"] = "