mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-06 03:45:26 +00:00
ArpMatrix code moved to attic
This commit is contained in:
parent
0d4927f89a
commit
70dc07c3f1
22 changed files with 11 additions and 200 deletions
|
|
@ -670,13 +670,6 @@ function printMisc()
|
|||
multipleTableButtonPrefs(subpage_active.entries["toggle_host_mask"].title,
|
||||
subpage_active.entries["toggle_host_mask"].description,
|
||||
h_labels, h_values, "0", "primary", "toggle_host_mask", "ntopng.prefs.host_mask")
|
||||
|
||||
prefsToggleButton(subpage_active, {
|
||||
field = "toggle_arp_matrix_generation",
|
||||
default = "0",
|
||||
pref = "arp_matrix_generation",
|
||||
to_switch = nil,
|
||||
})
|
||||
end
|
||||
|
||||
-- #####################
|
||||
|
|
|
|||
|
|
@ -1,139 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-20 - ntop.org
|
||||
--
|
||||
|
||||
dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
-- io.write ("Session:".._SESSION["session"].."\n")
|
||||
require "lua_utils"
|
||||
|
||||
local page_utils = require("page_utils")
|
||||
sendHTTPContentTypeHeader('text/html')
|
||||
|
||||
interface.select(ifname)
|
||||
page_utils.print_header()
|
||||
|
||||
local host_info = url2hostinfo(_GET)
|
||||
local host_ip = nil
|
||||
if host_info then
|
||||
host_ip = host_info["host"]
|
||||
end
|
||||
|
||||
--active_page = "home"
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")
|
||||
|
||||
local ifstats = interface.getStats()
|
||||
local is_loopback = interface.isLoopback()
|
||||
local iface_id = interface.name2id(ifname)
|
||||
|
||||
-- Load from or set in redis the refresh frequency for the top talkers heatmap
|
||||
local refresh = _GET["refresh"]
|
||||
local refresh_key = 'ntopng.prefs.'.._SESSION["user"]..'.'..ifname..'.heatmap_refresh'
|
||||
|
||||
if (refresh ~= nil) then
|
||||
ntop.setCache(refresh_key,refresh)
|
||||
else
|
||||
refresh = ntop.getCache(refresh_key)
|
||||
end
|
||||
-- Default frequency (ms)
|
||||
if (refresh == '') then refresh = 5000 end
|
||||
|
||||
|
||||
if((ifstats ~= nil) and (ifstats.stats.packets > 0)) then
|
||||
-- Print tabbed header
|
||||
|
||||
print [[
|
||||
<script src="]] print(ntop.getHttpPrefix()) print[[/js/d3.v4.min.js"></script>
|
||||
|
||||
|
||||
<div style="background-color:white", id="container"></div>
|
||||
<div style="background-color:white", id="container2"></div>
|
||||
|
||||
<div class="control-group" style="text-align: center;">
|
||||
]] print(i18n("index_page.refresh_frequency")) print[[: <div class="btn-group btn-small">
|
||||
<button class="btn btn-secondary btn-xs dropdown-toggle" data-toggle="dropdown">
|
||||
]]
|
||||
if (refresh ~= '0') then
|
||||
if (refresh == '60000') then
|
||||
print('1 '..i18n("index_page.minute"))
|
||||
else
|
||||
print((refresh/1000)..' '..i18n("index_page.seconds")..' ')
|
||||
end
|
||||
else
|
||||
print(' '..i18n("index_page.never")..' ')
|
||||
end
|
||||
|
||||
print [[<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu ">
|
||||
]]
|
||||
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=5000" >5 '..i18n("index_page.seconds")..'</a></li>\n')
|
||||
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=10000" >10 '..i18n("index_page.seconds")..'</a></li>\n')
|
||||
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=30000" >30 '..i18n("index_page.seconds")..'</a></li>\n')
|
||||
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=60000" >1 '..i18n("index_page.minute")..'</a></li>\n')
|
||||
print('<li style="text-align: left;"> <a href="'..ntop.getHttpPrefix()..'?refresh=0" >'..i18n("index_page.never")..'</a></li>\n')
|
||||
print [[
|
||||
</ul>
|
||||
</div><!-- /btn-group -->
|
||||
]]
|
||||
|
||||
if (refresh ~= '0') then
|
||||
print [[
|
||||
]] print(i18n("index_page.live_update")) print[[: <div class="btn-group btn-group-xs" data-toggle="buttons-radio" data-toggle-name="topflow_graph_state">
|
||||
<button id="topflow_graph_state_play" value="1" type="button" class="btn btn-secondary btn-xs active" data-toggle="button" ><i class="fas fa-play"></i></button>
|
||||
<button id="topflow_graph_state_stop" value="0" type="button" class="btn btn-secondary btn-xs" data-toggle="button" ><i class="fas fa-stop"></i></button>
|
||||
</div>
|
||||
]]
|
||||
else
|
||||
print [[
|
||||
]] print(i18n("index_page.refresh")) print[[: <div class="btn-group btn-small">
|
||||
<button id="topflow_graph_refresh" class="btn btn-secondary btn-xs">
|
||||
<i rel="tooltip" data-toggle="tooltip" data-placement="top" data-original-title="]] print(i18n("index_page.refresh_graph_popup_msg")) print [[" class="glyphicon glyphicon-refresh"></i></button>
|
||||
</div>
|
||||
]]
|
||||
end
|
||||
print [[
|
||||
</div>
|
||||
]]
|
||||
|
||||
print[[
|
||||
<script src="]] print(ntop.getHttpPrefix()) print[[/js/heatmap.js"></script>
|
||||
|
||||
<script>
|
||||
$("#topflow_graph_state_play").click(function() {
|
||||
map.startUpdate();
|
||||
map.build(]]
|
||||
print(refresh)
|
||||
if host_ip then
|
||||
print[[, "]]print(host_ip.."\"")
|
||||
end
|
||||
print[[);
|
||||
$("#topflow_graph_state_stop").removeClass("active");
|
||||
$("#topflow_graph_state_play").addClass("active");
|
||||
});
|
||||
$("#topflow_graph_state_stop").click(function() {
|
||||
map.stopUpdate();
|
||||
$("#topflow_graph_state_play").removeClass("active");
|
||||
$("#topflow_graph_state_stop").addClass("active");
|
||||
});
|
||||
$("#topflow_graph_refresh").click(function() {
|
||||
map.build(]]
|
||||
print("0")
|
||||
if host_ip then
|
||||
print[[, "]]print(host_ip.."\"")
|
||||
end
|
||||
|
||||
print[[);
|
||||
});
|
||||
|
||||
map.build(]]
|
||||
print(refresh)
|
||||
if host_ip then
|
||||
print[[, "]]print(host_ip.."\"")
|
||||
end
|
||||
|
||||
print[[);
|
||||
</script>
|
||||
]]
|
||||
end
|
||||
|
||||
dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-20 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
require "lua_utils"
|
||||
|
||||
local json = require("dkjson")
|
||||
sendHTTPContentTypeHeader('application/json')
|
||||
|
||||
local matrix = interface.getArpStatsMatrixInfo()
|
||||
|
||||
local host_info = url2hostinfo(_GET)
|
||||
local host_ip = host_info["host"]
|
||||
local page = _GET["page"]
|
||||
|
||||
local treshold = 0
|
||||
|
||||
local function createHeatmap(matrix, type)
|
||||
|
||||
if not matrix then return nil end
|
||||
|
||||
local t = {}
|
||||
local tmp = {}
|
||||
local v = 0
|
||||
local t_res = {}
|
||||
|
||||
-- function cmp(a,b)
|
||||
-- return a.y_label > b.y_label
|
||||
-- end
|
||||
|
||||
for _, m_elem in pairs(matrix) do
|
||||
for i,stats in pairs(m_elem)do
|
||||
tmp = split(i,"-")
|
||||
src_ip = tmp[1]
|
||||
dst_ip = tmp[2]
|
||||
|
||||
if type == "requests" then v = stats["src2dst.requests"]
|
||||
elseif type == "replies" then v = stats["src2dst.replies"]
|
||||
elseif type == "all" then v = stats["src2dst.requests"] + stats["src2dst.replies"]
|
||||
end
|
||||
|
||||
if v > treshold then
|
||||
table.insert( t_res, { x_label = dst_ip, y_label = src_ip, value = v })
|
||||
end
|
||||
v = 0
|
||||
|
||||
if type == "requests" then v = stats["dst2src.requests"]
|
||||
elseif type == "replies" then v = stats["dst2src.replies"]
|
||||
elseif type == "all" then v = stats["dst2src.requests"] + stats["dst2src.replies"]
|
||||
end
|
||||
|
||||
if v > treshold then
|
||||
table.insert( t_res, { x_label = src_ip, y_label = dst_ip, value = v })
|
||||
end
|
||||
--table.sort(t_res, cmp) --for lexicographical order
|
||||
end
|
||||
end
|
||||
|
||||
return t_res
|
||||
end
|
||||
|
||||
--NOTE: function currently not used
|
||||
local function createMap4Target(matrix, type, ip_target)
|
||||
local tmp = {}
|
||||
local v = 0
|
||||
local t_res = {}
|
||||
local treshold = 0
|
||||
|
||||
for _, m_elem in pairs(matrix) do
|
||||
for i,stats in pairs(m_elem)do
|
||||
|
||||
tmp = split(i,"-")
|
||||
src_ip = tmp[1]
|
||||
dst_ip = tmp[2]
|
||||
|
||||
if type == "requests" then v = stats["src2dst.requests"]
|
||||
elseif type == "replies" then v = stats["src2dst.replies"]
|
||||
elseif type == "all" then v = stats["src2dst.requests"] + stats["src2dst.replies"]
|
||||
end
|
||||
|
||||
if (v > treshold) and (src_ip == ip_target) then
|
||||
table.insert( t_res, { x_label = dst_ip, y_label = src_ip, value = v })
|
||||
end
|
||||
v = 0
|
||||
|
||||
if type == "requests" then v = stats["dst2src.requests"]
|
||||
elseif type == "replies" then v = stats["dst2src.replies"]
|
||||
elseif type == "all" then v = stats["dst2src.requests"] + stats["dst2src.replies"]
|
||||
end
|
||||
|
||||
if (v > treshold) and (dst_ip == ip_target) then
|
||||
table.insert( t_res, { x_label = src_ip, y_label = dst_ip, value = v })
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return t_res
|
||||
end
|
||||
|
||||
--return 2 counters: number of ARP requests received, and the number of senders for that requests
|
||||
local function arpTalkers(matrix, host_ip)
|
||||
local req_num = 0;
|
||||
local talkers_num = 0;
|
||||
|
||||
if (matrix and host_ip) then
|
||||
|
||||
for _, m_elem in pairs(matrix) do
|
||||
for i, stats in pairs(m_elem)do
|
||||
tmp = split(i,"-")
|
||||
src_ip = tmp[1]
|
||||
dst_ip = tmp[2]
|
||||
|
||||
if ((stats["src2dst.requests"] > 0) and (src_ip == host_ip)) or
|
||||
((stats["dst2src.requests"] > 0) and (dst_ip == host_ip))then
|
||||
|
||||
req_num = req_num + stats["src2dst.requests"] + stats["dst2src.requests"]
|
||||
talkers_num = talkers_num + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
return {talkers_num = talkers_num, req_num = req_num}
|
||||
end
|
||||
|
||||
if host_ip then
|
||||
print( json.encode( arpTalkers(matrix, host_ip) ) )
|
||||
else
|
||||
print( json.encode( createHeatmap(matrix, "all"), {indent = true} ) )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -651,43 +651,6 @@ end
|
|||
<button class="btn btn-secondary" onclick="$('#reset_host_stats_dialog').modal('show')">]] print(i18n("host_details.reset_host_stats")) print[[</button>
|
||||
</td></tr>]]
|
||||
|
||||
local am_enabled = (ntop.getPrefs()).is_arp_matrix_generation_enabled
|
||||
|
||||
if am_enabled then
|
||||
local arp_matrix_utils = require "arp_matrix_utils"
|
||||
|
||||
if (arp_matrix_utils.arpCheck(host_ip)) then
|
||||
print[[<tr><th width=30% >]] print("ARP Requests")
|
||||
print[[<a href="arp_matrix_graph.lua?host=]]print(host_ip)print[["> [See in Map]</a>]]
|
||||
print[[</th><td colspan=2 id="arp_req_td">
|
||||
|
||||
<script>
|
||||
|
||||
var printText = function(){
|
||||
$.getJSON("]]print (ntop.getHttpPrefix())print[[/lua/get_arp_matrix_data.lua?host=]]print(host_ip)print[[", function(data){
|
||||
|
||||
|
||||
if (data.talkers_num == 1)
|
||||
$("#arp_req_td").text( "Sent "+ data.req_num+ " Requests to " + data.talkers_num +" Host" );
|
||||
else
|
||||
$("#arp_req_td").text( "Sent "+ data.req_num+ " Requests to " + data.talkers_num +" different Hosts" );
|
||||
|
||||
$("#arp_req_td").prop("href", "arp_matrix_graph.lua?host=]]print(host_ip)print[[");
|
||||
} );
|
||||
};
|
||||
|
||||
printText();
|
||||
|
||||
setInterval(function() {
|
||||
printText();
|
||||
}, 3000);
|
||||
|
||||
</script>
|
||||
|
||||
</td></tr>]]
|
||||
end
|
||||
end
|
||||
|
||||
local num_extra_names = 0
|
||||
local extra_names = host["names"]
|
||||
local num_extra_names = table.len(extra_names)
|
||||
|
|
|
|||
|
|
@ -385,21 +385,6 @@ if not ifs.isViewed then -- Currently, hosts are not kept for viewed interfaces,
|
|||
end
|
||||
end)()
|
||||
..[[
|
||||
]]..
|
||||
(function()
|
||||
if ntop.getPrefs().is_arp_matrix_generation_enabled then
|
||||
return ([[
|
||||
<li>
|
||||
<a href="]]..ntop.getHttpPrefix()..[[/lua/arp_matrix_graph.lua.lua">
|
||||
]].. i18n("arp_top_talkers") ..[[
|
||||
</a>
|
||||
</li>
|
||||
]])
|
||||
else
|
||||
return [[]]
|
||||
end
|
||||
end)()
|
||||
..[[
|
||||
<li>
|
||||
<a href="]].. ntop.getHttpPrefix() ..[[/lua/bubble.lua">
|
||||
</i> Host Explorer
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
--
|
||||
-- (C) 2013-20 - ntop.org
|
||||
--
|
||||
|
||||
local dirs = ntop.getDirs()
|
||||
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
||||
require "lua_utils"
|
||||
|
||||
local matrix = interface.getArpStatsMatrixInfo()
|
||||
local arpMatrixModule = {}
|
||||
|
||||
function arpMatrixModule.arpCheck(host_ip)
|
||||
if not (matrix and host_ip) then return false end
|
||||
local req_num = 0;
|
||||
local talkers_num = 0;
|
||||
|
||||
if (matrix and host_ip) then
|
||||
|
||||
for _, m_elem in pairs(matrix) do
|
||||
for i, stats in pairs(m_elem)do
|
||||
tmp = split(i,"-")
|
||||
src_ip = tmp[1]
|
||||
dst_ip = tmp[2]
|
||||
|
||||
if ((stats["src2dst.requests"] > 0) and (src_ip == host_ip)) or
|
||||
((stats["dst2src.requests"] > 0) and (dst_ip == host_ip))then
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
return arpMatrixModule
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1462,7 +1462,6 @@ local known_parameters = {
|
|||
["edition"] = validateEmptyOr(validateChoiceInline({"community", "pro", "enterprise"})),
|
||||
["ts_high_resolution"] = validateNumber,
|
||||
["lbd_hosts_as_macs"] = validateBool,
|
||||
["toggle_arp_matrix_generation"] = validateBool,
|
||||
["toggle_send_telemetry_data"] = validateBool,
|
||||
["telemetry_email"] = validateSingleWord,
|
||||
|
||||
|
|
|
|||
|
|
@ -376,10 +376,7 @@ local menu_subpages = {
|
|||
}
|
||||
}}, {id="misc", label=i18n("prefs.misc"), advanced=false, pro_only=false, hidden=false, entries={
|
||||
|
||||
toggle_arp_matrix_generation = {
|
||||
title = i18n("prefs.toggle_arp_matrix_generation_title"),
|
||||
description = i18n("prefs.toggle_arp_matrix_generation_description", { product = info.product}),
|
||||
}, toggle_send_telemetry_data = {
|
||||
toggle_send_telemetry_data = {
|
||||
title = i18n("prefs.toggle_send_telemetry_data_title"),
|
||||
description = i18n("prefs.toggle_send_telemetry_data_description", { product = info.product}),
|
||||
}, toggle_thpt_content = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue