aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-10 14:43:08 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-10 14:43:08 +0000
commit6da62c074de755c5c0a6da94d519255624d9b02b (patch)
tree5f767a2417b817afe27ce5777cb97929edf298aa /src
parent2097dbc412fff3180ef9469d532a4299c5477856 (diff)
downloadrspamd-6da62c074de755c5c0a6da94d519255624d9b02b.tar.gz
rspamd-6da62c074de755c5c0a6da94d519255624d9b02b.zip
Allow logging of re_cache statistics
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_rcl.c5
-rw-r--r--src/libserver/protocol.c13
3 files changed, 19 insertions, 0 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 36e6371d8..511b18b25 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -247,6 +247,7 @@ struct rspamd_config {
gboolean log_color; /**< output colors for console output */
gboolean log_extended; /**< log extended information */
gboolean log_systemd; /**< special case for systemd logger */
+ gboolean log_re_cache; /**< show statistics about regexps */
gboolean mlock_statfile_pool; /**< use mlock (2) for locking statfiles */
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index bbe241cb1..1999dd351 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1258,6 +1258,11 @@ rspamd_rcl_config_init (void)
G_STRUCT_OFFSET (struct rspamd_config, log_urls),
0);
rspamd_rcl_add_default_handler (sub,
+ "log_re_cache",
+ rspamd_rcl_parse_struct_boolean,
+ G_STRUCT_OFFSET (struct rspamd_config, log_re_cache),
+ 0);
+ rspamd_rcl_add_default_handler (sub,
"debug_ip",
rspamd_rcl_parse_struct_string,
G_STRUCT_OFFSET (struct rspamd_config, debug_ip_map),
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index d6acd6e74..b140ca2c6 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -991,6 +991,7 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
{
struct metric_result *metric_res;
GHashTableIter hiter;
+ const struct rspamd_re_cache_stat *restat;
gpointer h, v;
ucl_object_t *top = NULL;
gdouble required_score;
@@ -1012,6 +1013,18 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
rspamd_task_write_log (task);
+ if (task->cfg->log_re_cache) {
+ restat = rspamd_re_cache_get_stat (task->re_rt);
+ g_assert (restat != NULL);
+ msg_info_task (
+ "regexp statistics: %ud pcre regexps scanned, %ud regexps matched,"
+ " %HL bytes scanned using pcre, %HL bytes scanned total",
+ restat->regexp_checked,
+ restat->regexp_matched,
+ restat->bytes_scanned_pcre,
+ restat->bytes_scanned);
+ }
+
msg->body = rspamd_fstring_sized_new (1000);
if (msg->method < HTTP_SYMBOLS && !RSPAMD_TASK_IS_SPAMC (task)) {