mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Addresses #3720 Refactor: create module graph_utils Refactor: get_timeseries_layout Refactor: get_default_timeseries Refactor: getDeviceCommonTimeseries Refactor: printCategoryDropdownButton Refactor: printPoolChangeDropdown Refactor: poolDropdown Refactor: printProtocolQuota Refactor: printGraphTopFlows Refactor: drawGraphs Refactor: printNotes Refactor: getMinZoomResolution Refactor: printSeries Refactor: zoom_vals Refactor: getZoomDuration Refactor: getZoomAtPos Refactor: stackedProgressBars Refactor: percentageBar Refactor: breakdownBar Refactor: getProtoVolume Refactor: normalizeSeriesPoints Refactor: nv_graph_utils Refactor: extendLabels Refactor: getAlertGraphLink Refactor: performCustomQuery Refactor: drawProGraph Refactor: unifies nv_graph_utils and graph_utils
41 lines
1.5 KiB
Lua
41 lines
1.5 KiB
Lua
require "lua_utils"
|
|
local graph_utils = require "graph_utils"
|
|
|
|
-- Get from redis the throughput type bps or pps
|
|
local throughput_type = getThroughputType()
|
|
|
|
local now = os.time()
|
|
|
|
function as2record(ifId, as)
|
|
local record = {}
|
|
record["key"] = tostring(as["asn"])
|
|
|
|
local as_link = "<A HREF='"..ntop.getHttpPrefix()..'/lua/hosts_stats.lua?asn='..as["asn"].."' title='"..as["asname"].."'>"..as["asn"]..'</A>'
|
|
record["column_asn"] = as_link
|
|
|
|
record["column_asname"] = printASN(as["asn"], as["asname"])
|
|
|
|
record["column_hosts"] = as["num_hosts"]..""
|
|
record["column_since"] = secondsToTime(now - as["seen.first"] + 1)
|
|
|
|
local sent2rcvd = round((as["bytes.sent"] * 100) / (as["bytes.sent"] + as["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-info' style='width: " .. (100-sent2rcvd) .. "%;'>Rcvd</div></div>"
|
|
|
|
if(throughput_type == "pps") then
|
|
record["column_thpt"] = pktsToSize(as["throughput_pps"])
|
|
else
|
|
record["column_thpt"] = bitsToSize(8*as["throughput_bps"])
|
|
end
|
|
|
|
record["column_traffic"] = bytesToSize(as["bytes.sent"] + as["bytes.rcvd"])
|
|
|
|
record["column_chart"] = ""
|
|
|
|
if areASTimeseriesEnabled(ifId) then
|
|
record["column_chart"] = '<A HREF="'..ntop.getHttpPrefix()..'/lua/as_details.lua?asn='..as["asn"]..'&page=historical"><i class=\'fas fa-chart-area fa-lg\'></i></A>'
|
|
end
|
|
|
|
return record
|
|
end
|
|
|