mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 15:39:33 +00:00
Refactors eBPF code with ebpf_utils.lua module
This commit is contained in:
parent
004a6cbbc8
commit
ffabf83511
6 changed files with 259 additions and 438 deletions
|
|
@ -6,6 +6,7 @@ local dirs = ntop.getDirs()
|
|||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
|
||||
require "lua_utils"
|
||||
local ebpf_utils = require "ebpf_utils"
|
||||
|
||||
sendHTTPContentTypeHeader('text/html')
|
||||
|
||||
|
|
@ -84,222 +85,11 @@ else
|
|||
|
||||
print('</ul>\n\t</div>\n\t</nav>\n')
|
||||
|
||||
|
||||
if page == "process_ndpi" then
|
||||
print [[
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr>
|
||||
<th class="text-left" colspan=2>]] print(i18n("ndpi_page.overview", {what = i18n("ndpi_page.application_protocol")})) print[[</th>
|
||||
<td>
|
||||
<div class="pie-chart" id="topApplicationProtocols"></div>
|
||||
</td>
|
||||
<td colspan=2>
|
||||
<div class="pie-chart" id="topApplicationBreeds"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-left" colspan=2>]] print(i18n("ndpi_page.overview", {what = i18n("ndpi_page.application_protocol_category")})) print[[</th>
|
||||
<td colspan=2>
|
||||
<div class="pie-chart" id="topApplicationCategories"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var refresh = ]] print(refresh_rate..'') print[[000 /* ms */;
|
||||
window.onload=function() {]]
|
||||
|
||||
print[[ do_pie("#topApplicationProtocols", ']]
|
||||
print (ntop.getHttpPrefix())
|
||||
print [[/lua/get_process_data.lua', { pid: "]] print(pid) print [[", process_data: "applications" ]]
|
||||
if host_info then print(", "..hostinfo2json(host_info)) end
|
||||
print [[ }, "", refresh); ]]
|
||||
|
||||
print[[ do_pie("#topApplicationCategories", ']]
|
||||
print (ntop.getHttpPrefix())
|
||||
print [[/lua/get_process_data.lua', { pid: "]] print(pid) print [[", process_data: "categories" ]]
|
||||
if host_info then print(", "..hostinfo2json(host_info)) end
|
||||
print [[ }, "", refresh); ]]
|
||||
|
||||
print[[do_pie("#topApplicationBreeds", ']]
|
||||
print (ntop.getHttpPrefix())
|
||||
print [[/lua/get_process_data.lua', { pid: "]] print(pid) print [[", process_data: "breeds" ]]
|
||||
if host_info then print(", "..hostinfo2json(host_info)) end
|
||||
print [[ }, "", refresh);]]
|
||||
|
||||
print[[
|
||||
}
|
||||
|
||||
</script>
|
||||
]]
|
||||
|
||||
ebpf_utils.draw_ndpi_piecharts(ifstats, "get_process_data.lua", host_info, nil, pid)
|
||||
elseif page == "flows" then
|
||||
print [[
|
||||
<div id="table-flows"></div>
|
||||
<script>
|
||||
var url_update = "]]
|
||||
print (ntop.getHttpPrefix())
|
||||
print [[/lua/get_flows_data.lua?pid=]] print(pid)
|
||||
if host_info then
|
||||
print ('&'..hostinfo2url(host_info))
|
||||
end
|
||||
print ('";')
|
||||
|
||||
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/flows_stats_id.inc")
|
||||
|
||||
local show_vlan
|
||||
if ifstats.vlan then show_vlan = true else show_vlan = false end
|
||||
-- Set the host table option
|
||||
if show_vlan then print ('flow_rows_option["vlan"] = true;\n') end
|
||||
|
||||
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 dt_buttons = ''
|
||||
-- TODO: add application filter, etc.
|
||||
dt_buttons = "["..dt_buttons.."]"
|
||||
|
||||
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); },
|
||||
tableCallback: function() { $("#dt-bottom-details > .pull-left > p").first().append('. ]]
|
||||
print(i18n('flows_page.idle_flows_not_listed'))
|
||||
print[['); },
|
||||
showPagination: true,
|
||||
]]
|
||||
|
||||
print('title: "'..active_flows_msg..'",')
|
||||
|
||||
-- Set the preference table
|
||||
local 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'
|
||||
}
|
||||
},]]
|
||||
|
||||
if show_vlan then
|
||||
|
||||
if ifstats.vlan then
|
||||
print('{ title: "'..i18n("vlan")..'",\n')
|
||||
end
|
||||
|
||||
|
||||
print [[
|
||||
field: "column_vlan",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
|
||||
},
|
||||
]]
|
||||
end
|
||||
print [[
|
||||
{
|
||||
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: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]] print(i18n("breakdown")) print[[",
|
||||
field: "column_breakdown",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
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'
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
]]
|
||||
|
||||
if have_nedge then
|
||||
printBlockFlowJs()
|
||||
end
|
||||
|
||||
print[[
|
||||
</script>
|
||||
|
||||
]]
|
||||
ebpf_utils.draw_flows_datatable(ifstats, host_info, nil, pid)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue