Include lttng-ctl apps for liblttng-ctl testing
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 22 Nov 2017 19:09:44 +0000 (14:09 -0500)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 22 Nov 2017 19:09:44 +0000 (14:09 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
lttng_ivc/apps/lttng-ctl/channels_ctl/Makefile [new file with mode: 0644]
lttng_ivc/apps/lttng-ctl/channels_ctl/app [new file with mode: 0755]
lttng_ivc/apps/lttng-ctl/channels_ctl/app.c [new file with mode: 0644]
lttng_ivc/apps/lttng-ctl/events_ctl/Makefile [new file with mode: 0644]
lttng_ivc/apps/lttng-ctl/events_ctl/app [new file with mode: 0755]
lttng_ivc/apps/lttng-ctl/events_ctl/app.c [new file with mode: 0644]

diff --git a/lttng_ivc/apps/lttng-ctl/channels_ctl/Makefile b/lttng_ivc/apps/lttng-ctl/channels_ctl/Makefile
new file mode 100644 (file)
index 0000000..2cbe921
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (C) 2017  Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+#
+# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+# OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+#
+# Permission is hereby granted to use or copy this program for any
+# purpose,  provided the above notices are retained on all copies.
+# Permission to modify the code and to distribute modified code is
+# granted, provided the above notices are retained, and a notice that
+# the code was modified is included with the above copyright notice.
+
+LIBS = -llttng-ctl
+LOCAL_CPPFLAGS += -I.
+
+all: app
+
+.PHONY: app
+
+app: app.o
+       $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ $(LIBS)
+
+app.o: app.c
+       $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(LTTNG_CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+
+
diff --git a/lttng_ivc/apps/lttng-ctl/channels_ctl/app b/lttng_ivc/apps/lttng-ctl/channels_ctl/app
new file mode 100755 (executable)
index 0000000..18aa4a8
Binary files /dev/null and b/lttng_ivc/apps/lttng-ctl/channels_ctl/app differ
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 (file)
index 0000000..05a8d4e
--- /dev/null
@@ -0,0 +1,143 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <inttypes.h>
+#include <lttng/lttng.h>
+
+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;
+}
diff --git a/lttng_ivc/apps/lttng-ctl/events_ctl/Makefile b/lttng_ivc/apps/lttng-ctl/events_ctl/Makefile
new file mode 100644 (file)
index 0000000..2cbe921
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (C) 2017  Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+#
+# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+# OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+#
+# Permission is hereby granted to use or copy this program for any
+# purpose,  provided the above notices are retained on all copies.
+# Permission to modify the code and to distribute modified code is
+# granted, provided the above notices are retained, and a notice that
+# the code was modified is included with the above copyright notice.
+
+LIBS = -llttng-ctl
+LOCAL_CPPFLAGS += -I.
+
+all: app
+
+.PHONY: app
+
+app: app.o
+       $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ $(LIBS)
+
+app.o: app.c
+       $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(LTTNG_CPPFLAGS) $(CFLAGS) -c -o $@ $<
+
+
+
diff --git a/lttng_ivc/apps/lttng-ctl/events_ctl/app b/lttng_ivc/apps/lttng-ctl/events_ctl/app
new file mode 100755 (executable)
index 0000000..0873364
Binary files /dev/null and b/lttng_ivc/apps/lttng-ctl/events_ctl/app differ
diff --git a/lttng_ivc/apps/lttng-ctl/events_ctl/app.c b/lttng_ivc/apps/lttng-ctl/events_ctl/app.c
new file mode 100644 (file)
index 0000000..563fa65
--- /dev/null
@@ -0,0 +1,142 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <lttng/lttng.h>
+
+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_event(struct lttng_event *event)
+{
+       int ret = -1;
+
+       /* Exclusion related lttng-ctl call */
+       ret = lttng_event_get_exclusion_name_count(event);
+       if (ret < 0) {
+               ret = 1;
+               goto end;
+       }
+       if (ret > 0) {
+               int count = ret;
+               for (int i = 0; i < count ; i++) {
+                       const char *name;
+                       ret = lttng_event_get_exclusion_name(event, i , &name);
+                       if (ret) {
+                               ret = 1;
+                               goto end;
+                       }
+                       printf("exclusion name: %s\n", name);
+               }
+       }
+
+       /* Filet expression related lttng-ctl call */
+       const char *filter_str;
+       ret = lttng_event_get_filter_expression(event, &filter_str);
+       if (ret) {
+               ret = 1;
+               goto end;
+       }
+
+       printf("filter expression: %s\n", filter_str);
+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;
+
+       /* Event related variables */
+       struct lttng_event *events = NULL;
+
+
+       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;
+       }
+
+       /* List events */
+       ret = lttng_list_events(handle, channel_name, &events);
+       if (ret <= 0) {
+               printf("No events found for channel %s in session %s\n", channel_name, session_name);
+       }
+
+       for (int i = 0; i < ret; i++) {
+               ret = process_event(&events[i]);
+               if (ret) {
+                       printf("Error while processing event \n");
+                       ret = 1;
+                       goto end;
+               }
+       }
+
+end:
+       free(events);
+       free(channels);
+       free(domains);
+       if (handle) {
+               lttng_destroy_handle(handle);
+       }
+       return 0;
+}
This page took 0.027925 seconds and 5 git commands to generate.