LTTNG_HIDDEN int mi_lttng_channel_attr(struct mi_writer *writer, struct lttng_channel_attr *attr) { int ret = 0; struct lttng_channel *chan = caa_container_of(attr, struct lttng_channel, attr); uint64_t discarded_events, lost_packets, monitor_timer_interval; int64_t blocking_timeout; assert(attr); ret = lttng_channel_get_discarded_event_count(chan, &discarded_events); if (ret) { goto end; } ret = lttng_channel_get_lost_packet_count(chan, &lost_packets); if (ret) { goto end; } ret = lttng_channel_get_monitor_timer_interval(chan, &monitor_timer_interval); if (ret) { goto end; } ret = lttng_channel_get_blocking_timeout(chan, &blocking_timeout); if (ret) { goto end; } /* Opening Attributes */ ret = mi_lttng_writer_open_element(writer, config_element_attributes); if (ret) { goto end; } /* Overwrite */ ret = mi_lttng_writer_write_element_string(writer, config_element_overwrite_mode, attr->overwrite ? config_overwrite_mode_overwrite : config_overwrite_mode_discard); if (ret) { goto end; } /* Sub buffer size in byte */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_subbuf_size, attr->subbuf_size); if (ret) { goto end; } /* Number of subbuffer (power of two) */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_num_subbuf, attr->num_subbuf); if (ret) { goto end; } /* Switch timer interval in usec */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_switch_timer_interval, attr->switch_timer_interval); if (ret) { goto end; } /* Read timer interval in usec */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_read_timer_interval, attr->read_timer_interval); if (ret) { goto end; } /* Monitor timer interval in usec */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_monitor_timer_interval, monitor_timer_interval); if (ret) { goto end; } /* Retry timeout in usec */ ret = mi_lttng_writer_write_element_signed_int(writer, config_element_blocking_timeout, blocking_timeout); if (ret) { goto end; } /* Event output */ ret = mi_lttng_writer_write_element_string(writer, config_element_output_type, attr->output == LTTNG_EVENT_SPLICE ? config_output_type_splice : config_output_type_mmap); if (ret) { goto end; } /* Tracefile size in bytes */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_tracefile_size, attr->tracefile_size); if (ret) { goto end; } /* Count of tracefiles */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_tracefile_count, attr->tracefile_count); if (ret) { goto end; } /* Live timer interval in usec*/ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_live_timer_interval, attr->live_timer_interval); if (ret) { goto end; } /* Discarded events */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_discarded_events, discarded_events); if (ret) { goto end; } /* Lost packets */ ret = mi_lttng_writer_write_element_unsigned_int(writer, config_element_lost_packets, lost_packets); if (ret) { goto end; } /* Closing attributes */ ret = mi_lttng_writer_close_element(writer); if (ret) { goto end; } end: return ret; }
/* * Pretty print channel */ static void print_channel(struct lttng_channel *channel) { int ret; uint64_t discarded_events, lost_packets, monitor_timer_interval; int64_t blocking_timeout; ret = lttng_channel_get_discarded_event_count(channel, &discarded_events); if (ret) { ERR("Failed to retrieve discarded event count of channel"); return; } ret = lttng_channel_get_lost_packet_count(channel, &lost_packets); if (ret) { ERR("Failed to retrieve lost packet count of channel"); return; } ret = lttng_channel_get_monitor_timer_interval(channel, &monitor_timer_interval); if (ret) { ERR("Failed to retrieve monitor interval of channel"); return; } ret = lttng_channel_get_blocking_timeout(channel, &blocking_timeout); if (ret) { ERR("Failed to retrieve blocking timeout of channel"); return; } MSG("- %s:%s\n", channel->name, enabled_string(channel->enabled)); MSG("%sAttributes:", indent4); 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 mode: splice", indent6); break; case LTTNG_EVENT_MMAP: 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; }