#include <common/common.h>
#include <common/defaults.h>
#include <common/uri.h>
+#include <common/utils.h>
#include "consumer.h"
#include "health.h"
*/
int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
struct snapshot_output *output, int metadata, uid_t uid, gid_t gid,
- int wait)
+ const char *session_path, int wait)
{
int ret;
+ char datetime[16];
struct lttcomm_consumer_msg msg;
assert(socket);
DBG("Consumer snapshot channel key %" PRIu64, key);
- memset(&msg, 0, sizeof(msg));
+ ret = utils_get_current_time_str("%Y%m%d-%H%M%S", datetime,
+ sizeof(datetime));
+ if (!ret) {
+ ret = -EINVAL;
+ goto error;
+ }
+ memset(&msg, 0, sizeof(msg));
msg.cmd_type = LTTNG_CONSUMER_SNAPSHOT_CHANNEL;
msg.u.snapshot_channel.key = key;
msg.u.snapshot_channel.max_size = output->max_size;
msg.u.snapshot_channel.relayd_id = output->consumer->net_seq_index;
msg.u.snapshot_channel.use_relayd = 1;
ret = snprintf(msg.u.snapshot_channel.pathname,
- sizeof(msg.u.snapshot_channel.pathname), "%s/%s",
- output->consumer->subdir, DEFAULT_SNAPSHOT_NAME);
+ sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s",
+ output->consumer->subdir, output->name, datetime,
+ session_path);
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
goto error;
}
} else {
ret = snprintf(msg.u.snapshot_channel.pathname,
- sizeof(msg.u.snapshot_channel.pathname), "%s/%s",
- output->consumer->dst.trace_path, DEFAULT_SNAPSHOT_NAME);
+ sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s",
+ output->consumer->dst.trace_path, output->name, datetime,
+ session_path);
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
goto error;
/* Snapshot command. */
int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
struct snapshot_output *output, int metadata, uid_t uid, gid_t gid,
- int wait);
+ const char *session_path, int wait);
#endif /* _CONSUMER_H */
cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
pthread_mutex_lock(socket->lock);
ret = consumer_snapshot_channel(socket, chan->fd, output, 0,
- ksess->uid, ksess->gid, wait);
+ ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait);
pthread_mutex_unlock(socket->lock);
if (ret < 0) {
ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
/* Snapshot metadata, */
pthread_mutex_lock(socket->lock);
ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output,
- 1, ksess->uid, ksess->gid, wait);
+ 1, ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait);
pthread_mutex_unlock(socket->lock);
if (ret < 0) {
ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
}
lttng_ht_node_init_ulong(&output->node, (unsigned long) output->id);
- if (name) {
+ if (name && name[0] != '\0') {
strncpy(output->name, name, sizeof(output->name));
} else {
/* Set default name. */
cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
ua_chan, node.node) {
ret = consumer_snapshot_channel(socket, ua_chan->key, output, 0,
- ua_sess->euid, ua_sess->egid, wait);
+ ua_sess->euid, ua_sess->egid, ua_sess->path, wait);
if (ret < 0) {
goto error;
}
registry = get_session_registry(ua_sess);
assert(registry);
ret = consumer_snapshot_channel(socket, registry->metadata_key, output,
- 1, ua_sess->euid, ua_sess->egid, wait);
+ 1, ua_sess->euid, ua_sess->egid, ua_sess->path, wait);
if (ret < 0) {
goto error;
}