diff options
author | Lucas Rolff <lucas@lucasrolff.com> | 2022-05-02 22:40:13 +0200 |
---|---|---|
committer | Lucas Rolff <lucas@lucasrolff.com> | 2022-05-02 22:40:13 +0200 |
commit | 50bbb389711f7b47dcc6a34772c9040f3c0deeb9 (patch) | |
tree | 31e02fd97a5da20112e40da6a16d4531d670d7ae /src/plugins/lua/metadata_exporter.lua | |
parent | 89f17f72d353f89cbf78d9a8bfcaa1d445519f73 (diff) | |
download | rspamd-50bbb389711f7b47dcc6a34772c9040f3c0deeb9.tar.gz rspamd-50bbb389711f7b47dcc6a34772c9040f3c0deeb9.zip |
[Minor] Add scan_time and hostname to metadata_exporter
Diffstat (limited to 'src/plugins/lua/metadata_exporter.lua')
-rw-r--r-- | src/plugins/lua/metadata_exporter.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index 20d388fef..6316ddc09 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -29,6 +29,7 @@ local rspamd_logger = require "rspamd_logger" local ucl = require "ucl" local E = {} local N = 'metadata_exporter' +local HOSTNAME = rspamd_util.get_hostname() local settings = { pusher_enabled = {}, @@ -75,6 +76,7 @@ local function get_general_metadata(task, flatten, no_content) r.qid = task:get_queue_id() or 'unknown' r.subject = task:get_subject() or 'unknown' r.action = task:get_metric_action('default') + r.rspamd_server = HOSTNAME local s = task:get_metric_score('default')[1] r.score = flatten and string.format('%.2f', s) or s @@ -151,6 +153,18 @@ local function get_general_metadata(task, flatten, no_content) return 'unknown' end end + + local scan_real = task:get_scan_time() + scan_real = math.floor(scan_real * 1000) + if scan_real < 0 then + rspamd_logger.messagex(task, + 'clock skew detected for message: %s ms real sca time (reset to 0)', + scan_real) + scan_real = 0 + end + + r.scan_time = scan_real + if not no_content then r.header_from = process_header('from') r.header_to = process_header('to') |