rotation-api: pass session name explicitly
[lttng-tools.git] / src / bin / lttng / commands / list.c
index a166fd2b31c6e91d80a9c169c7e90bbd9bdccc31..e05134cbb2d518f6f1dbfcea9ffa0fc151fd71e8 100644 (file)
@@ -1520,6 +1520,57 @@ end:
        return ret;
 }
 
+/*
+ * List the rotate settings (timer/size if any).
+ */
+static int list_rotate_settings(const char *session_name)
+{
+       int ret;
+       uint64_t size, timer;
+
+       ret = lttng_rotation_schedule_get_timer_period(session_name, &timer);
+       if (ret) {
+               goto end;
+       }
+
+       ret = lttng_rotation_schedule_get_size(session_name, &size);
+       if (ret) {
+               goto end;
+       }
+
+       if (!timer && !size) {
+               ret = 0;
+               goto end;
+       }
+
+       _MSG("Automatic rotation schedule settings:\n");
+
+       if (timer) {
+               _MSG("    timer period: %" PRIu64" µs\n", timer);
+               if (lttng_opt_mi) {
+                       ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                                       config_element_rotation_timer_interval, timer);
+                       if (ret) {
+                               goto end;
+                       }
+               }
+       }
+       if (size) {
+               _MSG("    size threshold:  %" PRIu64" bytes\n", size);
+               if (lttng_opt_mi) {
+                       ret = mi_lttng_writer_write_element_unsigned_int(writer,
+                                       config_element_rotation_size, size);
+                       if (ret) {
+                               goto end;
+                       }
+               }
+       }
+       _MSG("\n");
+
+end:
+       return ret;
+}
+
 /*
  * Machine interface
  * Find the session with session_name as name
@@ -1776,7 +1827,7 @@ end:
 int cmd_list(int argc, const char **argv)
 {
        int opt, ret = CMD_SUCCESS;
-       const char *session_name;
+       const char *session_name, *leftover = NULL;
        static poptContext pc;
        struct lttng_domain domain;
        struct lttng_domain *domains = NULL;
@@ -1837,6 +1888,13 @@ int cmd_list(int argc, const char **argv)
        session_name = poptGetArg(pc);
        DBG2("Session name: %s", session_name);
 
+       leftover = poptGetArg(pc);
+       if (leftover) {
+               ERR("Unknown argument: %s", leftover);
+               ret = CMD_ERROR;
+               goto end;
+       }
+
        if (opt_kernel) {
                domain.type = LTTNG_DOMAIN_KERNEL;
        } else if (opt_userspace) {
@@ -1918,6 +1976,11 @@ int cmd_list(int argc, const char **argv)
                        goto end;
                }
 
+               ret = list_rotate_settings(session_name);
+               if (ret) {
+                       goto end;
+               }
+
                /* Domain listing */
                if (opt_domain) {
                        ret = list_domains(session_name);
This page took 0.023548 seconds and 4 git commands to generate.