85d13c9029d9c7d887506b30d7af9286683637d2
[lttng-tools.git] / include / lttng / lttng.h
1 /*
2 * lttng.h
3 *
4 * Linux Trace Toolkit Control Library Header File
5 *
6 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
7 *
8 * This library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License, version 2.1 only,
10 * as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef LTTNG_H
23 #define LTTNG_H
24
25 /* Error codes that can be returned by API calls */
26 #include <lttng/lttng-error.h>
27
28 /* Include every LTTng ABI/API available. */
29 #include <lttng/channel.h>
30 #include <lttng/domain.h>
31 #include <lttng/event.h>
32 #include <lttng/handle.h>
33 #include <lttng/health.h>
34 #include <lttng/save.h>
35 #include <lttng/session.h>
36 #include <lttng/snapshot.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /* Health component for the health check function. */
43 enum lttng_health_component {
44 LTTNG_HEALTH_CMD,
45 LTTNG_HEALTH_APP_MANAGE,
46 LTTNG_HEALTH_APP_REG,
47 LTTNG_HEALTH_KERNEL,
48 LTTNG_HEALTH_CONSUMER,
49 LTTNG_HEALTH_HT_CLEANUP,
50 LTTNG_HEALTH_APP_MANAGE_NOTIFY,
51 LTTNG_HEALTH_APP_REG_DISPATCH,
52 LTTNG_HEALTH_ALL,
53 };
54
55 enum lttng_calibrate_type {
56 LTTNG_CALIBRATE_FUNCTION = 0,
57 };
58
59 #define LTTNG_CALIBRATE_PADDING1 16
60 struct lttng_calibrate {
61 enum lttng_calibrate_type type;
62
63 char padding[LTTNG_CALIBRATE_PADDING1];
64 };
65
66 /*
67 * Check if a session daemon is alive.
68 *
69 * Return 1 if alive or 0 if not. On error, returns a negative negative LTTng
70 * error code.
71 */
72 extern int lttng_session_daemon_alive(void);
73
74 /*
75 * Set the tracing group for the *current* flow of execution.
76 *
77 * On success, returns 0 else a negative LTTng error code.
78 */
79 extern int lttng_set_tracing_group(const char *name);
80
81 /*
82 * This call registers an "outside consumer" for a session and an lttng domain.
83 * No consumer will be spawned and all fds/commands will go through the socket
84 * path given (socket_path).
85 *
86 * NOTE that this is not recommended unless you absolutely know what you are
87 * doing.
88 *
89 * Return 0 on success else a negative LTTng error code.
90 */
91 extern int lttng_register_consumer(struct lttng_handle *handle,
92 const char *socket_path);
93
94 /*
95 * Start tracing for *all* domain(s) in the session.
96 *
97 * Return 0 on success else a negative LTTng error code.
98 */
99 extern int lttng_start_tracing(const char *session_name);
100
101 /*
102 * Stop tracing for *all* domain(s) in the session.
103 *
104 * This call will wait for data availability for each domain of the session so
105 * this can take an abritrary amount of time. However, when returning you have
106 * the guarantee that the data is ready to be read and analyze. Use the
107 * _no_wait call below to avoid this behavior.
108 *
109 * The session_name can't be NULL.
110 *
111 * Return 0 on success else a negative LTTng error code.
112 */
113 extern int lttng_stop_tracing(const char *session_name);
114
115 /*
116 * Behave exactly like lttng_stop_tracing but does not wait for data
117 * availability.
118 */
119 extern int lttng_stop_tracing_no_wait(const char *session_name);
120
121 /*
122 * Calibrate LTTng overhead.
123 *
124 * The chan and handle params can not be NULL.
125 *
126 * Return 0 on success else a negative LTTng error code.
127 */
128 extern int lttng_calibrate(struct lttng_handle *handle,
129 struct lttng_calibrate *calibrate);
130
131 /*
132 * Set URL for a consumer for a session and domain.
133 *
134 * Both data and control URL must be defined. If both URLs are the same, only
135 * the control URL is used even for network streaming.
136 *
137 * Default port are 5342 and 5343 respectively for control and data which uses
138 * the TCP protocol.
139 *
140 * URL format: proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
141 *
142 * Possible protocols are:
143 * > file://...
144 * Local filesystem full path.
145 *
146 * > net[6]://...
147 * This will use the default network transport layer which is TCP for both
148 * control (PORT1) and data port (PORT2).
149 *
150 * > tcp[6]://...
151 * TCP only streaming. For this one, both data and control URL must be given.
152 *
153 * Return 0 on success else a negative LTTng error code.
154 */
155 extern int lttng_set_consumer_url(struct lttng_handle *handle,
156 const char *control_url, const char *data_url);
157
158 /*
159 * Enable the consumer for a session and domain.
160 */
161 extern LTTNG_DEPRECATED("This call is now obsolete.")
162 int lttng_enable_consumer(struct lttng_handle *handle);
163
164 /*
165 * Disable consumer for a session and domain.
166 */
167 extern LTTNG_DEPRECATED("This call is now obsolete.")
168 int lttng_disable_consumer(struct lttng_handle *handle);
169
170 /*
171 * Check session daemon health for a specific component.
172 *
173 * Return 0 if health is OK or 1 if BAD. A returned value of -1 indicate that
174 * the control library was not able to connect to the session daemon health
175 * socket.
176 *
177 * Any other positive value is an lttcomm error which can be translate with
178 * lttng_strerror().
179 *
180 * Please see lttng-health-check(3) man page for more information.
181 */
182 extern LTTNG_DEPRECATED("This call is now obsolete.")
183 int lttng_health_check(enum lttng_health_component c);
184
185 /*
186 * For a given session name, this call checks if the data is ready to be read
187 * or is still being extracted by the consumer(s) (pending) hence not ready to
188 * be used by any readers.
189 *
190 * Return 0 if there is _no_ data pending in the buffers thus having a
191 * guarantee that the data can be read safely. Else, return 1 if there is still
192 * traced data is pending. On error, a negative value is returned and readable
193 * by lttng_strerror().
194 */
195 extern int lttng_data_pending(const char *session_name);
196
197 #ifdef __cplusplus
198 }
199 #endif
200
201 #endif /* LTTNG_H */
This page took 0.032435 seconds and 4 git commands to generate.