@@ -38,6 +38,7 @@ 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_show_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);
@@ -372,3 +372,38 @@ int cmd_list_monitor(int argc, const char **argv, void *ctx)
out:
return 1;
}
+
+int cmd_show_monitor(int argc, const char **argv, void *ctx)
+{
+ const struct option options[] = {
+ OPT_STRING('m', "monitor", ¶m.monitor, "monitor name",
+ "monitor name")
+ };
+ const char * const u[] = {
+ "ndctl show-monitor <monitor>",
+ 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;
+ }
+ if (!param.monitor) {
+ error("monitor name --monitor is required\n");
+ goto out;
+ }
+
+ char *filename;
+ filename = get_full_path_filename(proc_path, param.monitor);
+ struct json_object *jmonitors = json_object_from_file(filename);
+ if (jmonitors == NULL) {
+ error("monitor %s is not exist\n", param.monitor);
+ goto out;
+ }
+
+ printf("%s\n", json_object_to_json_string_ext(jmonitors,
+ JSON_C_TO_STRING_PRETTY));
+ return 0;
+out:
+ return 1;
+}
@@ -86,6 +86,7 @@ static struct cmd_struct commands[] = {
{ "inject-error", cmd_inject_error },
{ "create-monitor", cmd_create_monitor },
{ "list-monitor", cmd_list_monitor },
+ { "show-monitor", cmd_show_monitor },
{ "list", cmd_list },
{ "help", cmd_help },
#ifdef ENABLE_TEST
This patch is used to add $ndctl show-monitor command, by which users can check the specific of a monitor. Example: $ndctl show-monitor --monitor m_nmem1 Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com> --- builtin.h | 1 + ndctl/monitor.c | 35 +++++++++++++++++++++++++++++++++++ ndctl/ndctl.c | 1 + 3 files changed, 37 insertions(+)