X-Git-Url: http://git.efficios.com/?p=deliverable%2Flttng-ivc.git;a=blobdiff_plain;f=lttng_ivc%2Fapps%2Flttng-ctl%2Fchannels_ctl%2Fapp.c;fp=lttng_ivc%2Fapps%2Flttng-ctl%2Fchannels_ctl%2Fapp.c;h=05a8d4ee0830d3e88dd9f62c83afb43a7505818c;hp=0000000000000000000000000000000000000000;hb=b84968566f2f36e2914002aaec9b1b4b84247b38;hpb=80586d0d106070ca47900edef774e4cbbbb002c9 diff --git a/lttng_ivc/apps/lttng-ctl/channels_ctl/app.c b/lttng_ivc/apps/lttng-ctl/channels_ctl/app.c new file mode 100644 index 0000000..05a8d4e --- /dev/null +++ b/lttng_ivc/apps/lttng-ctl/channels_ctl/app.c @@ -0,0 +1,143 @@ +#include +#include +#include +#include +#include +#include +#include + +static enum lttng_domain_type get_domain_type(const char *domain) +{ + if (!strcmp("UST", domain)) { + return LTTNG_DOMAIN_UST; + } else if (!strcmp("KERNEL", domain)) { + return LTTNG_DOMAIN_KERNEL; + } else { + printf("Domain not supported\n"); + assert(0); + } +} + +static int process_channel(struct lttng_channel *channel) +{ + int ret; + uint64_t uint64 = 0; + int64_t int64 = 0; + + + ret = lttng_channel_get_discarded_event_count(channel, &uint64); + if (ret < 0) { + ret = 1; + goto end; + } + printf("discarded_event_count: %" PRIu64 "\n", uint64); + + ret = lttng_channel_get_lost_packet_count(channel, &uint64); + if (ret < 0) { + ret = 1; + goto end; + } + printf("lost packet: %" PRIu64 "\n", uint64); + +#ifdef LTTNG_2_10 + ret = lttng_channel_get_monitor_timer_interval(channel, &uint64); + if (ret < 0) { + ret = 1; + goto end; + } + printf("monitor timer interval: %" PRIu64 "\n", uint64); + + ret = lttng_channel_get_blocking_timeout(channel, &int64); + if (ret < 0) { + ret = 1; + goto end; + } + printf("blocking timeout: %" PRId64 "\n", int64); + + /* Setter */ + ret = lttng_channel_set_blocking_timeout(channel, 100); + if (ret < 0) { + ret = 1; + goto end; + } + + ret = lttng_channel_set_monitor_timer_interval(channel, 100); + if (ret < 0) { + ret = 1; + goto end; + } +#endif /* LTTNG_2_10 */ + +end: + return ret; +} + +int main(int argc, char **argv) +{ +int ret; +bool found; + +if (argc < 4) { +printf("missing parameters, session name, channel name, domain type\n"); +return 1; +} + +const char *session_name = argv[1]; +const char *channel_name = argv[2]; +const char *domain_str = argv[3]; + +/* Domain related variables */ +enum lttng_domain_type domain_type = LTTNG_DOMAIN_NONE; +struct lttng_domain *domains = NULL; +struct lttng_domain domain; +int domain_index = -1; + +/* Channel related variables */ +struct lttng_channel *channels = NULL; +int channel_index = -1; + +struct lttng_handle *handle = NULL; + +/* Find the domain we are interested in */ +domain_type = get_domain_type(domain_str); +ret = lttng_list_domains(session_name, &domains); +for (int i = 0; i < ret; i++) { + if (domains[i].type == domain_type) { + domain_index = i; + } + } + + if (domain_index < 0) { + printf("domain not found for session %s\n", session_name); + ret = 1; + goto end; + } + + /* Get the handle */ + + handle = lttng_create_handle(session_name, &domains[domain_index]); + + /* Find the channel we are interested in */ + ret = lttng_list_channels(handle, &channels); + for (int i = 0; i < ret; i++) { + if (!strcmp(channels[i].name, channel_name)) { + channel_index = i; + } + } + + if (channel_index < 0) { + printf("channel not found for session %s\n", session_name); + ret = 1; + goto end; + } + + ret = process_channel(&channels[channel_index]); + +end: + free(channels); + free(domains); + if (handle) { + lttng_destroy_handle(handle); + } + return 0; +}