Fixes drill-down when Clickhouse is enabled

Addresses #6021
This commit is contained in:
Simone Mainardi 2021-10-29 15:52:11 +02:00
parent 1051c7a3cd
commit 7d93d3b5be
2 changed files with 44 additions and 13 deletions

View file

@ -3223,22 +3223,53 @@ end
-- ##########################################
function historicalProtoHostHref(ifId, host, l4_proto, ndpi_proto_id, info)
if ntop.isPro() and ntop.getPrefs().is_dump_flows_to_mysql_enabled == true then
local hist_url = ntop.getHttpPrefix().."/lua/pro/db_explorer.lua?search=true&ifid="..ifId
if ntop.isPro() then
local now = os.time()
local ago1h = now - 3600
hist_url = hist_url.."&epoch_end="..tostring(now)
if((host ~= nil) and (host ~= "")) then hist_url = hist_url.."&"..hostinfo2url(host) end
if((l4_proto ~= nil) and (l4_proto ~= "")) then
hist_url = hist_url.."&l4proto="..l4_proto
local prefs = ntop.getPrefs()
if prefs.is_dump_flows_to_clickhouse_enabled then
local hist_url = ntop.getHttpPrefix().."/lua/pro/db_search.lua?"
local params = {epoch_end = now, epoch_begin = ago1h, ifid = ifId}
if host then
local host_k = hostinfo2hostkey(host)
if isEmptyString(host_k) then
host_k = host
end
params["ip"] = host_k..";eq"
end
if l4_proto then
params["l4proto"] = l4_proto..";eq"
end
if ndpi_proto_id then
params["l7proto"] = ndpi_proto_id..";eq"
end
local url_params = table.tconcat(params, "=", "&")
print(' ')
-- print('<span class="badge bg-info">')
print('<a href="'..hist_url..url_params..'" title="'..i18n("db_explorer.last_hour_flows")..'"><i class="fas fa-search-plus fa-lg"></i></a>')
-- print('</span>')
elseif prefs.is_dump_flows_to_mysql_enabled then
local hist_url = ntop.getHttpPrefix().."/lua/pro/db_explorer.lua?search=true&ifid="..ifId
hist_url = hist_url.."&epoch_end="..tostring(now)
if((host ~= nil) and (host ~= "")) then hist_url = hist_url.."&"..hostinfo2url(host) end
if((l4_proto ~= nil) and (l4_proto ~= "")) then
hist_url = hist_url.."&l4proto="..l4_proto
end
if((ndpi_proto_id ~= nil) and (ndpi_proto_id ~= "")) then hist_url = hist_url.."&protocol="..ndpi_proto_id end
if((info ~= nil) and (info ~= "")) then hist_url = hist_url.."&info="..info end
print('&nbsp;')
-- print('<span class="badge bg-info">')
print('<a href="'..hist_url..'&epoch_begin='..tostring(ago1h)..'" title="'..i18n("db_explorer.last_hour_flows")..'"><i class="fas fa-search-plus fa-lg"></i></a>')
-- print('</span>')
end
if((ndpi_proto_id ~= nil) and (ndpi_proto_id ~= "")) then hist_url = hist_url.."&protocol="..ndpi_proto_id end
if((info ~= nil) and (info ~= "")) then hist_url = hist_url.."&info="..info end
print('&nbsp;')
-- print('<span class="badge bg-info">')
print('<a href="'..hist_url..'&epoch_begin='..tostring(ago1h)..'" title="'..i18n("db_explorer.last_hour_flows")..'"><i class="fas fa-search-plus fa-lg"></i></a>')
-- print('</span>')
end
end