Fix: honor base path for network URIs
[lttng-tools.git] / include / lttng / session.h
1 /*
2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
3 * Copyright (C) 2019 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 *
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, version 2.1 only,
7 * as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef LTTNG_SESSION_H
20 #define LTTNG_SESSION_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 struct lttng_session_descriptor;
27 struct lttng_destruction_handle;
28
29 /*
30 * Basic session information.
31 *
32 * The "enabled" field is only used when listing the sessions which indicate if
33 * it's started or not.
34 *
35 * The structures should be initialized to zero before use.
36 */
37 #define LTTNG_SESSION_PADDING1 12
38 struct lttng_session {
39 char name[LTTNG_NAME_MAX];
40 /*
41 * Human-readable representation of the trace's destination.
42 * In the case of a local tracing session, a path is provided:
43 * /path/to/the/output
44 *
45 * In the case of a remote (network) tracing session, the string has
46 * the following format:
47 * net://hostname/path:ctrl_port [data: data_port]
48 */
49 char path[PATH_MAX];
50 uint32_t enabled; /* enabled/started: 1, disabled/stopped: 0 */
51 uint32_t snapshot_mode;
52 unsigned int live_timer_interval; /* usec */
53
54 union {
55 char padding[LTTNG_SESSION_PADDING1];
56 void *ptr;
57 } extended;
58 };
59
60 /*
61 * Create a session on the session daemon from a session descriptor.
62 *
63 * See the session descriptor API description in session-descriptor.h
64 *
65 * Note that unspecified session descriptor parameters, such as a session's
66 * name, are updated in the session descriptor if the creation of the session
67 * succeeds. This allows users to query the session's auto-generated name
68 * after its creation. Note that other attributes can be queried using the
69 * session listing API.
70 *
71 * Returns LTTNG_OK on success. See lttng-error.h for the meaning of the other
72 * return codes.
73 */
74 extern enum lttng_error_code lttng_create_session_ext(
75 struct lttng_session_descriptor *session_descriptor);
76
77 /*
78 * Create a tracing session using a name and an optional URL.
79 *
80 * If _url_ is NULL, no consumer is created for the session. The name can't be
81 * NULL here.
82 *
83 * Return 0 on success else a negative LTTng error code.
84 */
85 extern int lttng_create_session(const char *name, const char *url);
86
87 /*
88 * Create a tracing session that will exclusively be used for snapshot meaning
89 * the session will be in no output mode and every channel enabled for that
90 * session will be set in overwrite mode and in mmap output since splice is not
91 * supported.
92 *
93 * Name can't be NULL. If an url is given, it will be used to create a default
94 * snapshot output using it as a destination. If NULL, no output will be
95 * defined and an add-output call will be needed.
96 *
97 * Return 0 on success else a negative LTTng error code.
98 */
99 extern int lttng_create_session_snapshot(const char *name,
100 const char *snapshot_url);
101
102 /*
103 * Create a session exclusively used for live reading.
104 *
105 * In this mode, the switch-timer parameter is forced for each UST channel, a
106 * live-switch-timer is enabled for kernel channels, manually setting
107 * switch-timer is forbidden. Synchronization beacons are sent to the relayd,
108 * indexes are sent and metadata is checked for each packet.
109 *
110 * Name can't be NULL. If no URL is given, the default is to send the data to
111 * net://127.0.0.1. The timer_interval is in usec.
112 *
113 * Return 0 on success else a negative LTTng error code.
114 */
115 extern int lttng_create_session_live(const char *name, const char *url,
116 unsigned int timer_interval);
117
118 /*
119 * Destroy a tracing session.
120 *
121 * The session will not be usable, tracing will be stopped thus buffers will be
122 * flushed.
123 *
124 * This call will wait for data availability for each domain of the session,
125 * which can take an arbitrary amount of time. However, when returning the
126 * tracing data is guaranteed to be ready to be read and analyzed.
127 *
128 * lttng_destroy_session_no_wait() may be used if such a guarantee is not
129 * needed.
130 *
131 * The name can't be NULL here.
132 *
133 * Return 0 on success else a negative LTTng error code.
134 */
135 extern int lttng_destroy_session(const char *name);
136
137 /*
138 * Destroy a tracing session.
139 *
140 * Performs the same function as lttng_destroy_session(), but provides
141 * an lttng_destruction_handle which can be used to wait for the completion
142 * of the session's destruction. The lttng_destroy_handle can also be used
143 * obtain the status and archive location of any implicit session
144 * rotation that may have occured during the session's destruction.
145 *
146 * Returns LTTNG_OK on success. The returned handle is owned by the caller
147 * and must be free'd using lttng_destruction_handle_destroy().
148 */
149 extern enum lttng_error_code lttng_destroy_session_ext(const char *session_name,
150 struct lttng_destruction_handle **handle);
151
152 /*
153 * Behaves exactly like lttng_destroy_session but does not wait for data
154 * availability.
155 */
156 extern int lttng_destroy_session_no_wait(const char *name);
157
158 /*
159 * List all the tracing sessions.
160 *
161 * Return the number of entries of the "lttng_session" array. The caller
162 * must free the returned sessions array directly using free().
163 *
164 * On error, a negative LTTng error code is returned.
165 */
166 extern int lttng_list_sessions(struct lttng_session **sessions);
167
168 /*
169 * Get the creation time of an lttng_session object on the session daemon.
170 *
171 * This function must only be used with lttng_session objects returned
172 * by lttng_list_sessions() or lttng_session_create().
173 *
174 * The creation time returned is a UNIX timestamp; the number of seconds since
175 * Epoch (1970-01-01 00:00:00 +0000 (UTC)).
176 *
177 * Returns LTTNG_OK on success. See lttng-error.h for the meaning of the other
178 * return codes.
179 */
180 extern enum lttng_error_code lttng_session_get_creation_time(
181 const struct lttng_session *session, uint64_t *creation_time);
182
183 /*
184 * Set the shared memory path for a session.
185 *
186 * Sets the (optional) file system path where shared memory buffers will
187 * be created for the session. This is useful for buffer extraction on
188 * crash, when used with filesystems like pramfs.
189 *
190 * Return 0 on success else a negative LTTng error code.
191 */
192 extern int lttng_set_session_shm_path(const char *session_name,
193 const char *shm_path);
194
195 /*
196 * Add PID to session tracker.
197 *
198 * A pid argument >= 0 adds the PID to the session tracker.
199 * A pid argument of -1 means "track all PIDs".
200 *
201 * Return 0 on success else a negative LTTng error code.
202 */
203 extern int lttng_track_pid(struct lttng_handle *handle, int pid);
204
205 /*
206 * Remove PID from session tracker.
207 *
208 * A pid argument >= 0 removes the PID from the session tracker.
209 * A pid argument of -1 means "untrack all PIDs".
210 *
211 * Return 0 on success else a negative LTTng error code.
212 */
213 extern int lttng_untrack_pid(struct lttng_handle *handle, int pid);
214
215 /*
216 * List PIDs in the tracker.
217 *
218 * enabled is set to whether the PID tracker is enabled.
219 * pids is set to an allocated array of PIDs currently tracked. On
220 * success, pids must be freed by the caller.
221 * nr_pids is set to the number of entries contained by the pids array.
222 *
223 * Returns 0 on success, else a negative LTTng error code.
224 */
225 extern int lttng_list_tracker_pids(struct lttng_handle *handle,
226 int *enabled, int32_t **pids, size_t *nr_pids);
227
228 #ifdef __cplusplus
229 }
230 #endif
231
232 #endif /* LTTNG_SESSION_H */
This page took 0.033791 seconds and 4 git commands to generate.