mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 23:49:33 +00:00
Implements Top Talkers and Top Applications In Time Range
Top Talkers and Top applications can be retrieved via MySQL both interface-wide and per-host. A couple of tabs, namely "Top Talkers" and "Top Applications" become available in the historical page of interfaces and hosts. Upon focus of each tab, an ajax request is triggered and data is fetched from MySQL. TODO: interface wide top-talkers are retrieved from sqlite and need to be moved to mysql.
This commit is contained in:
parent
91df9df585
commit
25ee0d5c11
6 changed files with 500 additions and 191 deletions
94
scripts/lua/modules/historical_utils.lua
Normal file
94
scripts/lua/modules/historical_utils.lua
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
require "lua_utils"
|
||||
|
||||
function historicalTopTalkersTable(ifid, epoch_begin, epoch_end, host)
|
||||
local top_talkers_url_params=""
|
||||
top_talkers_url_params = top_talkers_url_params.."&epoch_start="..epoch_begin
|
||||
top_talkers_url_params = top_talkers_url_params.."&epoch_end="..epoch_end
|
||||
if host and host ~= "" then
|
||||
top_talkers_url_params = top_talkers_url_params.."&peer1="..host
|
||||
end
|
||||
local preference = tablePreferences("rows_number",_GET["perPage"])
|
||||
local sort_order = getDefaultTableSortOrder("historical_stats_top_talkers")
|
||||
local sort_column= getDefaultTableSort("historical_stats_top_talkers")
|
||||
if not sort_column or sort_column == "column_" then sort_column = "column_bytes" end
|
||||
print[[
|
||||
<div id="historical-top-talkers-table">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$('a[href="#historical-top-talkers"]').on('shown.bs.tab', function (e) {
|
||||
var target = $(e.target).attr("href"); // activated tab
|
||||
$('#historical-top-talkers-table').datatable({
|
||||
title: "",]]
|
||||
print("url: '"..ntop.getHttpPrefix().."/lua/get_historical_data.lua?stats_type=top_talkers"..top_talkers_url_params.."',")
|
||||
if preference ~= "" then print ('perPage: '..preference.. ",\n") end
|
||||
-- Automatic default sorted. NB: the column must be exists.
|
||||
print ('sort: [ ["'..sort_column..'","'..sort_order..'"] ],\n')
|
||||
print [[
|
||||
showFilter: true,
|
||||
showPagination: true,
|
||||
columns:
|
||||
[
|
||||
{title: "Address", field: "column_addr", hidden: true},
|
||||
{title: "Host Name", field: "column_label", sortable: true},
|
||||
{title: "Traffic Volume", field: "column_bytes", sortable: true},
|
||||
{title: "Packets", field: "column_packets", sortable: true},
|
||||
{title: "Flows", field: "column_flows", sortable: true}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
]]
|
||||
end
|
||||
|
||||
function historicalTopApplicationsTable(ifid, epoch_begin, epoch_end, host)
|
||||
local top_apps_url_params=""
|
||||
top_apps_url_params = top_apps_url_params.."&epoch_start="..epoch_begin
|
||||
top_apps_url_params = top_apps_url_params.."&epoch_end="..epoch_end
|
||||
if host and host ~= "" then
|
||||
top_apps_url_params = top_apps_url_params.."&peer1="..host
|
||||
end
|
||||
local preference = tablePreferences("rows_number",_GET["perPage"])
|
||||
local sort_order = getDefaultTableSortOrder("historical_stats_top_applications")
|
||||
local sort_column= getDefaultTableSort("historical_stats_top_applications")
|
||||
if not sort_column or sort_column == "column_" then sort_column = "column_tot_bytes" end
|
||||
|
||||
print[[
|
||||
<div id="historical-top-applications-table">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$('a[href="#historical-top-apps"]').on('shown.bs.tab', function (e) {
|
||||
var target = $(e.target).attr("href"); // activated tab
|
||||
$('#historical-top-applications-table').datatable({
|
||||
title: "",]]
|
||||
print("url: '"..ntop.getHttpPrefix().."/lua/get_historical_data.lua?stats_type=top_applications"..top_apps_url_params.."',")
|
||||
if preference ~= "" then print ('perPage: '..preference.. ",\n") end
|
||||
-- Automatic default sorted. NB: the column must be exists.
|
||||
print ('sort: [ ["'..sort_column..'","'..sort_order..'"] ],\n')
|
||||
print [[
|
||||
showFilter: true,
|
||||
showPagination: true,
|
||||
columns:
|
||||
[
|
||||
{title: "Protocol id", field: "column_application", hidden: true},
|
||||
{title: "Application", field: "column_label", sortable: true},
|
||||
{title: "Traffic Volume", field: "column_bytes", sortable: true},
|
||||
{title: "Packets", field: "column_packets", sortable: true},
|
||||
{title: "Flows", field: "column_flows", sortable: true}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
]]
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue