diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-27 18:16:11 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-27 18:16:11 +0100 |
commit | 79052d53a490c8f1122f15e5e75465c6653d9b1a (patch) | |
tree | 7b2785850845a9b68b8cc9b7f34e1472c815fcaa /src/controller.c | |
parent | 37965fd580c62d8b246e33f9d7b4c315c6d1cd06 (diff) | |
download | rspamd-79052d53a490c8f1122f15e5e75465c6653d9b1a.tar.gz rspamd-79052d53a490c8f1122f15e5e75465c6653d9b1a.zip |
[Feature] Allow to query storage about number of fuzzy hashes stored
Diffstat (limited to 'src/controller.c')
-rw-r--r-- | src/controller.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/controller.c b/src/controller.c index 1021939ae..085eda5d4 100644 --- a/src/controller.c +++ b/src/controller.c @@ -24,6 +24,7 @@ #include "libserver/worker_util.h" #include "cryptobox.h" #include "ottery.h" +#include "fuzzy_storage.h" #include "libutil/rrd.h" #include "unix-std.h" #include "utlist.h" @@ -103,6 +104,8 @@ const struct timeval rrd_update_time = { const guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL; +extern void fuzzy_stat_command (struct rspamd_task *task); + gpointer init_controller_worker (struct rspamd_config *cfg); void start_controller_worker (struct rspamd_worker *worker); @@ -1925,7 +1928,9 @@ rspamd_controller_stat_fin_task (void *ud) { struct rspamd_stat_cbdata *cbdata = ud; struct rspamd_http_connection_entry *conn_ent; - ucl_object_t *top; + ucl_object_t *top, *ar; + GList *fuzzy_elts, *cur; + struct rspamd_fuzzy_stat_entry *entry; conn_ent = cbdata->conn_ent; top = cbdata->top; @@ -1937,6 +1942,23 @@ rspamd_controller_stat_fin_task (void *ud) ucl_object_insert_key (top, cbdata->stat, "statfiles", 0, false); } + fuzzy_elts = rspamd_mempool_get_variable (cbdata->task->task_pool, "fuzzy_stat"); + + if (fuzzy_elts) { + ar = ucl_object_typed_new (UCL_OBJECT); + + for (cur = fuzzy_elts; cur != NULL; cur = g_list_next (cur)) { + entry = cur->data; + + if (entry->name) { + ucl_object_insert_key (ar, ucl_object_fromint (entry->fuzzy_cnt), + entry->name, 0, true); + } + } + + ucl_object_insert_key (top, ar, "fuzzy_hashes", 0, false); + } + rspamd_controller_send_ucl (conn_ent, top); @@ -2064,6 +2086,8 @@ rspamd_controller_handle_stat_common ( rspamd_mempool_stat_reset (); } + fuzzy_stat_command (task); + /* Now write statistics for each statfile */ rspamd_stat_statistics (task, session->ctx->cfg, &cbdata->learned, &cbdata->stat); |