From: Vsevolod Stakhov Date: Mon, 4 Dec 2017 07:33:22 +0000 (+0000) Subject: [Feature] Add `-m` flag to configdump to show modules states X-Git-Tag: 1.7.0~372 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40759556db803500b4eaaaf443dff0a94320f209;p=rspamd.git [Feature] Add `-m` flag to configdump to show modules states --- diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c index cf49f4632..d5380bc9d 100644 --- a/src/rspamadm/configdump.c +++ b/src/rspamadm/configdump.c @@ -26,6 +26,7 @@ static gboolean json = FALSE; static gboolean compact = FALSE; static gboolean show_help = FALSE; static gboolean show_comments = FALSE; +static gboolean modules_state = FALSE; static gchar *config = NULL; extern struct rspamd_main *rspamd_main; /* Defined in modules.c */ @@ -54,6 +55,8 @@ static GOptionEntry entries[] = { "Show help as comments for each option", NULL }, {"show-comments", 's', 0, G_OPTION_ARG_NONE, &show_comments, "Show saved comments from the configuration file", NULL }, + {"modules-state", 'm', 0, G_OPTION_ARG_NONE, &modules_state, + "Show modules state only", NULL}, {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL} }; @@ -64,11 +67,12 @@ rspamadm_configdump_help (gboolean full_help) if (full_help) { help_str = "Perform configuration file dump\n\n" - "Usage: rspamadm configdump [-c -j --compact [ [ ...]]]\n" + "Usage: rspamadm configdump [-c [-j --compact -m] [ [ ...]]]\n" "Where options are:\n\n" "-j: output plain json\n" "--compact: output compacted json\n" "-c: config file to test\n" + "-m: show state of modules only\n" "-h: show help for dumped options\n" "--help: shows available options and commands"; } @@ -297,6 +301,19 @@ rspamadm_configdump (gint argc, gchar **argv) } if (ret) { + if (modules_state) { + lua_State *L = cfg->lua_state; + + rspamadm_execute_lua_ucl_subr (L, + argc, + argv, + cfg->rcl_obj, + "plugins_stats"); + + lua_close (L); + + exit (EXIT_SUCCESS); + } /* Output configuration */ if (argc == 1) { rspamadm_dump_section_obj (cfg, cfg->rcl_obj, cfg->doc_strings);