Fix: Create a lock file to prevent multiple session daemons
[lttng-tools.git] / src / common / defaults.h
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as published by the Free Software Foundation.
8 *
9 * This program 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 General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #ifndef _DEFAULTS_H
20 #define _DEFAULTS_H
21
22 #include <config.h>
23
24 /* Default unix group name for tracing. */
25 #define DEFAULT_TRACING_GROUP "tracing"
26
27 /*
28 * This value is defined in the CTF specification (see
29 * git://git.efficios.com/ctf.git in the file
30 * common-trace-format-specification.txt.
31 */
32 #define DEFAULT_METADATA_NAME "metadata"
33
34 /* Environment variable to set session daemon binary path. */
35 #define DEFAULT_SESSIOND_PATH_ENV "LTTNG_SESSIOND_PATH"
36
37 /* Default trace output directory name */
38 #define DEFAULT_TRACE_DIR_NAME "lttng-traces"
39
40 /* Default size of a hash table */
41 #define DEFAULT_HT_SIZE 4
42
43 /* Default session daemon paths */
44 #define DEFAULT_HOME_DIR "/tmp"
45 #define DEFAULT_UST_SOCK_DIR DEFAULT_HOME_DIR "/ust-app-socks"
46 #define DEFAULT_GLOBAL_APPS_PIPE DEFAULT_UST_SOCK_DIR "/global"
47 #define DEFAULT_TRACE_OUTPUT DEFAULT_HOME_DIR "/lttng"
48
49 /* Default directory where the trace are written in per domain */
50 #define DEFAULT_KERNEL_TRACE_DIR "/kernel"
51 #define DEFAULT_UST_TRACE_DIR "/ust"
52
53 /* Subpath for per PID or UID sessions. */
54 #define DEFAULT_UST_TRACE_PID_PATH "/pid"
55 #define DEFAULT_UST_TRACE_UID_PATH "/uid/%d/%u-bit"
56
57 /*
58 * Default session name for the lttng command line. This default value will
59 * get the date and time appended (%Y%m%d-%H%M%S) to it.
60 */
61 #define DEFAULT_SESSION_NAME "auto"
62
63 /* Default consumer paths */
64 #define DEFAULT_CONSUMERD_RUNDIR "%s"
65
66 /* Kernel consumer path */
67 #define DEFAULT_KCONSUMERD_PATH DEFAULT_CONSUMERD_RUNDIR "/kconsumerd"
68 #define DEFAULT_KCONSUMERD_CMD_SOCK_PATH DEFAULT_KCONSUMERD_PATH "/command"
69 #define DEFAULT_KCONSUMERD_ERR_SOCK_PATH DEFAULT_KCONSUMERD_PATH "/error"
70
71 /* UST 64-bit consumer path */
72 #define DEFAULT_USTCONSUMERD64_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd64"
73 #define DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/command"
74 #define DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH DEFAULT_USTCONSUMERD64_PATH "/error"
75
76 /* UST 32-bit consumer path */
77 #define DEFAULT_USTCONSUMERD32_PATH DEFAULT_CONSUMERD_RUNDIR "/ustconsumerd32"
78 #define DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/command"
79 #define DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH DEFAULT_USTCONSUMERD32_PATH "/error"
80
81 /* Relayd path */
82 #define DEFAULT_RELAYD_RUNDIR "%s"
83 #define DEFAULT_RELAYD_PATH DEFAULT_RELAYD_RUNDIR "/relayd"
84
85 /* Default lttng run directory */
86 #define DEFAULT_LTTNG_HOME_ENV_VAR "LTTNG_HOME"
87 #define DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR "HOME"
88 #define DEFAULT_LTTNG_RUNDIR CONFIG_LTTNG_SYSTEM_RUNDIR
89 #define DEFAULT_LTTNG_HOME_RUNDIR "%s/.lttng"
90 #define DEFAULT_LTTNG_SESSIOND_PIDFILE "lttng-sessiond.pid"
91 #define DEFAULT_LTTNG_SESSIOND_JULPORT_FILE "jul.port"
92 #define DEFAULT_LTTNG_SESSIOND_LOCKFILE "lttng-sessiond.lck"
93
94 /* Default unix socket path */
95 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
96 #define DEFAULT_HOME_CLIENT_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
97 #define DEFAULT_GLOBAL_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/sessiond-health"
98 #define DEFAULT_HOME_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/sessiond-health"
99
100 /* Default consumer health unix socket path */
101 #define DEFAULT_GLOBAL_USTCONSUMER32_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/ustconsumerd32/health"
102 #define DEFAULT_HOME_USTCONSUMER32_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd32/health"
103 #define DEFAULT_GLOBAL_USTCONSUMER64_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/ustconsumerd64/health"
104 #define DEFAULT_HOME_USTCONSUMER64_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/ustconsumerd64/health"
105 #define DEFAULT_GLOBAL_KCONSUMER_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/kconsumerd/health"
106 #define DEFAULT_HOME_KCONSUMER_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/kconsumerd/health"
107
108 /* Default relay health unix socket path */
109 #define DEFAULT_GLOBAL_RELAY_HEALTH_UNIX_SOCK DEFAULT_LTTNG_RUNDIR "/relayd/health-%d"
110 #define DEFAULT_HOME_RELAY_HEALTH_UNIX_SOCK DEFAULT_LTTNG_HOME_RUNDIR "/relayd/health-%d"
111
112 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK \
113 DEFAULT_LTTNG_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
114 #define DEFAULT_HOME_APPS_UNIX_SOCK \
115 DEFAULT_LTTNG_HOME_RUNDIR "/" LTTNG_UST_SOCK_FILENAME
116 #define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH \
117 "/" LTTNG_UST_WAIT_FILENAME
118 #define DEFAULT_HOME_APPS_WAIT_SHM_PATH \
119 DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "-%d"
120
121 /*
122 * Value taken from the hard limit allowed by the kernel when using setrlimit
123 * with RLIMIT_NOFILE on an Intel i7 CPU and Linux 3.0.3.
124 */
125 #define DEFAULT_POLL_SIZE 65535
126
127 /*
128 * Format is %s_%d respectively channel name and CPU number. Eigth bytes
129 * are added here to add space for the CPU number. I guess 2^8 CPUs is more
130 * than enough. We might end up with quantum computing in a cell phone when
131 * reaching this limit.
132 */
133 #define DEFAULT_STREAM_NAME_LEN LTTNG_SYMBOL_NAME_LEN + 8
134
135 /* Default channel attributes */
136 #define DEFAULT_CHANNEL_NAME "channel0"
137 /* Default JUL domain channel name. */
138 #define DEFAULT_JUL_CHANNEL_NAME "lttng_jul_channel"
139 /* Default JUL tracepoint name. This is a wildcard for the JUL domain. */
140 #define DEFAULT_SYS_JUL_EVENT_NAME "lttng_jul:sys*"
141 #define DEFAULT_USER_JUL_EVENT_NAME "lttng_jul:user*"
142 /* JUL default channel name. */
143 #define DEFAULT_CHANNEL_OVERWRITE 0
144 #define DEFAULT_CHANNEL_TRACEFILE_SIZE 0
145 #define DEFAULT_CHANNEL_TRACEFILE_COUNT 0
146
147 /* Must always be a power of 2 */
148 #define _DEFAULT_CHANNEL_SUBBUF_SIZE 4096 /* bytes */
149 /* Must always be a power of 2 */
150 #define _DEFAULT_CHANNEL_SUBBUF_NUM 4
151 #define _DEFAULT_CHANNEL_SWITCH_TIMER 0 /* usec */
152 #define _DEFAULT_CHANNEL_LIVE_TIMER 0 /* usec */
153 #define _DEFAULT_CHANNEL_READ_TIMER 200000 /* usec */
154 #define _DEFAULT_CHANNEL_OUTPUT LTTNG_EVENT_MMAP
155
156 /* Metadata channel defaults. */
157 #define DEFAULT_METADATA_SUBBUF_SIZE 4096
158 #define DEFAULT_METADATA_SUBBUF_NUM 2
159 #define DEFAULT_METADATA_CACHE_SIZE 4096
160 #define DEFAULT_METADATA_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER
161 #define DEFAULT_METADATA_READ_TIMER 0
162 #define DEFAULT_METADATA_OUTPUT _DEFAULT_CHANNEL_OUTPUT
163
164 /* Kernel has different defaults */
165
166 /* DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE must always be a power of 2 */
167 #define DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE 262144 /* bytes */
168 /*
169 * DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM must always be a power of 2.
170 * Update help manually if override.
171 */
172 #define DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM _DEFAULT_CHANNEL_SUBBUF_NUM
173 /* See lttng-kernel.h enum lttng_kernel_output for channel output */
174 #define DEFAULT_KERNEL_CHANNEL_OUTPUT LTTNG_EVENT_SPLICE
175 #define DEFAULT_KERNEL_CHANNEL_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER
176 #define DEFAULT_KERNEL_CHANNEL_READ_TIMER _DEFAULT_CHANNEL_READ_TIMER
177 #define DEFAULT_KERNEL_CHANNEL_LIVE_TIMER _DEFAULT_CHANNEL_LIVE_TIMER
178
179 /* User space defaults */
180
181 /* Must be a power of 2 */
182 #define DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE _DEFAULT_CHANNEL_SUBBUF_SIZE
183 #define DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE 131072 /* bytes */
184 /* Must be a power of 2. Update help manuall if override. */
185 #define DEFAULT_UST_PID_CHANNEL_SUBBUF_NUM _DEFAULT_CHANNEL_SUBBUF_NUM
186 #define DEFAULT_UST_UID_CHANNEL_SUBBUF_NUM _DEFAULT_CHANNEL_SUBBUF_NUM
187 /* See lttng-ust.h enum lttng_ust_output */
188 #define DEFAULT_UST_PID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT
189 #define DEFAULT_UST_UID_CHANNEL_OUTPUT _DEFAULT_CHANNEL_OUTPUT
190 /* Timers in usec. */
191 #define DEFAULT_UST_PID_CHANNEL_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER
192 #define DEFAULT_UST_UID_CHANNEL_SWITCH_TIMER _DEFAULT_CHANNEL_SWITCH_TIMER
193 #define DEFAULT_UST_PID_CHANNEL_LIVE_TIMER _DEFAULT_CHANNEL_LIVE_TIMER
194 #define DEFAULT_UST_UID_CHANNEL_LIVE_TIMER _DEFAULT_CHANNEL_LIVE_TIMER
195
196 #define DEFAULT_UST_PID_CHANNEL_READ_TIMER 0 /* usec */
197 #define DEFAULT_UST_UID_CHANNEL_READ_TIMER 0 /* usec */
198
199 /*
200 * Default timeout value for the sem_timedwait() call. Blocking forever is not
201 * wanted so a timeout is used to control the data flow and not freeze the
202 * session daemon.
203 */
204 #define DEFAULT_SEM_WAIT_TIMEOUT 30 /* in seconds */
205
206 /* Default bind addresses for network services. */
207 #define DEFAULT_NETWORK_CONTROL_BIND_ADDRESS "0.0.0.0"
208 #define DEFAULT_NETWORK_DATA_BIND_ADDRESS "0.0.0.0"
209 #define DEFAULT_NETWORK_VIEWER_BIND_ADDRESS "localhost"
210 #define DEFAULT_JUL_BIND_ADDRESS "localhost"
211
212 /* Default network ports for trace streaming support. */
213 #define DEFAULT_NETWORK_CONTROL_PORT 5342
214 #define DEFAULT_NETWORK_DATA_PORT 5343
215 #define DEFAULT_NETWORK_VIEWER_PORT 5344
216
217 /* JUL registration TCP port. */
218 #define DEFAULT_JUL_TCP_PORT 5345
219
220 /*
221 * If a thread stalls for this amount of time, it will be considered bogus (bad
222 * health).
223 */
224 #define DEFAULT_HEALTH_CHECK_DELTA_S 20
225 #define DEFAULT_HEALTH_CHECK_DELTA_NS 0
226
227 /*
228 * Wait period before retrying the lttng_data_pending command in the lttng
229 * stop command of liblttng-ctl.
230 */
231 #define DEFAULT_DATA_AVAILABILITY_WAIT_TIME 200000 /* usec */
232
233 /*
234 * Wait period before retrying the lttng_consumer_flushed_cache when
235 * the consumer receives metadata.
236 */
237 #define DEFAULT_METADATA_AVAILABILITY_WAIT_TIME 200000 /* usec */
238
239 /*
240 * The usual value for the maximum TCP SYN retries time and TCP FIN timeout is
241 * 180 and 60 seconds on most Linux system and the default value since kernel
242 * 2.2 thus using the highest value. See tcp(7) for more details.
243 */
244 #define DEFAULT_INET_TCP_TIMEOUT 180 /* sec */
245
246 /*
247 * Default receiving and sending timeout for an application socket.
248 */
249 #define DEFAULT_APP_SOCKET_RW_TIMEOUT 5 /* sec */
250 #define DEFAULT_APP_SOCKET_TIMEOUT_ENV "LTTNG_APP_SOCKET_TIMEOUT"
251
252 #define DEFAULT_UST_STREAM_FD_NUM 2 /* Number of fd per UST stream. */
253
254 #define DEFAULT_SNAPSHOT_NAME "snapshot"
255 #define DEFAULT_SNAPSHOT_MAX_SIZE 0 /* Unlimited. */
256
257 /* Suffix of an index file. */
258 #define DEFAULT_INDEX_FILE_SUFFIX ".idx"
259 #define DEFAULT_INDEX_DIR "index"
260
261 /* Default lttng command live timer value in usec. */
262 #define DEFAULT_LTTNG_LIVE_TIMER 1000000
263
264 extern size_t default_channel_subbuf_size;
265 extern size_t default_metadata_subbuf_size;
266 extern size_t default_ust_pid_channel_subbuf_size;
267 extern size_t default_ust_uid_channel_subbuf_size;
268 extern size_t default_kernel_channel_subbuf_size;
269
270 /*
271 * Returns the default subbuf size.
272 *
273 * This function depends on a value that is set at constructor time, so it is
274 * unsafe to call it from another constructor.
275 */
276 static inline
277 size_t default_get_channel_subbuf_size(void)
278 {
279 return default_channel_subbuf_size;
280 }
281
282 /*
283 * Returns the default metadata subbuf size.
284 *
285 * This function depends on a value that is set at constructor time, so it is
286 * unsafe to call it from another constructor.
287 */
288 static inline
289 size_t default_get_metadata_subbuf_size(void)
290 {
291 return default_metadata_subbuf_size;
292 }
293
294 /*
295 * Returns the default subbuf size for the kernel domain.
296 *
297 * This function depends on a value that is set at constructor time, so it is
298 * unsafe to call it from another constructor.
299 */
300 static inline
301 size_t default_get_kernel_channel_subbuf_size(void)
302 {
303 return default_kernel_channel_subbuf_size;
304 }
305
306 /*
307 * Returns the default subbuf size for the UST domain per PID.
308 *
309 * This function depends on a value that is set at constructor time, so it is
310 * unsafe to call it from another constructor.
311 */
312 static inline
313 size_t default_get_ust_pid_channel_subbuf_size(void)
314 {
315 return default_ust_pid_channel_subbuf_size;
316 }
317
318 /*
319 * Returns the default subbuf size for the UST domain per UID.
320 *
321 * This function depends on a value that is set at constructor time, so it is
322 * unsafe to call it from another constructor.
323 */
324 static inline
325 size_t default_get_ust_uid_channel_subbuf_size(void)
326 {
327 return default_ust_uid_channel_subbuf_size;
328 }
329
330 #endif /* _DEFAULTS_H */
This page took 0.035116 seconds and 4 git commands to generate.