projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the written value when listing fields
[lttng-tools.git]
/
src
/
bin
/
lttng
/
commands
/
create.c
diff --git
a/src/bin/lttng/commands/create.c
b/src/bin/lttng/commands/create.c
index 3e7074e02bc0e35f611fb2e9347342159a7234d2..96bb184a7bd63a7c654604326ef50e13a23e3f3b 100644
(file)
--- a/
src/bin/lttng/commands/create.c
+++ b/
src/bin/lttng/commands/create.c
@@
-60,6
+60,13
@@
static struct poptOption long_options[] = {
{0, 0, 0, 0, 0, 0, 0}
};
{0, 0, 0, 0, 0, 0, 0}
};
+/*
+ * Please have a look at src/lib/lttng-ctl/lttng-ctl.c for more information on
+ * why this declaration exists and used ONLY in for this command.
+ */
+extern int _lttng_create_session_ext(const char *name, const char *url,
+ const char *datetime);
+
/*
* usage
*/
/*
* usage
*/
@@
-100,7
+107,7
@@
static void usage(FILE *ofp)
fprintf(ofp, " > file://...\n");
fprintf(ofp, " Local filesystem full path.\n");
fprintf(ofp, "\n");
fprintf(ofp, " > file://...\n");
fprintf(ofp, " Local filesystem full path.\n");
fprintf(ofp, "\n");
- fprintf(ofp, " > net[
4|
6]://...\n");
+ fprintf(ofp, " > net[6]://...\n");
fprintf(ofp, " This will use the default network transport layer which is\n");
fprintf(ofp, " TCP for both control (PORT1) and data port (PORT2).\n");
fprintf(ofp, " The default ports are respectively 5342 and 5343.\n");
fprintf(ofp, " This will use the default network transport layer which is\n");
fprintf(ofp, " TCP for both control (PORT1) and data port (PORT2).\n");
fprintf(ofp, " The default ports are respectively 5342 and 5343.\n");
@@
-245,8
+252,9
@@
error:
static int create_session(void)
{
int ret;
static int create_session(void)
{
int ret;
- char *session_name, *traces_path = NULL, *alloc_path = NULL;
+ char *session_name
= NULL
, *traces_path = NULL, *alloc_path = NULL;
char *alloc_url = NULL, *url = NULL, datetime[16];
char *alloc_url = NULL, *url = NULL, datetime[16];
+ char session_name_date[NAME_MAX], *print_str_url = NULL;
time_t rawtime;
struct tm *timeinfo;
time_t rawtime;
struct tm *timeinfo;
@@
-257,18
+265,31
@@
static int create_session(void)
/* Auto session name creation */
if (opt_session_name == NULL) {
/* Auto session name creation */
if (opt_session_name == NULL) {
- ret = asprintf(&session_name, DEFAULT_SESSION_NAME "%s", datetime);
+ ret = snprintf(session_name_date, sizeof(session_name_date),
+ DEFAULT_SESSION_NAME "-%s", datetime);
if (ret < 0) {
if (ret < 0) {
- PERROR("
as
printf session name");
+ PERROR("
sn
printf session name");
goto error;
}
goto error;
}
- DBG("Auto session name set to %s", session_name);
+ session_name = strdup(DEFAULT_SESSION_NAME);
+ if (session_name == NULL) {
+ PERROR("strdup session name");
+ goto error;
+ }
+ DBG("Auto session name set to %s", session_name_date);
} else {
session_name = opt_session_name;
} else {
session_name = opt_session_name;
+ ret = snprintf(session_name_date, sizeof(session_name_date),
+ "%s-%s", session_name, datetime);
+ if (ret < 0) {
+ PERROR("snprintf session name");
+ goto error;
+ }
}
if (opt_no_consumer) {
url = NULL;
}
if (opt_no_consumer) {
url = NULL;
+ print_str_url = "";
} else if (opt_output_path != NULL) {
traces_path = utils_expand_path(opt_output_path);
if (traces_path == NULL) {
} else if (opt_output_path != NULL) {
traces_path = utils_expand_path(opt_output_path);
if (traces_path == NULL) {
@@
-285,10
+306,10
@@
static int create_session(void)
}
/* URL to use in the lttng_create_session() call */
url = alloc_url;
}
/* URL to use in the lttng_create_session() call */
url = alloc_url;
-
MSG("Trace(s) output set to %s", traces_path)
;
+
print_str_url = traces_path
;
} else if (opt_url) { /* Handling URL (-U opt) */
url = opt_url;
} else if (opt_url) { /* Handling URL (-U opt) */
url = opt_url;
-
MSG("Trace(s) output set to %s", url)
;
+
print_str_url = url
;
} else if (opt_ctrl_url == NULL && opt_data_url == NULL) {
/* Auto output path */
alloc_path = config_get_default_path();
} else if (opt_ctrl_url == NULL && opt_data_url == NULL) {
/* Auto output path */
alloc_path = config_get_default_path();
@@
-300,8
+321,9
@@
static int create_session(void)
}
alloc_path = strdup(alloc_path);
}
alloc_path = strdup(alloc_path);
- ret = asprintf(&alloc_url, "file://%s/" DEFAULT_TRACE_DIR_NAME,
- alloc_path);
+ ret = asprintf(&alloc_url,
+ "file://%s/" DEFAULT_TRACE_DIR_NAME "/%s",
+ alloc_path, session_name_date);
if (ret < 0) {
PERROR("asprintf trace dir name");
ret = CMD_FATAL;
if (ret < 0) {
PERROR("asprintf trace dir name");
ret = CMD_FATAL;
@@
-309,14
+331,14
@@
static int create_session(void)
}
url = alloc_url;
}
url = alloc_url;
-
MSG("Trace(s) output set to %s", alloc_url + strlen("file://")
);
+
print_str_url = alloc_url + strlen("file://"
);
}
}
- ret =
lttng_create_session(session_name, url
);
+ ret =
_lttng_create_session_ext(session_name, url, datetime
);
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
switch (-ret) {
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
switch (-ret) {
- case LTT
COMM
_EXIST_SESS:
+ case LTT
NG_ERR
_EXIST_SESS:
WARN("Session %s already exists", session_name);
break;
}
WARN("Session %s already exists", session_name);
break;
}
@@
-324,10
+346,11
@@
static int create_session(void)
}
if (opt_session_name == NULL) {
}
if (opt_session_name == NULL) {
- MSG("Session
created with default name %s", session_nam
e);
+ MSG("Session
%s created.", session_name_dat
e);
} else {
MSG("Session %s created.", session_name);
}
} else {
MSG("Session %s created.", session_name);
}
+ MSG("Traces will be written in %s", print_str_url);
if (opt_ctrl_url || opt_data_url) {
/* Setting up control URI (-C or/and -D opt) */
if (opt_ctrl_url || opt_data_url) {
/* Setting up control URI (-C or/and -D opt) */
@@
-349,6
+372,11
@@
static int create_session(void)
}
}
}
}
+ if (opt_session_name == NULL) {
+ free(session_name);
+ session_name = session_name_date;
+ }
+
/* Init lttng session config */
ret = config_init(session_name);
if (ret < 0) {
/* Init lttng session config */
ret = config_init(session_name);
if (ret < 0) {
@@
-356,10
+384,11
@@
static int create_session(void)
goto error;
}
goto error;
}
+
ret = CMD_SUCCESS;
error:
ret = CMD_SUCCESS;
error:
- if (opt_session_name == NULL) {
+ if (opt_session_name == NULL
&& session_name != session_name_date
) {
free(session_name);
}
free(session_name);
}
This page took
0.025949 seconds
and
4
git commands to generate.