X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Frotate.c;h=05e55bf3cc39d1eb8a138641061b33d69f886fc1;hp=5a00d699416b164df72d5d9659e3745e994d7256;hb=dd73d57bb95fae31161ca0781108d166082a06f5;hpb=b867041c62b48e89c9f00430cde4c33f13a2da09 diff --git a/src/bin/lttng/commands/rotate.c b/src/bin/lttng/commands/rotate.c index 5a00d6994..05e55bf3c 100644 --- a/src/bin/lttng/commands/rotate.c +++ b/src/bin/lttng/commands/rotate.c @@ -32,6 +32,7 @@ #include "../command.h" #include +#include static char *opt_session_name; static int opt_no_wait; @@ -100,6 +101,111 @@ end: return ret; } +static int output_trace_archive_location( + const struct lttng_trace_archive_location *location, + const char *session_name) +{ + int ret = 0; + enum lttng_trace_archive_location_type location_type; + enum lttng_trace_archive_location_status status; + bool printed_location = false; + + location_type = lttng_trace_archive_location_get_type(location); + + _MSG("Trace chunk archive for session %s is now readable", + session_name); + switch (location_type) { + case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL: + { + const char *absolute_path; + + status = lttng_trace_archive_location_local_get_absolute_path( + location, &absolute_path); + if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { + ret = -1; + goto end; + } + MSG(" at %s", absolute_path); + ret = mi_output_rotate("completed", absolute_path, + session_name); + if (ret) { + goto end; + } + printed_location = true; + break; + } + case LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY: + { + uint16_t control_port, data_port; + const char *host, *relative_path, *protocol_str; + enum lttng_trace_archive_location_relay_protocol_type protocol; + + /* Fetch all relay location parameters. */ + status = lttng_trace_archive_location_relay_get_protocol_type( + location, &protocol); + if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { + ret = -1; + goto end; + } + + status = lttng_trace_archive_location_relay_get_host( + location, &host); + if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { + ret = -1; + goto end; + } + + status = lttng_trace_archive_location_relay_get_control_port( + location, &control_port); + if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { + ret = -1; + goto end; + } + + status = lttng_trace_archive_location_relay_get_data_port( + location, &data_port); + if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { + ret = -1; + goto end; + } + + status = lttng_trace_archive_location_relay_get_relative_path( + location, &relative_path); + if (status != LTTNG_TRACE_ARCHIVE_LOCATION_STATUS_OK) { + ret = -1; + goto end; + } + + switch (protocol) { + case LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP: + protocol_str = "tcp"; + break; + default: + protocol_str = "unknown"; + break; + } + + MSG(" on relay %s://%s/%s [control port %" PRIu16 ", data port %" + PRIu16 "]", protocol_str, host, + relative_path, control_port, data_port); + printed_location = true; + ret = mi_output_rotate("completed", relative_path, + session_name); + if (ret) { + goto end; + } + break; + } + default: + break; + } +end: + if (!printed_location) { + MSG(" at an unknown location"); + } + return ret; +} + static int rotate_tracing(char *session_name) { int ret; @@ -176,17 +282,15 @@ static int rotate_tracing(char *session_name) switch (rotation_state) { case LTTNG_ROTATION_STATE_COMPLETED: { - const char *path; + const struct lttng_trace_archive_location *location; - rotation_status = lttng_rotation_handle_get_completed_archive_location( - handle, &path); + rotation_status = lttng_rotation_handle_get_archive_location( + handle, &location); if (rotation_status != LTTNG_ROTATION_STATUS_OK) { ERR("Failed to retrieve the rotation's completed chunk archive location"); goto error; } - MSG("Trace chunk archive for session %s is now readable at %s", - session_name, path); - ret = mi_output_rotate("completed", path, session_name); + ret = output_trace_archive_location(location, session_name); if (ret) { goto error; }