diff options
Diffstat (limited to 'src')
-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; |