]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add `-m` flag to configdump to show modules states
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Dec 2017 07:33:22 +0000 (07:33 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Dec 2017 07:33:22 +0000 (07:33 +0000)
src/rspamadm/configdump.c

index cf49f463256518661ce7b6a263d7329f58e423db..d5380bc9df0d0b1ec3af7081f7b583d9572ffdb9 100644 (file)
@@ -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 <config_name> -j --compact [<path1> [<path2> ...]]]\n"
+                               "Usage: rspamadm configdump [-c <config_name> [-j --compact -m] [<path1> [<path2> ...]]]\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);