@@ -37,6 +37,7 @@ int cmd_init_labels(int argc, const char **argv, void *ctx);
int cmd_check_labels(int argc, const char **argv, void *ctx);
int cmd_inject_error(int argc, const char **argv, void *ctx);
int cmd_create_monitor(int argc, const char **argv, void *ctx);
+int cmd_list_monitor(int argc, const char **argv, void *ctx);
int cmd_list(int argc, const char **argv, void *ctx);
#ifdef ENABLE_TEST
int cmd_test(int argc, const char **argv, void *ctx);
@@ -340,3 +340,35 @@ int cmd_create_monitor(int argc, const char **argv, void *ctx)
out:
return 1;
}
+
+int cmd_list_monitor(int argc, const char **argv, void *ctx)
+{
+ const struct option options[] = {
+ OPT_BOOLEAN('a', "all", ¶m.all, "list all monitors")
+ };
+ const char * const u[] = {
+ "ndctl list-monitor [<options>]",
+ NULL
+ };
+ argc = parse_options(argc, argv, options, u, 0);
+ for (int i = 0; i < argc; i++) {
+ error("unknown parameter \"%s\"\n", argv[i]);
+ goto out;
+ }
+ DIR *dir;
+ struct dirent *ent;
+ dir = opendir("/var/ndctl/monitor/");
+ if (!dir)
+ return -1;
+ while ((ent = readdir(dir)) != NULL)
+ {
+ if (strcmp(ent->d_name, ".") == 0
+ || strcmp(ent->d_name, "..") == 0)
+ continue;
+ printf(" %s\n", ent->d_name);
+ }
+ return 0;
+
+out:
+ return 1;
+}
@@ -85,6 +85,7 @@ static struct cmd_struct commands[] = {
{ "check-labels", cmd_check_labels },
{ "inject-error", cmd_inject_error },
{ "create-monitor", cmd_create_monitor },
+ { "list-monitor", cmd_list_monitor },
{ "list", cmd_list },
{ "help", cmd_help },
#ifdef ENABLE_TEST
This patch adds $ndctl list-monitor command, by which users can list all currently running monitors. Example: $ndctl list-monitor --all Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com> --- builtin.h | 1 + ndctl/monitor.c | 32 ++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + 3 files changed, 34 insertions(+)