mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Implements slow rrd checks and updates in C
This commit is contained in:
parent
a7ea7f76ed
commit
a0612895fe
9 changed files with 49 additions and 81 deletions
|
|
@ -1969,18 +1969,4 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function driver:isAppendSlow()
|
||||
-- InfluxDB appends are handled in C and are never assumed to be slow
|
||||
return false
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function driver:checkAppendSlow()
|
||||
-- InfluxDB appends are handled in C and are never assumed to be slow
|
||||
return
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return driver
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ local HOST_PREFIX_MAP = {
|
|||
host_pool = "pool:",
|
||||
}
|
||||
local WILDCARD_TAGS = {protocol=1, category=1, l4proto=1}
|
||||
local MAX_AVG_APPEND_DURATION_MS = 20 -- Appends are considered slow if average is slower than this value
|
||||
|
||||
local function get_fname_for_schema(schema, tags)
|
||||
if schema.options.rrd_fname ~= nil then
|
||||
|
|
@ -957,32 +956,4 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function driver:isAppendSlow()
|
||||
-- InfluxDB appends are handled in C and are never assumed to be slow
|
||||
return ntop.getCache("ntopng.cache.rrd.write.slow") == "1"
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function driver:checkAppendSlow()
|
||||
-- Retrieve the stats for all the interface periodic activities (note that
|
||||
-- this function can be called concurrently by multiple thread, each with a
|
||||
-- different interface (already selected and available with interface.<something> methods
|
||||
local periodic_scripts_stats = interface.getPeriodicActivitiesStats()
|
||||
|
||||
for ps_name, ps_stats in pairs(periodic_scripts_stats) do
|
||||
if ps_stats["rrd"] and ps_stats["rrd"]["write"] then
|
||||
-- At least 10 calls to consider the average as significant
|
||||
if ps_stats["rrd"]["write"]["tot_calls"] > 10
|
||||
and ps_stats["rrd"]["write"]["avg_call_duration_ms"] >= MAX_AVG_APPEND_DURATION_MS then
|
||||
-- tprint({info = "ERROR", name = ps_name, ps_stats = ps_stats})
|
||||
ntop.setCache("ntopng.cache.rrd.write.slow", "1", 60 --[[ 1 min TTL --]])
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return driver
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ function ts_utils.append(schema_name, tags_and_metrics, timestamp)
|
|||
return false
|
||||
end
|
||||
|
||||
if((not schema.options.is_critical_ts) and ntop.isDeadlineApproaching()) then
|
||||
if not schema.options.is_critical_ts and (ntop.isDeadlineApproaching() or ntop.rrd_is_slow()) then
|
||||
-- Do not write timeseries if the deadline is approaching.
|
||||
-- traceError(TRACE_NORMAL, TRACE_CONSOLE, "Deadline approaching... [".. schema.name .."]["..formatEpoch(ntop.getDeadline()).."]")
|
||||
return false
|
||||
|
|
@ -270,30 +270,6 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
--! @brief Returns true when the append is slow (e.g., due to a slow disk)
|
||||
--! @return true if the append is slow, false otherwise
|
||||
function ts_utils.isAppendSlow()
|
||||
for _, driver in pairs(ts_utils.listActiveDrivers()) do
|
||||
if driver:isAppendSlow() then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--! @brief Returns true when the append is slow (e.g., due to a slow disk)
|
||||
--! @return true if the append is slow, false otherwise
|
||||
function ts_utils.checkAppendSlow()
|
||||
for _, driver in pairs(ts_utils.listActiveDrivers()) do
|
||||
driver:checkAppendSlow()
|
||||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- Get some default options to use in queries.
|
||||
function ts_utils.getQueryOptions(overrides)
|
||||
return table.merge({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue