mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-10 00:42:14 +00:00
Added missing return code in interface.execSQLQuery
This commit is contained in:
parent
ba9551baff
commit
d8bf334ea7
7 changed files with 27 additions and 19 deletions
|
|
@ -76,7 +76,7 @@ if page == "overview" or not page then
|
|||
-- Get the first record time, if any
|
||||
if ntop.isClickHouseEnabled() then
|
||||
show_historical = true
|
||||
local res = interface.execSQLQuery("SELECT FIRST_SEEN FROM hourly_asn ORDER BY FIRST_SEEN ASC LIMIT 1")
|
||||
local res,err = interface.execSQLQuery("SELECT FIRST_SEEN FROM hourly_asn ORDER BY FIRST_SEEN ASC LIMIT 1")
|
||||
if res and type(res) == "table" and #res > 0 then
|
||||
first_seen = tonumber(res[1]["FIRST_SEEN"])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -410,9 +410,11 @@ function as_utils.retrieveASHistoricalTraffic(options)
|
|||
") GROUP BY asn", where, ternary(isEmptyString(src_asn_filters), "", " AND " .. src_asn_filters), where,
|
||||
ternary(isEmptyString(dst_asn_filters), "", " AND " .. dst_asn_filters))
|
||||
|
||||
local historical_asn_stats = interface.execSQLQuery(query) or {}
|
||||
local historical_asn_stats,err = interface.execSQLQuery(query)
|
||||
local asn_stats = {}
|
||||
|
||||
historical_asn_stats = historical_asn_stats or {}
|
||||
|
||||
if (perform_profiling) then
|
||||
traceError(TRACE_NORMAL, TRACE_CONSOLE,
|
||||
string.format("[ASN Profiling][Time: %s] End request to DB (Historical)\n", os.time()))
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ local function scan_check(params)
|
|||
"AND ip_src IS NOT NULL AND ip_dst IS NOT NULL ORDER BY total_flows DESC " ..
|
||||
"LIMIT 1000", tonumber(interface.getId()), interval_begin, interval_end, interval_end, threshold)
|
||||
|
||||
local results_port_query = interface.execSQLQuery(q_port)
|
||||
local results_port_query,err = interface.execSQLQuery(q_port)
|
||||
local results_port = iterative_src_dst_alert(params, results_port_query, false, "Port")
|
||||
|
||||
-- Service down
|
||||
|
|
@ -201,7 +201,8 @@ local function scan_check(params)
|
|||
"HAVING count_src_ports >= %u AND ip_src IS NOT NULL AND ip_dst IS NOT NULL " ..
|
||||
"ORDER BY total_flows DESC " .. "LIMIT 500",
|
||||
tonumber(interface.getId()), interval_begin, interval_end, interval_end, 50)
|
||||
local results_service_down = interface.execSQLQuery(q_service_down)
|
||||
|
||||
local results_service_down, rerr = interface.execSQLQuery(q_service_down)
|
||||
for _, row in ipairs(results_service_down) do
|
||||
local vlan_id = tonumber(row.vlan_id) or 0
|
||||
local attacker_ip = row.ip_src
|
||||
|
|
@ -232,8 +233,10 @@ local function scan_check(params)
|
|||
"AND DST2SRC_PACKETS <= 1 " .. "GROUP BY vlan_id, ip_src, dst_port, src_location, " .. "src_blacklisted, src_name " ..
|
||||
"HAVING count_ip_dst >= %u AND ip_src IS NOT NULL " .. "ORDER BY total_flows DESC " .. "LIMIT 1000", tonumber(interface.getId()), interval_begin,
|
||||
interval_end, interval_end, 50)
|
||||
local results_service = interface.execSQLQuery(q_service)
|
||||
|
||||
local results_service,s_err = interface.execSQLQuery(q_service)
|
||||
local service_attackers = {}
|
||||
|
||||
for _, row in ipairs(results_service) do
|
||||
local vlan_id = tonumber(row.vlan_id) or 0
|
||||
local attacker_ip = row.ip_src
|
||||
|
|
@ -268,7 +271,8 @@ local function scan_check(params)
|
|||
"AND (FIRST_SEEN >= %u AND FIRST_SEEN <= %u AND LAST_SEEN <= %u) " .. "AND L7_PROTO != 5 " .. "AND DST2SRC_PACKETS <= 1 " ..
|
||||
"GROUP BY vlan_id, ip_src, dst_network, src_location, " .. "src_blacklisted, src_name " .. "HAVING count_ip_dst >= %u AND ip_src IS NOT NULL " ..
|
||||
"ORDER BY total_flows DESC " .. "LIMIT 1000", tonumber(interface.getId()), interval_begin, interval_end, interval_end, 100)
|
||||
local results_network = interface.execSQLQuery(q_network)
|
||||
|
||||
local results_network, n_err = interface.execSQLQuery(q_network)
|
||||
for _, row in ipairs(results_network) do
|
||||
local vlan_id = tonumber(row.vlan_id) or 0
|
||||
local attacker_ip = row.ip_src
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ local function domains_check(params)
|
|||
threshold
|
||||
)
|
||||
|
||||
local results = interface.execSQLQuery(q)
|
||||
local results,err = interface.execSQLQuery(q)
|
||||
|
||||
for _, row in ipairs(results) do
|
||||
local count = tonumber(row.count) or 0
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ function getInterfaceTopFlows(interface_id, version, host_or_profile, peer, l7pr
|
|||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
|
||||
res = interface.execSQLQuery(sql, false) -- do not limit the maximum number of flows
|
||||
local res,err = interface.execSQLQuery(sql, false) -- do not limit the maximum number of flows
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
return {}
|
||||
|
|
@ -236,7 +236,7 @@ function getFlowInfo(interface_id, version, flow_idx)
|
|||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
|
||||
res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
return {}
|
||||
|
|
@ -309,7 +309,7 @@ function getNumFlows(interface_id, version, host, protocol, port, l7proto, info,
|
|||
end
|
||||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
|
|
@ -434,7 +434,7 @@ function getOverallTopTalkers(interface_id, l4proto, port, vlan, profile, info,
|
|||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
|
||||
res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
return {}
|
||||
|
|
@ -541,7 +541,7 @@ function getHostTopTalkers(interface_id, host, l7_proto_id, l4_proto_id, port, v
|
|||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
|
||||
res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
|
|
@ -667,7 +667,8 @@ function getAppTopTalkers(interface_id, l7_proto_id, l4_proto_id, port, vlan, pr
|
|||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
|
||||
res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
return {}
|
||||
|
|
@ -760,7 +761,8 @@ function getTopApplications(interface_id, peer1, peer2, l7_proto_id, l4_proto_id
|
|||
|
||||
if(db_debug == true) then io.write(sql.."\n") end
|
||||
|
||||
res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
|
||||
if(type(res) == "string") then
|
||||
if(db_debug == true) then io.write(res.."\n") end
|
||||
return {}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ end
|
|||
-- Execute a query via the C++ ClickHouse native client.
|
||||
-- Returns a list of row-tables on success, nil on failure.
|
||||
local function ch_query(sql)
|
||||
local res = interface.execSQLQuery(sql, false --[[no row limit]], false --[[don't wait for db]])
|
||||
local res,err = interface.execSQLQuery(sql, false --[[no row limit]], false --[[don't wait for db]])
|
||||
if type(res) ~= "table" then
|
||||
return nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function vs_db_utils.retrieve_scan_result(scan_type, host, end_epoch)
|
|||
if not ntop.isClickHouseEnabled() then return end
|
||||
local sql = "SELECT VS_RESULT_FILE FROM %s WHERE HOST = '%s' AND SCAN_TYPE = '%s' AND LAST_SCAN = %u;"
|
||||
sql = string.format(sql, data_table_name, host, scan_type, tonumber(end_epoch))
|
||||
local res = interface.execSQLQuery(sql)
|
||||
local res,err = interface.execSQLQuery(sql)
|
||||
local response = ""
|
||||
-- replace back all the "|" with "'"
|
||||
for _, item in ipairs(res) do
|
||||
|
|
@ -93,7 +93,7 @@ function vs_db_utils.retrieve_reports(sort_item, epoch)
|
|||
|
||||
sql = string.format(sql,report_table_name, sort_item)
|
||||
|
||||
local query_result = interface.execSQLQuery(sql)
|
||||
local query_result,err = interface.execSQLQuery(sql)
|
||||
local result = {}
|
||||
|
||||
-- format data
|
||||
|
|
@ -124,7 +124,7 @@ function vs_db_utils.retrieve_report(epoch)
|
|||
"WHERE REPORT_DATE = %u"
|
||||
sql = string.format(sql,report_table_name, tonumber(epoch))
|
||||
|
||||
local query_result = interface.execSQLQuery(sql)
|
||||
local query_result,err = interface.execSQLQuery(sql)
|
||||
local result = {}
|
||||
local report_info
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ function vs_db_utils.retrieve_report_name(epoch)
|
|||
"WHERE REPORT_DATE = %u"
|
||||
sql = string.format(sql,report_table_name, tonumber(epoch))
|
||||
|
||||
local query_result = interface.execSQLQuery(sql)
|
||||
local query_result,err = interface.execSQLQuery(sql)
|
||||
local report_name
|
||||
|
||||
-- format data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue