X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=e05134cbb2d518f6f1dbfcea9ffa0fc151fd71e8;hp=942e4a4c2c3f46a4e48ff1ce3d246b15e5f95deb;hb=dbd512ea8aa5349849aeeccda6130aa9e28cf23c;hpb=491d15395b58df09f8a3e7ba7404eb1f46392b79 diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 942e4a4c2..e05134cbb 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -57,6 +57,9 @@ enum { static struct lttng_handle *handle; static struct mi_writer *writer; +/* Only set when listing a single session. */ +static struct lttng_session listed_session; + static struct poptOption long_options[] = { /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, @@ -1148,7 +1151,7 @@ static int list_events(const char *channel_name) } } else { /* Pretty print */ - MSG("\n%sEvents:", indent4); + MSG("\n%sEvent rules:", indent4); if (count == 0) { MSG("%sNone\n", indent6); goto end; @@ -1166,6 +1169,23 @@ error: return ret; } +static +void print_timer(const char *timer_name, uint32_t space_count, int64_t value) +{ + uint32_t i; + + _MSG("%s%s:", indent6, timer_name); + for (i = 0; i < space_count; i++) { + _MSG(" "); + } + + if (value) { + MSG("%" PRId64 " µs", value); + } else { + MSG("inactive"); + } +} + /* * Pretty print channel */ @@ -1204,27 +1224,67 @@ static void print_channel(struct lttng_channel *channel) } MSG("- %s:%s\n", channel->name, enabled_string(channel->enabled)); - MSG("%sAttributes:", indent4); - MSG("%soverwrite mode: %d", indent6, channel->attr.overwrite); - MSG("%ssubbuffers size: %" PRIu64, indent6, channel->attr.subbuf_size); - MSG("%snumber of subbuffers: %" PRIu64, indent6, channel->attr.num_subbuf); - MSG("%sswitch timer interval: %u", indent6, channel->attr.switch_timer_interval); - MSG("%sread timer interval: %u", indent6, channel->attr.read_timer_interval); - MSG("%smonitor timer interval: %" PRIu64, indent6, monitor_timer_interval); - MSG("%sblocking timeout (µs): %" PRId64, indent6, blocking_timeout); - MSG("%strace file count: %" PRIu64, indent6, channel->attr.tracefile_count); - MSG("%strace file size (bytes): %" PRIu64, indent6, channel->attr.tracefile_size); - MSG("%sdiscarded events: %" PRIu64, indent6, discarded_events); - MSG("%slost packets: %" PRIu64, indent6, lost_packets); + MSG("%sEvent-loss mode: %s", indent6, channel->attr.overwrite ? "overwrite" : "discard"); + MSG("%sSub-buffer size: %" PRIu64 " bytes", indent6, channel->attr.subbuf_size); + MSG("%sSub-buffer count: %" PRIu64, indent6, channel->attr.num_subbuf); + + print_timer("Switch timer", 5, channel->attr.switch_timer_interval); + print_timer("Read timer", 7, channel->attr.read_timer_interval); + print_timer("Monitor timer", 4, monitor_timer_interval); + + if (!channel->attr.overwrite) { + if (blocking_timeout == -1) { + MSG("%sBlocking timeout: infinite", indent6); + } else { + MSG("%sBlocking timeout: %" PRId64 " µs", indent6, blocking_timeout); + } + } + + MSG("%sTrace file count: %" PRIu64 " per stream", indent6, + channel->attr.tracefile_count == 0 ? + 1 : channel->attr.tracefile_count); + if (channel->attr.tracefile_size != 0 ) { + MSG("%sTrace file size: %" PRIu64 " bytes", indent6, + channel->attr.tracefile_size); + } else { + MSG("%sTrace file size: %s", indent6, "unlimited"); + } switch (channel->attr.output) { case LTTNG_EVENT_SPLICE: - MSG("%soutput: splice()", indent6); + MSG("%sOutput mode: splice", indent6); break; case LTTNG_EVENT_MMAP: - MSG("%soutput: mmap()", indent6); + MSG("%sOutput mode: mmap", indent6); break; } + + MSG("\n%sStatistics:", indent4); + if (listed_session.snapshot_mode) { + /* + * The lost packet count is omitted for sessions in snapshot + * mode as it is misleading: it would indicate the number of + * packets that the consumer could not extract during the + * course of recording the snapshot. It does not have the + * same meaning as the "regular" lost packet count that + * would result from the consumer not keeping up with + * event production in an overwrite-mode channel. + * + * A more interesting statistic would be the number of + * packets lost between the first and last extracted + * packets of a given snapshot (which prevents most analyses). + */ + MSG("%sNone", indent6); + goto skip_stats_printing; + } + + if (!channel->attr.overwrite) { + MSG("%sDiscarded events: %" PRIu64, indent6, discarded_events); + } else { + MSG("%sLost packets: %" PRIu64, indent6, lost_packets); + } +skip_stats_printing: + return; } /* @@ -1460,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 @@ -1584,6 +1695,8 @@ static int list_sessions(const char *session_name) active_string(sessions[i].enabled), snapshot_string(sessions[i].snapshot_mode)); MSG("%sTrace path: %s\n", indent4, sessions[i].path); + memcpy(&listed_session, &sessions[i], + sizeof(listed_session)); break; } } else { @@ -1593,7 +1706,7 @@ static int list_sessions(const char *session_name) snapshot_string(sessions[i].snapshot_mode)); MSG("%sTrace path: %s", indent4, sessions[i].path); if (sessions[i].live_timer_interval != 0) { - MSG("%sLive timer interval (usec): %u", indent4, + MSG("%sLive timer interval: %u µs", indent4, sessions[i].live_timer_interval); } MSG(""); @@ -1714,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; @@ -1775,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) { @@ -1856,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);