--
-- (C) 2013-21 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
if(ntop.isPro()) then
package.path = dirs.installdir .. "/pro/scripts/lua/modules/?.lua;" .. package.path
local snmp_utils = require "snmp_utils"
end
require "lua_utils"
local graph_utils = require "graph_utils"
local ts_utils = require("ts_utils")
local page_utils = require("page_utils")
local asn = tonumber(_GET["asn"])
local page = _GET["page"]
local application = _GET["application"]
local version = _GET["version"]
local flowhosts_type = _GET["flowhosts_type"]
interface.select(ifname)
local as_info = interface.getASInfo(asn) or {}
local ifId = getInterfaceId(ifname)
local asname = as_info["asname"]
local base_url = ntop.getHttpPrefix() .. "/lua/as_details.lua"
local page_params = {}
if asn then
page_params["asn"] = asn
end
if asn then
page_params["application"] = application
end
if page then
page_params["page"] = page
end
if flowhosts_type then
page_params["flowhosts_type"] = flowhosts_type
end
local label = (asn or '')..''
if not isEmptyString(asname) then
label = label.." ["..shortenString(asname).."]"
end
sendHTTPContentTypeHeader('text/html')
-- #######################
local function formatDropdownEntries(entries, base_url, param_arr, param_filter, curr_filter)
local dropdownString = ""
for _, htype in ipairs(entries) do
if type(htype) == "string" then
-- plain html
dropdownString = htype
goto continue
end
param_arr[param_filter] = htype[1]
dropdownString = dropdownString .. '
' .. htype[2] .. ''
::continue::
end
return dropdownString
end
-- #######################
local function addDropdownEntries(entries, base_url, param_arr, param_filter, curr_filter)
local dropdownString = ""
for _, htype in ipairs(entries) do
if type(htype) == "string" then
-- plain html
dropdownString = htype
goto continue
end
param_arr[param_filter] = htype[1]
dropdownString = dropdownString .. '' .. htype[2] .. ''
::continue::
end
return dropdownString
end
-- #######################
page_utils.print_header()
page_utils.set_active_menu_entry(page_utils.menu_entries.autonomous_systems)
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
if isEmptyString(asn) then
print(" .. )
".. i18n("as_details.as_parameter_missing_message") .. "
")
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
return
end
--[[
Create Menu Bar with buttons
--]]
local nav_url = ntop.getHttpPrefix().."/lua/as_details.lua?asn="..tonumber(asn)
local title = i18n("as_details.as") .. ": "..label
page_utils.print_navbar(title, nav_url,
{
{
active = page == "flows" or not page,
page_name = "flows",
label = i18n("flows"),
},
{
active = page == "historical",
page_name = "historical",
label = "",
},
}
)
if isEmptyString(page) or page == "historical" then
local default_schema = "asn:traffic"
if(not ts_utils.exists(default_schema, {ifid=ifId, asn=asn})) then
print(" .. )
"..i18n("as_details.no_available_data_for_as",{asn = label}))
print(" "..i18n("as_details.as_timeseries_enable_message",{url = ntop.getHttpPrefix().."/lua/admin/prefs.lua?tab=on_disk_ts",icon_flask="
"})..'
')
else
local schema = _GET["ts_schema"] or default_schema
local selected_epoch = _GET["epoch"] or ""
local asn_url = ntop.getHttpPrefix()..'/lua/as_details.lua?ifid='..ifId..'&asn='..asn..'&page=historical'
local tags = {
ifid = ifId,
asn = asn,
protocol = _GET["protocol"],
}
graph_utils.drawGraphs(ifId, schema, tags, _GET["zoom"], asn_url, selected_epoch, {
top_protocols = "top:asn:ndpi",
timeseries = {
{schema="asn:traffic", label=i18n("traffic"), split_directions = true --[[ split RX and TX directions ]]},
{schema="asn:rtt", label=i18n("graphs.num_ms_rtt"), nedge_exclude=1},
{schema="asn:traffic_sent", label=i18n("graphs.traffic_sent"), nedge_exclude=1},
{schema="asn:traffic_rcvd", label=i18n("graphs.traffic_rcvd"), nedge_exclude=1},
{schema="asn:score", label=i18n("score"), split_directions = true},
{schema="asn:tcp_retransmissions", label=i18n("graphs.tcp_packets_retr"), nedge_exclude=1},
{schema="asn:tcp_out_of_order", label=i18n("graphs.tcp_packets_ooo"), nedge_exclude=1},
{schema="asn:tcp_lost", label=i18n("graphs.tcp_packets_lost"), nedge_exclude=1},
{schema="asn:tcp_keep_alive", label=i18n("graphs.tcp_packets_keep_alive"), nedge_exclude=1},
},
})
end
print[[
]] print(i18n('notes')) print[[
- ]] print(i18n('graphs.note_ases_traffic')) print[[
- ]] print(i18n('graphs.note_ases_sent')) print[[
- ]] print(i18n('graphs.note_ases_rcvd')) print[[
]]
elseif page == "flows" then
print [[
]]
end
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")