Browse Source

[Feature] Add `-m` flag to configdump to show modules states

tags/1.7.0
Vsevolod Stakhov 6 years ago
parent
commit
40759556db
1 changed files with 18 additions and 1 deletions
  1. 18
    1
      src/rspamadm/configdump.c

+ 18
- 1
src/rspamadm/configdump.c View File

static gboolean compact = FALSE; static gboolean compact = FALSE;
static gboolean show_help = FALSE; static gboolean show_help = FALSE;
static gboolean show_comments = FALSE; static gboolean show_comments = FALSE;
static gboolean modules_state = FALSE;
static gchar *config = NULL; static gchar *config = NULL;
extern struct rspamd_main *rspamd_main; extern struct rspamd_main *rspamd_main;
/* Defined in modules.c */ /* Defined in modules.c */
"Show help as comments for each option", NULL }, "Show help as comments for each option", NULL },
{"show-comments", 's', 0, G_OPTION_ARG_NONE, &show_comments, {"show-comments", 's', 0, G_OPTION_ARG_NONE, &show_comments,
"Show saved comments from the configuration file", NULL }, "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} {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}
}; };




if (full_help) { if (full_help) {
help_str = "Perform configuration file dump\n\n" 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" "Where options are:\n\n"
"-j: output plain json\n" "-j: output plain json\n"
"--compact: output compacted json\n" "--compact: output compacted json\n"
"-c: config file to test\n" "-c: config file to test\n"
"-m: show state of modules only\n"
"-h: show help for dumped options\n" "-h: show help for dumped options\n"
"--help: shows available options and commands"; "--help: shows available options and commands";
} }
} }


if (ret) { 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 */ /* Output configuration */
if (argc == 1) { if (argc == 1) {
rspamadm_dump_section_obj (cfg, cfg->rcl_obj, cfg->doc_strings); rspamadm_dump_section_obj (cfg, cfg->rcl_obj, cfg->doc_strings);

Loading…
Cancel
Save