diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-25 10:29:38 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-25 10:29:38 +0000 |
commit | b373c5e17b7c3aceb15cdecef5c64775725b533e (patch) | |
tree | a69daad2c944b5e3f3fdcd4d6fd6ed325752c433 /lualib | |
parent | cd5ed04fdaf1bfe6ba13dbc6b2cf39fd3361be3b (diff) | |
download | rspamd-b373c5e17b7c3aceb15cdecef5c64775725b533e.tar.gz rspamd-b373c5e17b7c3aceb15cdecef5c64775725b533e.zip |
[Feature] Show stats in rspamadm
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/rspamadm/fuzzy_stat.lua | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lualib/rspamadm/fuzzy_stat.lua b/lualib/rspamadm/fuzzy_stat.lua index ef8a5de08..b9af35e22 100644 --- a/lualib/rspamadm/fuzzy_stat.lua +++ b/lualib/rspamadm/fuzzy_stat.lua @@ -59,7 +59,23 @@ local function add_data(target, src) if type(v.extensions.name) == 'string' then target.name = v.extensions.name end + if type(v.extensions.email) == 'string' then + target.email = v.extensions.email + end + if type(v.extensions.ratelimit) == 'table' then + if not target.ratelimit then + target.ratelimit = {} + end + -- Passed as {burst = x, rate = y} + target.ratelimit.limit = v.extensions.ratelimit + end + end + elseif k == 'ratelimit' then + if not target.ratelimit then + target.ratelimit = {} end + -- Ratelimit is passed as {cur = count, last = time} + target.ratelimit.cur = v end end end @@ -301,7 +317,8 @@ return function(args, res) for _, key in ipairs(sorted_keys) do local key_stat = key.data if key_stat.name then - print(string.format('Key id: %s, name: %s', key.key, key_stat.name)) + print(string.format('Key id: %s, name: %s (email: %s)', key.key, key_stat.name, + key_stat.email or 'unknown')) else print(string.format('Key id: %s', key.key)) end @@ -332,6 +349,16 @@ return function(args, res) end end + if key_stat.ratelimit then + print('') + print('\tRatelimit stat:') + print(string.format('\tLimit: %s (%s leak rate)', + print_num(key_stat.ratelimit.limit.burst), print_num(key_stat.ratelimit.limit.rate))) + print(string.format('\tCurrent: %s (%s last)', + print_num(key_stat.ratelimit.cur), os.date('%c', key_stat.ratelimit.last))) + print('') + end + print('') end end |