diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-12-12 20:27:03 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-12-12 20:27:03 +0000 |
commit | f3587ce1bebb7fcaf529f796dbcec6e436253c05 (patch) | |
tree | fb3ca9d57eacb4426534f2019dbc408cf3aab7d0 | |
parent | 3617535f341e5ea4df04b94e10f78c1f9ee5e814 (diff) | |
download | rspamd-f3587ce1bebb7fcaf529f796dbcec6e436253c05.tar.gz rspamd-f3587ce1bebb7fcaf529f796dbcec6e436253c05.zip |
[Minor] Add ability to log mempool usage for a task
-rw-r--r-- | src/libserver/cfg_file.h | 2 | ||||
-rw-r--r-- | src/libserver/cfg_utils.c | 6 | ||||
-rw-r--r-- | src/libserver/task.c | 12 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index fbddd9096..8e1ce2c42 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -262,6 +262,8 @@ enum rspamd_log_format_type { RSPAMD_LOG_SETTINGS_ID, RSPAMD_LOG_GROUPS, RSPAMD_LOG_PUBLIC_GROUPS, + RSPAMD_LOG_MEMPOOL_SIZE, + RSPAMD_LOG_MEMPOOL_WASTE, }; enum rspamd_log_format_flags { diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 857f7a0ac..76731eec4 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -518,6 +518,12 @@ rspamd_config_process_var (struct rspamd_config *cfg, const rspamd_ftok_t *var, else if (rspamd_ftok_cstr_equal (&tok, "settings_id", TRUE)) { type = RSPAMD_LOG_SETTINGS_ID; } + else if (rspamd_ftok_cstr_equal (&tok, "mempool_size", TRUE)) { + type = RSPAMD_LOG_MEMPOOL_SIZE; + } + else if (rspamd_ftok_cstr_equal (&tok, "mempool_waste", TRUE)) { + type = RSPAMD_LOG_MEMPOOL_WASTE; + } else { msg_err_config ("unknown log variable: %T", &tok); return FALSE; diff --git a/src/libserver/task.c b/src/libserver/task.c index 2fb9bf1d9..7cdce32f3 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -1544,6 +1544,18 @@ rspamd_task_log_variable (struct rspamd_task *task, var.len = sizeof (undef) - 1; } break; + case RSPAMD_LOG_MEMPOOL_SIZE: + var.len = rspamd_snprintf (numbuf, sizeof (numbuf), + "%Hz", + task->task_pool->used_memory); + var.begin = numbuf; + break; + case RSPAMD_LOG_MEMPOOL_WASTE: + var.len = rspamd_snprintf (numbuf, sizeof (numbuf), + "%Hz", + task->task_pool->wasted_memory); + var.begin = numbuf; + break; default: var = rspamd_task_log_metric_res (task, lf); break; |