option for that.
\-U, \-\-set-uri=URL
- Set URL for the enable-consumer destination. It is persistent for the
+ Set URL for the consumer output destination. It is persistent for the
session lifetime. Redo the command to change it. This will set both
data and control URL for network.
\-C, \-\-ctrl-url=URL
Set control path URL. (Must use -D also)
\-D, \-\-data-url=URL
Set data path URL. (Must use -C also)
- \-\-no-consumer
- Don't activate a consumer for this session.
- \-\-disable-consumer
- Disable consumer for this session.
-See \fBenable-consumer\fP command below for the supported URL format.
+.B URL FORMAT:
+
+proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
+
+Supported protocols are (proto):
+> file://...
+ Local filesystem full path.
+
+> net://...
+ This will use the default network transport layer which is TCP for both
+ control (PORT1) and data port (PORT2). The default ports are
+ respectively 5342 and 5343. Note that net[6]:// is not yet supported.
+
+> tcp[6]://...
+ Can only be used with -C and -D together
+
+NOTE: IPv6 address MUST be enclosed in brackets '[]' (rfc2732)
.B EXAMPLES:
.IP
-.IP "\fBenable-consumer\fP [-u|-k] [URL] [OPTIONS]"
-.nf
-Enable a consumer for the tracing session and domain.
-
-By default, every tracing session has a consumer attached to it using the local
-filesystem as output. The trace is written in $HOME/lttng-traces. This command
-allows the user to specify a specific URL after the session was created for a
-specific domain. If no domain is specified, the consumer is applied on all
-domains.
-
-Without options, the behavior is to enable a consumer to the current URL. The
-default URL is the local filesystem at the path of the session mentioned above.
-
-The enable-consumer feature supports both local and network transport. You must
-have a running \fBlttng-relayd(8)\fP for network transmission or any other daemon
-that can understand the streaming protocol of LTTng.
-.fi
-
-.B OPTIONS:
-
-.nf
-\-h, \-\-help
- Show summary of possible options and commands.
-\-\-list-options
- Simple listing of options
-\-s, \-\-session NAME
- Apply on session name
-\-k, \-\-kernel
- Apply for the kernel tracer
-\-u, \-\-userspace
- Apply for the user-space tracer
-
-Using these options, each API call can be controlled individually. For
-instance, \-C does not enable the consumer automatically. You'll need the \-e
-option for that.
-
-\-U, \-\-set-uri=URL
- Set URL for the enable-consumer destination. It is persistent for the
- session lifetime. Redo the command to change it. This will set both
- data and control URL for network.
-\-C, \-\-ctrl-url=URL
- Set control path URL. (Must use -D also)
-\-D, \-\-data-url=URL
- Set data path URL. (Must use -C also)
-\-e, \-\-enable
- Enable consumer
-
-.B URL FORMAT:
-
-proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
-
-Supported protocols are (proto):
-> file://...
- Local filesystem full path.
-
-> net://...
- This will use the default network transport layer which is TCP for both
- control (PORT1) and data port (PORT2). The default ports are
- respectively 5342 and 5343. Note that net[6]:// is not yet supported.
-
-> tcp[6]://...
- Can only be used with -C and -D together
-
-NOTE: IPv6 address MUST be enclosed in brackets '[]' (rfc2732)
-
-.B EXAMPLES:
-
-$ lttng enable-consumer -u net://192.168.1.42
-
-Uses TCP and default ports for user space tracing (-u) where the IP address
-above is the destination machine where the traces will be streamed and a
-\fBlttng-relayd(8)\fP is listening.
-.fi
-
.IP "\fBenable-event\fP NAME[,NAME2,...] [-k|-u] [OPTIONS]"
.nf
Enable tracing event
Apply for the user-space tracer
.fi
-.IP "\fBdisable-consumer\fP [\-k|\-u] [OPTIONS]"
-.nf
-Disable the consumer of a tracing session.
-
-This call MUST be done BEFORE tracing has started.
-.fi
-
-.B OPTIONS:
-
-.nf
-\-h, \-\-help
- Show summary of possible options and commands.
-\-\-list-options
- Simple listing of options
-\-s, \-\-session NAME
- Apply on session name
-\-k, \-\-kernel
- Apply for the kernel tracer
-\-u, \-\-userspace
- Apply for the user-space tracer
-.fi
-
.IP "\fBdisable-event\fP NAME[,NAME2,...] [\-k|\-u] [OPTIONS]"
.nf
Disable tracing event
extern "C" {
#endif
+#ifndef LTTNG_DEPRECATED
+#if defined (__GNUC__) \
+ && ((__GNUC_MAJOR__ == 4) && (__GNUC_MINOR__ >= 5) \
+ || __GNUC_MAJOR__ >= 5)
+#define LTTNG_DEPRECATED(msg) __attribute__((deprecated(msg)))
+#else
+#define LTTNG_DEPRECATED(msg) __attribute__((deprecated))
+#endif /* defined __GNUC__ */
+#endif /* LTTNG_DEPRECATED */
+
enum lttng_error_code {
LTTNG_OK = 10, /* Ok */
LTTNG_ERR_UNK = 11, /* Unknown Error */
LTTNG_ERR_CREATE_DIR_FAIL = 17, /* Create directory fail */
LTTNG_ERR_SESSION_FAIL = 18, /* Create session fail */
LTTNG_ERR_NO_SESSIOND = 19, /* No session daemon available */
- /* 20 */
- /* 21 */
+ LTTNG_ERR_SET_URL = 20, /* Error setting URL */
+ LTTNG_ERR_URL_EXIST = 21, /* URL already exists. */
/* 22 */
LTTNG_ERR_SESS_NOT_FOUND = 23, /* Session by name not found */
/* 24 */
/*
* Enable the consumer for a session and domain.
*/
-extern int lttng_enable_consumer(struct lttng_handle *handle);
+extern LTTNG_DEPRECATED("This call is now obselete.")
+int lttng_enable_consumer(struct lttng_handle *handle);
/*
* Disable consumer for a session and domain.
*/
-extern int lttng_disable_consumer(struct lttng_handle *handle);
+extern LTTNG_DEPRECATED("This call is now obselete.")
+int lttng_disable_consumer(struct lttng_handle *handle);
/*
* Check session daemon health for a specific component.
consumer->type = CONSUMER_DST_NET;
+ if ((uri->stype == LTTNG_STREAM_CONTROL &&
+ consumer->dst.net.control_isset) ||
+ (uri->stype == LTTNG_STREAM_DATA &&
+ consumer->dst.net.data_isset)) {
+ ret = LTTNG_ERR_URL_EXIST;
+ goto error;
+ }
+
/* Set URI into consumer output object */
ret = consumer_set_network_uri(consumer, uri);
if (ret < 0) {
usess = session->ust_session;
ksess = session->kernel_session;
- DBG2("Setting relayd for session %s", session->name);
+ DBG("Setting relayd for session %s", session->name);
rcu_read_lock();
case LTTNG_DOMAIN_KERNEL:
/* Code flow error if we don't have a kernel session here. */
assert(ksess);
-
- /* Create consumer output if none exists */
- consumer = ksess->tmp_consumer;
- if (consumer == NULL) {
- consumer = consumer_copy_output(ksess->consumer);
- if (consumer == NULL) {
- ret = LTTNG_ERR_FATAL;
- goto error;
- }
- /* Trash the consumer subdir, we are about to set a new one. */
- memset(consumer->subdir, 0, sizeof(consumer->subdir));
- ksess->tmp_consumer = consumer;
- }
-
+ assert(ksess->consumer);
+ consumer = ksess->consumer;
break;
case LTTNG_DOMAIN_UST:
/* Code flow error if we don't have a kernel session here. */
assert(usess);
-
- /* Create consumer output if none exists */
- consumer = usess->tmp_consumer;
- if (consumer == NULL) {
- consumer = consumer_copy_output(usess->consumer);
- if (consumer == NULL) {
- ret = LTTNG_ERR_FATAL;
- goto error;
- }
- /* Trash the consumer subdir, we are about to set a new one. */
- memset(consumer->subdir, 0, sizeof(consumer->subdir));
- usess->tmp_consumer = consumer;
- }
-
+ assert(usess->consumer);
+ consumer = usess->consumer;
break;
}
assert(name);
+ /* No URIs is not possible. */
+ if (uris == NULL) {
+ ret = LTTNG_ERR_SESSION_FAIL;
+ goto session_error;
+ }
+
/*
* Verify if the session already exist
*
goto consumer_error;
}
- /*
- * This means that the lttng_create_session call was called with the _path_
- * argument set to NULL.
- */
- if (uris == NULL) {
- /*
- * At this point, we'll skip the consumer URI setup and create a
- * session with a NULL path which will flag the session to NOT spawn a
- * consumer.
- */
- DBG("Create session %s with NO uri, skipping consumer setup", name);
- goto end;
- }
-
- session->start_consumer = 1;
-
ret = cmd_set_consumer_uri(0, session, nb_uri, uris);
if (ret != LTTNG_OK) {
goto consumer_error;
session->consumer->enabled = 1;
-end:
return LTTNG_OK;
consumer_error:
}
}
-/*
- * Command LTTNG_DISABLE_CONSUMER processed by the client thread.
- */
-int cmd_disable_consumer(int domain, struct ltt_session *session)
-{
- int ret;
- struct ltt_kernel_session *ksess = session->kernel_session;
- struct ltt_ust_session *usess = session->ust_session;
- struct consumer_output *consumer;
-
- assert(session);
-
- if (session->enabled) {
- /* Can't disable consumer on an already started session */
- ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
- goto error;
- }
-
- if (!session->start_consumer) {
- ret = LTTNG_ERR_NO_CONSUMER;
- goto error;
- }
-
- switch (domain) {
- case 0:
- DBG("Disable tracing session %s consumer", session->name);
- consumer = session->consumer;
- break;
- case LTTNG_DOMAIN_KERNEL:
- /* Code flow error if we don't have a kernel session here. */
- assert(ksess);
-
- DBG("Disabling kernel consumer");
- consumer = ksess->consumer;
-
- break;
- case LTTNG_DOMAIN_UST:
- /* Code flow error if we don't have a UST session here. */
- assert(usess);
-
- DBG("Disabling UST consumer");
- consumer = usess->consumer;
-
- break;
- default:
- ret = LTTNG_ERR_UNKNOWN_DOMAIN;
- goto error;
- }
-
- if (consumer) {
- consumer->enabled = 0;
- /* Success at this point */
- ret = LTTNG_OK;
- } else {
- ret = LTTNG_ERR_NO_CONSUMER;
- }
-
-error:
- return ret;
-}
-
-/*
- * Command LTTNG_ENABLE_CONSUMER processed by the client thread.
- */
-int cmd_enable_consumer(int domain, struct ltt_session *session)
-{
- int ret;
- struct ltt_kernel_session *ksess = session->kernel_session;
- struct ltt_ust_session *usess = session->ust_session;
- struct consumer_output *consumer = NULL;
-
- assert(session);
-
- /* Can't enable consumer after session started. */
- if (session->enabled) {
- ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
- goto error;
- }
-
- switch (domain) {
- case 0:
- assert(session->consumer);
- consumer = session->consumer;
- break;
- case LTTNG_DOMAIN_KERNEL:
- /* Code flow error if we don't have a kernel session here. */
- assert(ksess);
-
- /*
- * Check if we have already sent fds to the consumer. In that case,
- * the enable-consumer command can't be used because a start trace
- * had previously occured.
- */
- if (ksess->consumer_fds_sent) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- goto error;
- }
-
- consumer = ksess->tmp_consumer;
- if (consumer == NULL) {
- ret = LTTNG_OK;
- /* No temp. consumer output exists. Using the current one. */
- DBG3("No temporary consumer. Using default");
- consumer = ksess->consumer;
- goto error;
- }
-
- switch (consumer->type) {
- case CONSUMER_DST_LOCAL:
- DBG2("Consumer output is local. Creating directory(ies)");
-
- /* Create directory(ies) */
- ret = run_as_mkdir_recursive(consumer->dst.trace_path,
- S_IRWXU | S_IRWXG, session->uid, session->gid);
- if (ret < 0) {
- if (ret != -EEXIST) {
- ERR("Trace directory creation error");
- ret = LTTNG_ERR_FATAL;
- goto error;
- }
- }
- break;
- case CONSUMER_DST_NET:
- DBG2("Consumer output is network. Validating URIs");
- /* Validate if we have both control and data path set. */
- if (!consumer->dst.net.control_isset) {
- ret = LTTNG_ERR_URL_CTRL_MISS;
- goto error;
- }
-
- if (!consumer->dst.net.data_isset) {
- ret = LTTNG_ERR_URL_DATA_MISS;
- goto error;
- }
-
- /* Check established network session state */
- if (session->net_handle == 0) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- ERR("Session network handle is not set on enable-consumer");
- goto error;
- }
-
- break;
- }
-
- /*
- * @session-lock
- * This is race free for now since the session lock is acquired before
- * ending up in this function. No other threads can access this kernel
- * session without this lock hence freeing the consumer output object
- * is valid.
- */
- rcu_read_lock();
- /* Destroy current consumer. We are about to replace it */
- consumer_destroy_output(ksess->consumer);
- rcu_read_unlock();
- ksess->consumer = consumer;
- ksess->tmp_consumer = NULL;
-
- break;
- case LTTNG_DOMAIN_UST:
- /* Code flow error if we don't have a UST session here. */
- assert(usess);
-
- /*
- * Check if we have already sent fds to the consumer. In that case,
- * the enable-consumer command can't be used because a start trace
- * had previously occured.
- */
- if (usess->start_trace) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- goto error;
- }
-
- consumer = usess->tmp_consumer;
- if (consumer == NULL) {
- ret = LTTNG_OK;
- /* No temp. consumer output exists. Using the current one. */
- DBG3("No temporary consumer. Using default");
- consumer = usess->consumer;
- goto error;
- }
-
- switch (consumer->type) {
- case CONSUMER_DST_LOCAL:
- DBG2("Consumer output is local. Creating directory(ies)");
-
- /* Create directory(ies) */
- ret = run_as_mkdir_recursive(consumer->dst.trace_path,
- S_IRWXU | S_IRWXG, session->uid, session->gid);
- if (ret < 0) {
- if (ret != -EEXIST) {
- ERR("Trace directory creation error");
- ret = LTTNG_ERR_FATAL;
- goto error;
- }
- }
- break;
- case CONSUMER_DST_NET:
- DBG2("Consumer output is network. Validating URIs");
- /* Validate if we have both control and data path set. */
- if (!consumer->dst.net.control_isset) {
- ret = LTTNG_ERR_URL_CTRL_MISS;
- goto error;
- }
-
- if (!consumer->dst.net.data_isset) {
- ret = LTTNG_ERR_URL_DATA_MISS;
- goto error;
- }
-
- /* Check established network session state */
- if (session->net_handle == 0) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- DBG2("Session network handle is not set on enable-consumer");
- goto error;
- }
-
- if (consumer->net_seq_index == -1) {
- ret = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
- DBG2("Network index is not set on the consumer");
- goto error;
- }
-
- break;
- }
-
- /*
- * @session-lock
- * This is race free for now since the session lock is acquired before
- * ending up in this function. No other threads can access this kernel
- * session without this lock hence freeing the consumer output object
- * is valid.
- */
- rcu_read_lock();
- /* Destroy current consumer. We are about to replace it */
- consumer_destroy_output(usess->consumer);
- rcu_read_unlock();
- usess->consumer = consumer;
- usess->tmp_consumer = NULL;
-
- break;
- }
-
- session->start_consumer = 1;
-
- /* Enable it */
- if (consumer) {
- consumer->enabled = 1;
- /* Success at this point */
- ret = LTTNG_OK;
- } else {
- /* Should not really happend... */
- ret = LTTNG_ERR_NO_CONSUMER;
- }
-
-error:
- return ret;
-}
-
/*
* Command LTTNG_DATA_PENDING returning 0 if the data is NOT pending meaning
* ready for trace analysis (or anykind of reader) or else 1 for pending data.
/* Consumer commands */
int cmd_register_consumer(struct ltt_session *session, int domain,
const char *sock_path, struct consumer_data *cdata);
-int cmd_disable_consumer(int domain, struct ltt_session *session);
-int cmd_enable_consumer(int domain, struct ltt_session *session);
int cmd_set_consumer_uri(int domain, struct ltt_session *session,
size_t nb_uri, struct lttng_uri *uris);
int cmd_setup_relayd(struct ltt_session *session);
/* Start the kernel consumer daemon */
pthread_mutex_lock(&kconsumer_data.pid_mutex);
if (kconsumer_data.pid == 0 &&
- cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER &&
- cmd_ctx->session->start_consumer) {
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
pthread_mutex_unlock(&kconsumer_data.pid_mutex);
ret = start_consumerd(&kconsumer_data);
if (ret < 0) {
pthread_mutex_lock(&ustconsumer64_data.pid_mutex);
if (consumerd64_bin[0] != '\0' &&
ustconsumer64_data.pid == 0 &&
- cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER &&
- cmd_ctx->session->start_consumer) {
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
pthread_mutex_unlock(&ustconsumer64_data.pid_mutex);
ret = start_consumerd(&ustconsumer64_data);
if (ret < 0) {
/* 32-bit */
if (consumerd32_bin[0] != '\0' &&
ustconsumer32_data.pid == 0 &&
- cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER &&
- cmd_ctx->session->start_consumer) {
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
pthread_mutex_unlock(&ustconsumer32_data.pid_mutex);
ret = start_consumerd(&ustconsumer32_data);
if (ret < 0) {
cmd_ctx->lsm->u.disable.channel_name);
break;
}
- case LTTNG_DISABLE_CONSUMER:
- {
- ret = cmd_disable_consumer(cmd_ctx->lsm->domain.type, cmd_ctx->session);
- break;
- }
case LTTNG_ENABLE_CHANNEL:
{
ret = cmd_enable_channel(cmd_ctx->session, cmd_ctx->lsm->domain.type,
&cmd_ctx->lsm->u.channel.chan, kernel_poll_pipe[1]);
break;
}
- case LTTNG_ENABLE_CONSUMER:
- {
- /*
- * XXX: 0 means that this URI should be applied on the session. Should
- * be a DOMAIN enuam.
- */
- ret = cmd_enable_consumer(cmd_ctx->lsm->domain.type, cmd_ctx->session);
- if (ret != LTTNG_OK) {
- goto error;
- }
-
- if (cmd_ctx->lsm->domain.type == 0) {
- /* Add the URI for the UST session if a consumer is present. */
- if (cmd_ctx->session->ust_session &&
- cmd_ctx->session->ust_session->consumer) {
- ret = cmd_enable_consumer(LTTNG_DOMAIN_UST, cmd_ctx->session);
- } else if (cmd_ctx->session->kernel_session &&
- cmd_ctx->session->kernel_session->consumer) {
- ret = cmd_enable_consumer(LTTNG_DOMAIN_KERNEL,
- cmd_ctx->session);
- }
- }
- break;
- }
case LTTNG_ENABLE_EVENT:
{
ret = cmd_enable_event(cmd_ctx->session, cmd_ctx->lsm->domain.type,
ret = LTTNG_ERR_FATAL;
goto error_asprintf;
}
- new_session->start_consumer = 1;
- } else {
- /* No path indicates that there is no use for a consumer. */
- new_session->start_consumer = 0;
- new_session->path[0] = '\0';
}
/* Init kernel session */
*/
struct consumer_output *consumer;
- /* Indicates whether or not we have to spawn consumer(s) */
- unsigned int start_consumer;
-
/* Did a start command occured before the kern/ust session creation? */
unsigned int started;
};
fprintf(ofp, " -C, --ctrl-url=URL Set control path URL. (Must use -D also)\n");
fprintf(ofp, " -D, --data-url=URL Set data path URL. (Must use -C also)\n");
fprintf(ofp, " --no-consumer Don't activate a consumer for this session.\n");
+ fprintf(ofp, " OBSELETE\n");
fprintf(ofp, " --disable-consumer\n");
fprintf(ofp, " Disable consumer for this session.\n");
+ fprintf(ofp, " OBSELETE\n");
fprintf(ofp, "\n");
fprintf(ofp, "Please refer to the man page (lttng(1)) for more information on network\n");
fprintf(ofp, "streaming mechanisms and explanation of the control and data port\n");
return ret;
}
-/*
- * For a session name, enable the consumer.
- */
-static int enable_consumer(const char *session_name)
-{
- int ret;
- struct lttng_handle *handle;
- struct lttng_domain dom;
-
- assert(session_name);
-
- /*
- * Set handle with the session name and the domain set to 0. This means to
- * the session daemon that the next action applies on the tracing session
- * rather then the domain specific session.
- *
- * XXX: This '0' value should be a domain enum value.
- */
- memset(&dom, 0, sizeof(dom));
-
- handle = lttng_create_handle(session_name, 0);
- if (handle == NULL) {
- ret = CMD_FATAL;
- goto error;
- }
-
- ret = lttng_enable_consumer(handle);
- if (ret < 0) {
- goto error;
- }
-
- MSG("Consumer enabled for session %s", session_name);
-
-error:
- lttng_destroy_handle(handle);
- return ret;
-}
-
-/*
- * For a session name, disable the consumer.
- */
-static int disable_consumer(const char *session_name)
-{
- int ret;
- struct lttng_handle *handle;
-
- assert(session_name);
-
- /*
- * Set handle with the session name and the domain set to 0. This means to
- * the session daemon that the next action applies on the tracing session
- * rather then the domain specific session.
- *
- * XXX: This '0' value should be a domain enum value.
- */
- handle = lttng_create_handle(session_name, 0);
- if (handle == NULL) {
- ret = CMD_FATAL;
- goto error;
- }
-
- ret = lttng_disable_consumer(handle);
- if (ret < 0) {
- goto error;
- }
- free(handle);
-
- MSG("Consumer disabled for session %s", session_name);
-
-error:
- return ret;
-}
-
/*
* Create a tracing session.
* If no name is specified, a default name is generated.
}
}
- if (opt_no_consumer) {
- url = NULL;
- print_str_url = "";
- } else if (opt_output_path != NULL) {
+ if (opt_output_path != NULL) {
traces_path = utils_expand_path(opt_output_path);
if (traces_path == NULL) {
ret = CMD_ERROR;
print_str_url = alloc_url + strlen("file://");
}
+ assert(url);
+
ret = _lttng_create_session_ext(session_name, url, datetime);
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
if (ret < 0) {
goto error;
}
-
- ret = enable_consumer(session_name);
- if (ret < 0) {
- goto error;
- }
} else if ((!opt_ctrl_url && opt_data_url) ||
(opt_ctrl_url && !opt_data_url)) {
ERR("You need both control and data URL.");
goto error;
}
- if (opt_disable_consumer && !opt_no_consumer) {
- ret = disable_consumer(session_name);
- if (ret < 0) {
- goto error;
- }
- }
-
/* Init lttng session config */
ret = config_init(session_name);
if (ret < 0) {
}
}
+ if (opt_no_consumer) {
+ MSG("The option --no-consumer is obsolete.");
+ ret = CMD_WARNING;
+ goto end;
+ }
+
+ if (opt_disable_consumer) {
+ MSG("The option --disable-consumer is obsolete.");
+ ret = CMD_WARNING;
+ goto end;
+ }
+
opt_session_name = (char*) poptGetArg(pc);
ret = create_session();
#include "../command.h"
#include "../utils.h"
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-
-static int opt_kernel;
-static int opt_userspace;
-static char *opt_session_name;
-
-static struct lttng_handle *handle;
-
-enum {
- OPT_HELP = 1,
- OPT_LIST_OPTIONS,
-};
-
-static struct poptOption long_options[] = {
- /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
-};
-
-/*
- * usage
- */
-static void usage(FILE *ofp)
-{
- fprintf(ofp, "usage: lttng disable-consumer [-u|-k] [OPTIONS]\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Disable the consumer for a tracing session. This call can\n");
- fprintf(ofp, "be done BEFORE tracing has started.\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Options:\n");
- fprintf(ofp, " -h, --help Show this help\n");
- fprintf(ofp, " --list-options Simple listing of options\n");
- fprintf(ofp, " -s, --session NAME Apply to session name\n");
- fprintf(ofp, " -k, --kernel Apply to the kernel tracer\n");
- fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
- fprintf(ofp, "\n");
-}
-
-/*
- * Disable consumer command.
- */
-static int disable_consumer(char *session_name)
-{
- int ret = CMD_SUCCESS;
- struct lttng_domain dom;
-
- memset(&dom, 0, sizeof(dom));
-
- /* Create lttng domain */
- if (opt_kernel) {
- dom.type = LTTNG_DOMAIN_KERNEL;
- } else if (opt_userspace) {
- dom.type = LTTNG_DOMAIN_UST;
- } else {
- ERR("Please specify a tracer (-k/--kernel or -u/--userspace)");
- ret = CMD_ERROR;
- goto error;
- }
-
- handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
- ret = -1;
- goto error;
- }
-
- ret = lttng_disable_consumer(handle);
- if (ret < 0) {
- ERR("Disabling consumer for session %s: %s", session_name,
- lttng_strerror(ret));
- goto error;
- }
-
- MSG("Consumer disabled successfully");
-
-error:
- lttng_destroy_handle(handle);
- return ret;
-}
-
/*
* The 'disable-consumer <options>' first level command
*
*/
int cmd_disable_consumer(int argc, const char **argv)
{
- int opt, ret = CMD_SUCCESS;
- static poptContext pc;
- char *session_name = NULL;
-
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
- poptReadDefaultConfig(pc, 0);
-
- while ((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- case OPT_HELP:
- usage(stdout);
- goto end;
- case OPT_LIST_OPTIONS:
- list_cmd_options(stdout, long_options);
- goto end;
- default:
- usage(stderr);
- ret = CMD_UNDEFINED;
- goto end;
- }
- }
-
- /* Get session name */
- if (!opt_session_name) {
- session_name = get_session_name();
- if (session_name == NULL) {
- ret = CMD_ERROR;
- goto end;
- }
- } else {
- session_name = opt_session_name;
- }
-
- ret = disable_consumer(session_name);
+ int ret;
-end:
- if (opt_session_name == NULL) {
- free(session_name);
- }
+ MSG("The disable-consumer command is now obselete.");
+ ret = CMD_WARNING;
- poptFreeContext(pc);
return ret;
}
#include "../command.h"
#include "../utils.h"
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-
-static int opt_kernel;
-static int opt_userspace;
-static int opt_enable;
-static char *opt_session_name;
-static char *opt_url;
-static char *opt_ctrl_url;
-static char *opt_data_url;
-static char *opt_url_arg;
-
-static struct lttng_handle *handle;
-
-enum {
- OPT_HELP = 1,
- OPT_LIST_OPTIONS,
-};
-
-static struct poptOption long_options[] = {
- /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- {"help", 'h', POPT_ARG_NONE, NULL, OPT_HELP, NULL, NULL},
- {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL},
- {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
- {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
- {"set-uri", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0},
- {"ctrl-uri", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0},
- {"data-uri", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0},
- {"enable", 'e', POPT_ARG_VAL, &opt_enable, 1, 0, 0},
- {0, 0, 0, 0, 0, 0, 0}
-};
-
-/*
- * usage
- */
-static void usage(FILE *ofp)
-{
- fprintf(ofp, "usage: lttng enable-consumer [-u|-k] [URL] [OPTIONS]\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "The default behavior is to enable a consumer to the current URL.\n");
- fprintf(ofp, "The default URL is the local filesystem at the path of the session.\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "The enable-consumer feature supports both local and network transport.\n");
- fprintf(ofp, "You must have a running lttng-relayd for network transmission.\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Options:\n");
- fprintf(ofp, " -h, --help Show this help\n");
- fprintf(ofp, " --list-options Simple listing of options\n");
- fprintf(ofp, " -s, --session NAME Apply to session name\n");
- fprintf(ofp, " -k, --kernel Apply to the kernel tracer\n");
- fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Extended Options:\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Using these options, each API call can be controlled individually.\n");
- fprintf(ofp, "For instance, -C does not enable the consumer automatically.\n");
- fprintf(ofp, "\n");
- fprintf(ofp, " -U, --set-uri=URL Set URL for the enable-consumer destination.\n");
- fprintf(ofp, " It is persistent for the session lifetime.\n");
- fprintf(ofp, " Redo the command to change it.\n");
- fprintf(ofp, " This will set both data and control URL for network.\n");
- fprintf(ofp, " -C, --ctrl-url=URL Set control path URL. (Must use -D also)\n");
- fprintf(ofp, " -D, --data-url=URL Set data path URL. (Must use -C also)\n");
- fprintf(ofp, " -e, --enable Enable consumer\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Please refer to the man page (lttng(1)) for more information on network\n");
- fprintf(ofp, "streaming mechanisms and explanation of the control and data port\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "URL format is has followed:\n");
- fprintf(ofp, "\n");
- fprintf(ofp, " proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]\n");
- fprintf(ofp, "\n");
- fprintf(ofp, " Supported protocols are (proto):\n");
- fprintf(ofp, " > file://...\n");
- fprintf(ofp, " Local filesystem full path.\n");
- fprintf(ofp, "\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, "\n");
- fprintf(ofp, " > tcp[4|6]://...\n");
- fprintf(ofp, " Can only be used with -C and -D together\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "NOTE: IPv6 address MUST be enclosed in brackets '[]' (rfc2732)\n");
- fprintf(ofp, "\n");
- fprintf(ofp, "Examples:\n");
- fprintf(ofp, " # lttng enable-consumer -u net://192.168.1.42\n");
- fprintf(ofp, " Uses TCP and default ports for user space tracing (-u).\n");
- fprintf(ofp, "\n");
-}
-
-/*
- * Enable consumer command.
- */
-static int enable_consumer(char *session_name, int domain)
-{
- int ret = CMD_SUCCESS;
- int run_enable_cmd = 1;
- struct lttng_domain dom;
-
- memset(&dom, 0, sizeof(dom));
-
- dom.type = domain;
-
- handle = lttng_create_handle(session_name, &dom);
- if (handle == NULL) {
- ret = -1;
- goto error;
- }
-
- /* Handle trailing arguments */
- if (opt_url_arg) {
- ret = lttng_set_consumer_url(handle, opt_url_arg, NULL);
- if (ret < 0) {
- ERR("%s", lttng_strerror(ret));
- goto error;
- }
-
- MSG("URL %s set for %s session %s.", opt_url_arg,
- (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST",
- session_name);
- }
-
- /* Handling URLs (-U opt) */
- if (opt_url) {
- ret = lttng_set_consumer_url(handle, opt_url, NULL);
- if (ret < 0) {
- ERR("%s", lttng_strerror(ret));
- goto error;
- }
-
- /* opt_enable will tell us to run or not the enable_consumer cmd. */
- run_enable_cmd = 0;
-
- MSG("URL %s set for %s session %s.", opt_url,
- (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST",
- session_name);
- }
-
- /* Setting up control URL (-C or/and -D opt) */
- if (opt_ctrl_url || opt_data_url) {
- ret = lttng_set_consumer_url(handle, opt_ctrl_url, opt_data_url);
- if (ret < 0) {
- ERR("%s", lttng_strerror(ret));
- goto error;
- }
-
- /* opt_enable will tell us to run or not the enable_consumer cmd. */
- run_enable_cmd = 0;
-
- if (opt_ctrl_url) {
- MSG("Control URL %s set for %s session %s.", opt_ctrl_url,
- (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST",
- session_name);
- }
-
- if (opt_data_url) {
- MSG("Data URL %s set for %s session %s.", opt_data_url,
- (domain == LTTNG_DOMAIN_KERNEL) ? "kernel" : "UST",
- session_name);
- }
- }
-
- /* Enable consumer (-e opt) */
- if (opt_enable || run_enable_cmd) {
- ret = lttng_enable_consumer(handle);
- if (ret < 0) {
- ERR("Enabling consumer for session %s: %s", session_name,
- lttng_strerror(ret));
- if (ret == -LTTNG_ERR_ENABLE_CONSUMER_FAIL) {
- ERR("Perhaps the session was previously started?");
- }
- goto error;
- }
-
- MSG("Consumer enabled successfully");
- }
-
-error:
- lttng_destroy_handle(handle);
- return ret;
-}
-
/*
* The 'enable-consumer <options>' first level command
*
*/
int cmd_enable_consumer(int argc, const char **argv)
{
- int opt, ret = CMD_SUCCESS;
- static poptContext pc;
- char *session_name = NULL;
-
- pc = poptGetContext(NULL, argc, argv, long_options, 0);
- poptReadDefaultConfig(pc, 0);
-
- while ((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- case OPT_HELP:
- usage(stdout);
- goto end;
- case OPT_LIST_OPTIONS:
- list_cmd_options(stdout, long_options);
- goto end;
- default:
- usage(stderr);
- ret = CMD_UNDEFINED;
- goto end;
- }
- }
-
- opt_url_arg = (char *) poptGetArg(pc);
- DBG("URLs: %s", opt_url_arg);
-
- /* Get session name */
- if (!opt_session_name) {
- session_name = get_session_name();
- if (session_name == NULL) {
- ret = CMD_ERROR;
- goto end;
- }
- } else {
- session_name = opt_session_name;
- }
-
- if (opt_kernel || (!opt_kernel && !opt_userspace)) {
- ret = enable_consumer(session_name, LTTNG_DOMAIN_KERNEL);
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_userspace || (!opt_kernel && !opt_userspace)) {
- ret = enable_consumer(session_name, LTTNG_DOMAIN_UST);
- if (ret < 0) {
- goto end;
- }
- }
+ int ret;
-end:
- if (opt_session_name == NULL) {
- free(session_name);
- }
+ MSG("The enable-consumer command is now obselete.");
+ ret = CMD_WARNING;
- poptFreeContext(pc);
return ret;
}
{ "version", cmd_version},
{ "calibrate", cmd_calibrate},
{ "view", cmd_view},
- { "enable-consumer", cmd_enable_consumer},
- { "disable-consumer", cmd_disable_consumer},
+ { "enable-consumer", cmd_enable_consumer}, /* OBSELETE */
+ { "disable-consumer", cmd_disable_consumer}, /*OBSELETE */
{ NULL, NULL} /* Array closure */
};
fprintf(ofp, " enable-event Enable tracing event\n");
fprintf(ofp, " disable-channel Disable tracing channel\n");
fprintf(ofp, " disable-event Disable tracing event\n");
- fprintf(ofp, " enable-consumer Enable local or streaming consumer\n");
- fprintf(ofp, " disable-consumer Disable consumer\n");
fprintf(ofp, " list List possible tracing options\n");
fprintf(ofp, " set-session Set current session name\n");
fprintf(ofp, " start Start tracing\n");
[ ERROR_INDEX(LTTNG_ERR_SESSION_STARTED) ] = "Session is running",
[ ERROR_INDEX(LTTNG_ERR_NOT_SUPPORTED) ] = "Operation not supported",
[ ERROR_INDEX(LTTNG_ERR_UST_EVENT_ENABLED) ] = "UST event already enabled",
+ [ ERROR_INDEX(LTTNG_ERR_SET_URL) ] = "Error setting URL",
+ [ ERROR_INDEX(LTTNG_ERR_URL_EXIST) ] = "URL already exists",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"
}
/*
- * Enable consumer for a session and domain.
- *
- * Return 0 on success, else a negative value.
+ * [OBSELETE]
*/
int lttng_enable_consumer(struct lttng_handle *handle)
{
- struct lttcomm_session_msg lsm;
-
- if (handle == NULL) {
- return -LTTNG_ERR_INVALID;
- }
-
- lsm.cmd_type = LTTNG_ENABLE_CONSUMER;
-
- copy_string(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
- copy_lttng_domain(&lsm.domain, &handle->domain);
-
- return ask_sessiond(&lsm, NULL);
+ return -ENOSYS;
}
/*
- * Disable consumer for a session and domain.
- *
- * Return 0 on success, else a negative value.
+ * [OBSELETE]
*/
int lttng_disable_consumer(struct lttng_handle *handle)
{
- struct lttcomm_session_msg lsm;
-
- if (handle == NULL) {
- return -LTTNG_ERR_INVALID;
- }
-
- lsm.cmd_type = LTTNG_DISABLE_CONSUMER;
-
- copy_string(lsm.session.name, handle->session_name,
- sizeof(lsm.session.name));
- copy_lttng_domain(&lsm.domain, &handle->domain);
-
- return ask_sessiond(&lsm, NULL);
+ return -ENOSYS;
}
/*
exit 0
fi
-function lttng_create_session
+function lttng_create_session_uri
{
echo -n "Creating session $SESSION_NAME... "
# Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
- if [ $? -eq 1 ]; then
- print_fail
- return 1
- else
- print_ok
- fi
-}
-
-function lttng_enable_consumer_localhost
-{
- echo -n "Enabling network consumer... "
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -k net://localhost >/dev/null 2>&1
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
if [ $? -eq 1 ]; then
print_fail
return 1
function test_kernel_before_start ()
{
echo -e "\n=== Testing kernel streaming with event enable BEFORE start\n"
- lttng_create_session
- lttng_enable_consumer_localhost
+ lttng_create_session_uri
lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME
# Give a second
function test_kernel_after_start ()
{
echo -e "\n=== Testing kernel streaming with event enable AFTER start\n"
- lttng_create_session
- lttng_enable_consumer_localhost
+ lttng_create_session_uri
start_lttng_tracing $SESSION_NAME
lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
# Give a second
exit 0
fi
-function lttng_create_session
+function lttng_create_session_uri
{
# Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
-}
-
-function lttng_enable_consumer
-{
- # Create session with default path
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u net://localhost >/dev/null 2>&1
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1
}
function wait_apps
function test_ust_before_start ()
{
echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
- lttng_create_session
- lttng_enable_consumer
+ lttng_create_session_uri
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
# Run 5 times with a 1 second delay
function test_ust_after_start ()
{
echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
- lttng_create_session
- lttng_enable_consumer
+ lttng_create_session_uri
enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
start_lttng_tracing $SESSION_NAME