#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
+#include <string.h>
#define event_list "lttng_statedump_start,lttng_statedump_end," \
"lttng_statedump_process_state,lttng_statedump_file_descriptor," \
}
static
-int start(char *name, int sudo, int local)
+int start(char *name, int sudo, int local, int print)
{
int ret;
char cmd[1024];
goto end;
}
+ if (!print)
+ goto end;
+
if (local) {
ret = sprintf(cmd, "%s lttng list|grep %s|cut -d'(' -f2|cut -d ')' -f1",
(sudo) ? "sudo" : " ", name);
} else {
- ret = sprintf(cmd, "lttngtop -r net://localhost|grep %s|cut -d' ' -f1",
+ ret = sprintf(cmd, "babeltrace -i lttng-live net://localhost|grep %s|cut -d' ' -f1",
name);
}
if (ret < 0) {
return ret;
}
+static
+char *live_path(char *name)
+{
+ FILE *fp;
+ int ret;
+ char path[1035];
+ char cmd[1024];
+ char *out = NULL;
+
+ ret = sprintf(cmd, "lttngtop -r net://localhost|grep %s|cut -d' ' -f1",
+ name);
+ if (ret < 0) {
+ fprintf(stderr, "allocating cmd\n");
+ goto end;
+ }
+
+ fp = popen(cmd, "r");
+ if (fp == NULL) {
+ printf("Failed to run command\n" );
+ goto end;
+ }
+
+ /* Read the output a line at a time - output it. */
+ out = fgets(path, sizeof(path)-1, fp);
+ if (out)
+ out = strdup(path);
+
+ /* close */
+ pclose(fp);
+
+end:
+ return out;
+}
+
static
int destroy(char *name)
{
goto end_free;
}
- ret = start(name, sudo, 1);
+ ret = start(name, sudo, 1, 1);
if (ret < 0) {
goto end_free;
}
return ret;
}
-int destroy_session(char *name)
+int destroy_live_local_session(char *name)
{
return destroy(name);
}
-int create_live_local_session()
+int create_live_local_session(char **session_path, char **session_name, int print)
{
int ret;
char *name;
goto end_free;
}
- ret = start(name, sudo, 0);
+ ret = start(name, sudo, 0, print);
if (ret < 0) {
goto end_free;
}
+ if (session_path)
+ *session_path = live_path(name);
+ if (session_name) {
+ *session_name = name;
+ goto end;
+ }
+
end_free:
free(name);
end:
return ret;
}
-
-/*
-int create_live_local_session();
-int destroy_live_local_session();
-*/
int create_local_session();
int destroy_local_session();
-int create_live_local_session();
-int destroy_live_local_session();
+int create_live_local_session(char **session_path, char **session_name, int print);
+int destroy_live_local_session(char *name);
#endif /* LTTNG_SESSION_H */
ret = create_local_session();
exit(ret);
case OPT_CREATE_LIVE_SESSION:
- ret = create_live_local_session();
+ ret = create_live_local_session(NULL, NULL, 1);
exit(ret);
case OPT_TEXTDUMP:
opt_textdump = 1;
{
int ret;
struct bt_context *bt_ctx = NULL;
+ char *live_session_name = NULL;
init_lttngtop();
ret = parse_options(argc, argv);
if (!opt_input_path && !remote_live && !opt_exec_name) {
/* mmap live */
-#ifdef LTTNGTOP_MMAP_LIVE
- if (opt_textdump) {
- signal(SIGTERM, handle_textdump_sigterm);
- signal(SIGINT, handle_textdump_sigterm);
- }
- mmap_live_loop(bt_ctx);
- pthread_join(timer_thread, NULL);
- quit = 1;
- pthread_join(display_thread, NULL);
-
- lttng_stop_tracing("test");
- lttng_destroy_session("test");
-
- goto end;
-#else
- fprintf(stderr, "[ERROR] Mmap live support not compiled, specify a "
- "trace directory or -r <relayd hostname/IP>\n");
- usage(stdout);
- ret = -1;
- goto end;
-#endif /* LTTNGTOP_MMAP_LIVE */
- } else if (!opt_input_path && remote_live) {
+ ret = create_live_local_session(&opt_relay_hostname,
+ &live_session_name, 0);
+ if (ret < 0)
+ goto end;
+ remote_live = 1;
+ }
+ if (!opt_input_path && remote_live) {
/* network live */
bt_ctx = bt_context_create();
ret = bt_context_add_traces_recursive(bt_ctx, opt_relay_hostname,
goto end;
}
} else {
- //init_lttngtop();
-
bt_ctx = bt_context_create();
ret = bt_context_add_traces_recursive(bt_ctx, opt_input_path, "ctf", NULL);
if (ret < 0) {
if (bt_ctx)
bt_context_put(bt_ctx);
+ if (live_session_name) {
+ ret = destroy_live_local_session(live_session_name);
+ if (ret < 0) {
+ fprintf(stderr, "Error destroying %s\n", live_session_name);
+ }
+ }
+
return ret;
}