summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/lua/bayes_expiry.lua32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua
index dc580a6b3..ea7ae1a9f 100644
--- a/src/plugins/lua/bayes_expiry.lua
+++ b/src/plugins/lua/bayes_expiry.lua
@@ -239,12 +239,14 @@ local expiry_script = [[
local cur = 0
local c_data = {0,0,0,0,0,0,0,0,0};
+local step = 0
local function expire_step(cls, ev_base, worker)
local function redis_step_cb(err, data)
if err then
logger.errx(rspamd_config, 'cannot perform expiry step: %s', err)
elseif type(data) == 'table' then
+ step = step + 1
for k,v in pairs(data) do data[k] = tonumber(v) end
cur = table.remove(data, 1)
@@ -259,21 +261,33 @@ local function expire_step(cls, ev_base, worker)
end
local function log_stat(cycle)
+ local mode = settings.lazy and ' (lazy)' or ''
+ local significant_action = (settings.lazy or cls.expiry < 0) and 'made persistent' or 'extended'
+ local infrequent_action = (cls.expiry < 0) and 'made persistent' or 'ttls set'
+
+ local d = cycle and {
+ 'cycle in ' .. step .. ' steps', mode, c_data[1],
+ c_data[7], c_data[2], significant_action,
+ c_data[6], c_data[3],
+ c_data[8], c_data[9], infrequent_action,
+ math.floor(.5 + c_data[4] / c_data[1]),
+ math.floor(.5 + math.sqrt(c_data[5] / c_data[1]))
+ } or {
+ 'step ' .. step, mode, data[1],
+ data[7], data[2], significant_action,
+ data[6], data[3],
+ data[8], data[9], infrequent_action,
+ data[4],
+ data[5]
+ }
logger.infox(rspamd_config, 'finished expiry %s%s: %s items checked, %s significant (%s %s), %s common (%s discriminated), %s infrequent (%s %s), %s mean, %s std',
- cycle and 'cycle' or 'step',
- settings.lazy and ' (lazy)' or '',
- c_data[1], c_data[7], c_data[2],
- (settings.lazy or cls.expiry < 0) and 'made persistent' or 'extended',
- c_data[6], c_data[3], data[8], data[9],
- (cls.expiry < 0) and 'made persistent' or 'ttls set',
- cycle and math.floor(.5 + c_data[4] / c_data[1]) or data[4],
- cycle and math.floor(.5 + math.sqrt(c_data[5] / c_data[1])) or data[5]
- )
+ lutil.unpack(d))
end
log_stat(false)
if cur == 0 then
log_stat(true)
c_data = {0,0,0,0,0,0,0,0,0};
+ step = 0
end
end
end