mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Adds an Active Flows page to the AS details
This commit is contained in:
parent
4e4020a480
commit
d5e36e87f4
8 changed files with 258 additions and 33 deletions
233
scripts/lua/as_details.lua
Normal file
233
scripts/lua/as_details.lua
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
--
|
||||
-- (C) 2013-17 - ntop.org
|
||||
--
|
||||
|
||||
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
|
||||
require "snmp_utils"
|
||||
end
|
||||
|
||||
require "lua_utils"
|
||||
require "graph_utils"
|
||||
|
||||
local asn = tonumber(_GET["asn"])
|
||||
local page = _GET["page"]
|
||||
|
||||
local application = _GET["application"]
|
||||
|
||||
interface.select(ifname)
|
||||
|
||||
local as_info = interface.getASInfo(asn) or {}
|
||||
local ifId = getInterfaceId(ifname)
|
||||
local asname = as_info["asname"]
|
||||
|
||||
local label = (asn or '')..''
|
||||
if not isEmptyString(asname) then
|
||||
label = label.." ["..shortenString(asname).."]"
|
||||
end
|
||||
|
||||
sendHTTPContentTypeHeader('text/html')
|
||||
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
|
||||
|
||||
if isEmptyString(asn) then
|
||||
print("<div class=\"alert alert alert-danger\"><img src=".. ntop.getHttpPrefix() .. "/img/warning.png> ".. i18n("as_details.as_parameter_missing_message") .. "</div>")
|
||||
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)
|
||||
print [[
|
||||
<div class="bs-docs-example">
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
]]
|
||||
|
||||
print("<li><a href=\"#\">" .. i18n("as_details.as") .. ": "..label.."</A> </li>")
|
||||
|
||||
if(page == "flows") then
|
||||
print("<li class=\"active\"><a href=\"#\">"..i18n("flows").."</a></li>\n")
|
||||
else
|
||||
print("<li><a href=\""..nav_url.."&page=flows\">"..i18n("flows").."</a></li>")
|
||||
end
|
||||
|
||||
if(page == "historical") then
|
||||
print("\n<li class=\"active\"><a href=\"#\"><i class='fa fa-area-chart fa-lg'></i></a></li>\n")
|
||||
else
|
||||
print("\n<li><a href=\""..nav_url.."&page=historical\"><i class='fa fa-area-chart fa-lg'></i></a></li>")
|
||||
end
|
||||
|
||||
print [[
|
||||
<li><a href="javascript:history.go(-1)"><i class='fa fa-reply'></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
]]
|
||||
|
||||
if isEmptyString(page) or page == "historical" then
|
||||
local rrdname = getRRDName(ifId, 'asn:'..asn, 'bytes.rrd')
|
||||
|
||||
if(not ntop.exists(rrdname)) then
|
||||
print("<div class=\"alert alert alert-danger\"><img src=".. ntop.getHttpPrefix() .. "/img/warning.png> "..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="<i class=\"fa fa-flask\"></i>"})..'</div>')
|
||||
|
||||
else
|
||||
local rrdfile = "bytes.rrd"
|
||||
if not isEmptyString(_GET["rrd_file"]) then
|
||||
rrdfile=_GET["rrd_file"]
|
||||
end
|
||||
|
||||
local asn_url = ntop.getHttpPrefix()..'/lua/as_details.lua?ifid='..ifId..'&asn='..asn..'&page=historical'
|
||||
drawRRD(ifId, 'asn:'..asn, rrdfile, _GET["zoom"], asn_url, 1, _GET["epoch"], nil, makeTopStatsScriptsArray())
|
||||
end
|
||||
|
||||
elseif page == "flows" then
|
||||
|
||||
print [[
|
||||
<div id="table-flows"></div>
|
||||
<script>
|
||||
var url_update = "]]
|
||||
print (ntop.getHttpPrefix())
|
||||
print [[/lua/get_flows_data.lua?ifid=]]
|
||||
print(ifId.."&")
|
||||
if not isEmptyString(application) then
|
||||
print("application="..application)
|
||||
end
|
||||
print("&asn="..asn..'";')
|
||||
|
||||
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/flows_stats_id.inc")
|
||||
|
||||
local active_flows_msg = i18n("flows_page.active_flows",{filter = ""})
|
||||
if not interface.isPacketInterface() then
|
||||
active_flows_msg = i18n("flows_page.recently_active_flows",{filter = ""})
|
||||
elseif interface.isPcapDumpInterface() then
|
||||
active_flows_msg = i18n("flows")
|
||||
end
|
||||
|
||||
local application_filter = ''
|
||||
if(application ~= nil) then
|
||||
application_filter = '<span class="glyphicon glyphicon-filter"></span>'
|
||||
end
|
||||
local dt_buttons = "['<div class=\"btn-group\"><button class=\"btn btn-link dropdown-toggle\" data-toggle=\"dropdown\">"..i18n("flows_page.applications").. " " .. application_filter .. "<span class=\"caret\"></span></button> <ul class=\"dropdown-menu\" role=\"menu\" >"
|
||||
dt_buttons = dt_buttons..'<li><a href="'..nav_url..'&page=flows">'..i18n("flows_page.all_proto")..'</a></li>'
|
||||
|
||||
local ndpi_stats = interface.getASInfo(asn)
|
||||
|
||||
for key, value in pairsByKeys(ndpi_stats["ndpi"], asc) do
|
||||
local class_active = ''
|
||||
if(key == application) then
|
||||
class_active = ' class="active"'
|
||||
end
|
||||
dt_buttons = dt_buttons..'<li '..class_active..'><a href="'..nav_url..'&page=flows&application='..key..'">'..key..'</a></li>'
|
||||
end
|
||||
|
||||
dt_buttons = dt_buttons .. "</ul></div>']"
|
||||
|
||||
print [[
|
||||
flow_rows_option["type"] = 'host';
|
||||
$("#table-flows").datatable({
|
||||
url: url_update,
|
||||
buttons: ]] print(dt_buttons) print[[,
|
||||
rowCallback: function ( row ) { return flow_table_setID(row); },
|
||||
showPagination: true,
|
||||
]]
|
||||
|
||||
print('title: "'..active_flows_msg..'",')
|
||||
|
||||
-- Set the preference table
|
||||
preference = tablePreferences("rows_number",_GET["perPage"])
|
||||
if(preference ~= "") then print ('perPage: '..preference.. ",\n") end
|
||||
|
||||
|
||||
print ('sort: [ ["' .. getDefaultTableSort("flows") ..'","' .. getDefaultTableSortOrder("flows").. '"] ],\n')
|
||||
|
||||
print [[
|
||||
columns: [
|
||||
{
|
||||
title: "Key",
|
||||
field: "key",
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
title: "",
|
||||
field: "column_key",
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("application")) print[[",
|
||||
field: "column_ndpi",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("flows_page.l4_proto")) print[[",
|
||||
field: "column_proto_l4",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("client")) print[[",
|
||||
field: "column_client",
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("server")) print[[",
|
||||
field: "column_server",
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("duration")) print[[",
|
||||
field: "column_duration",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'right'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("flows_page.actual_throughput")) print[[",
|
||||
field: "column_thpt",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'right'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("flows_page.total_bytes")) print[[",
|
||||
field: "column_bytes",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'right'
|
||||
}
|
||||
|
||||
}
|
||||
,{
|
||||
title: "]] print(i18n("info")) print[[",
|
||||
field: "column_info",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'left'
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
</script>
|
||||
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|
||||
Loading…
Add table
Add a link
Reference in a new issue