]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Output errors by IP
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 19 Dec 2015 21:27:20 +0000 (21:27 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 19 Dec 2015 21:27:20 +0000 (21:27 +0000)
src/rspamadm/fuzzy_stat.lua

index 3b56f9c1b3aa341a69069b460d3aa6306d96f8c1..69b39be9a3b6d86611a04ace2a663bfbda8ba33e 100644 (file)
@@ -166,8 +166,20 @@ return function(args, res)
 
           -- General stats
           for k,v in pairs(pr['data']) do
-            if k ~= 'keys' then
+            if k ~= 'keys' and k ~= 'errors_ips' then
               res_db[k] = add_result(res_db[k], v, k)
+            elseif k == 'errors_ips' then
+              -- Errors ips
+              if not res_db['errors_ips'] then
+                res_db['errors_ips'] = {}
+              end
+              for ip,nerrors in pairs(v) do
+                if not errors_ips[ip] then
+                  res_db['errors_ips'][ip] = nerrors
+                else
+                  res_db['errors_ips'][ip] = nerrors + res_db['errors_ips'][ip]
+                end
+              end
             end
           end
 
@@ -206,7 +218,7 @@ return function(args, res)
     print(string.format('Statistics for storage %s', db))
 
     for k,v in pairs(st) do
-      if k ~= 'keys' then
+      if k ~= 'keys' and k ~= 'errors_ips' then
         print(string.format('%s: %s', k, print_result(v)))
       end
     end
@@ -234,7 +246,14 @@ return function(args, res)
         print('')
       end
     end
-
+    if st['errors_ips'] and not opts['no-ips'] and not opts['short'] then
+      print('')
+      print('Errors IPs statistics:')
+      local sorted_ips = sort_ips(st['errors_ips'], opts)
+      for i, v in ipairs(sorted_ips) do
+        print(string.format('%s: %s', v['ip'], print_result(v['data'])))
+      end
+    end
   end
 
   if not opts['no-ips'] and not opts['short'] then