2 * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #ifndef LTTNG_CONDITION_BUFFER_USAGE_H
19 #define LTTNG_CONDITION_BUFFER_USAGE_H
21 #include <lttng/condition/evaluation.h>
22 #include <lttng/condition/condition.h>
24 #include <lttng/domain.h>
31 * Buffer usage conditions allows an action to be taken whenever a channel's
32 * buffer usage crosses a set threshold.
34 * These conditions are periodically evaluated against the current buffer
35 * usage statistics. The period at which these conditions are evaluated is
36 * governed by the channels' monitor timer.
38 * Note that the use of these conditons does not imply any hysteresis-loop
39 * mechanism. For instance, an upper-bound buffer usage condition set to 75%
40 * will fire everytime the buffer usage goes from a value < 75% to a value that
41 * is >= 75%. The evaluation result does not depend on any lower-bound condition
42 * being reached before the condition is evaluated to true again.
44 * Buffer usage conditions have the following properties:
45 * - the exact name of the session in which the channel to be monitored is
47 * - the domain of the channel to be monitored,
48 * - the exact name of the channel to be monitored,
49 * - a usage threshold, expressed either in bytes or as a fraction of total
52 * Wildcards, regular expressions or other globbing mechanisms are not supported
53 * in buffer usage condition properties.
57 * Create a newly allocated lower-bound buffer usage condition.
59 * A lower-bound buffer usage condition evaluates to true whenever
60 * a buffer's usage _crosses_ the bound that is defined as part of the
61 * condition's properties from high to low. In other words, the condition only
62 * evaluates to true when a buffer's usage transitions from a value higher than
63 * the threshold defined in the condition to a value lower than the threshold
64 * defined in the condition.
66 * Returns a new condition on success, NULL on failure. This condition must be
67 * destroyed using lttng_condition_destroy().
69 extern struct lttng_condition
*
70 lttng_condition_buffer_usage_low_create(void);
73 * Create a newly allocated upper-bound buffer usage condition.
75 * An upper-bound buffer usage condition evaluates to true whenever
76 * a buffer's usage _crosses_ the bound that is defined as part of the
77 * condition's properties from low to high. In other words, the condition only
78 * evaluates to true when a buffer's usage transitions from a value lower than
79 * the threshold defined in the condition to a value higher than the threshold
80 * defined in the condition.
82 * Returns a new condition on success, NULL on failure. This condition must be
83 * destroyed using lttng_condition_destroy().
85 extern struct lttng_condition
*
86 lttng_condition_buffer_usage_high_create(void);
89 * Get the buffer usage threshold ratio of a buffer usage condition.
91 * The buffer usage condition's threshold must have been defined as a ratio in
92 * order for this call to succeed.
94 * Returns LTTNG_CONDITION_STATUS_OK on success and a ratio contained by the
95 * interval [0.0, 1.0]. LTTNG_CONDITION_STATUS_INVALID is returned if an invalid
96 * parameter is passed, or LTTNG_CONDITION_STATUS_UNSET if a threshold,
97 * expressed as a ratio of total buffer capacity, was not set prior to this
100 extern enum lttng_condition_status
101 lttng_condition_buffer_usage_get_threshold_ratio(
102 const struct lttng_condition
*condition
,
103 double *threshold_ratio
);
106 * Set the buffer usage threshold ratio of a buffer usage condition.
108 * The threshold ratio passed must be contained by the interval [0.0, 1.0] and
109 * represents a ratio of the channel's buffer's capacity. Setting a threshold,
110 * either as a ratio or as an absolute size in bytes will override any
111 * previously set threshold.
113 * Returns LTTNG_CONDITION_STATUS_OK on success, LTTNG_CONDITION_STATUS_INVALID
114 * if invalid paramenters are passed.
116 extern enum lttng_condition_status
117 lttng_condition_buffer_usage_set_threshold_ratio(
118 struct lttng_condition
*condition
,
119 double threshold_ratio
);
122 * Get the buffer usage threshold of a buffer usage condition.
124 * The buffer usage condition's threshold must have been defined as an absolute
125 * value expressed in bytes in order for this call to succeed.
127 * Returns LTTNG_CONDITION_STATUS_OK on success and a threshold expressed in
128 * bytes, LTTNG_CONDITION_STATUS_INVALID if an invalid parameter is passed, or
129 * LTTNG_CONDITION_STATUS_UNSET if a threshold, expressed as an absolute size in
130 * bytes, was not set prior to this call.
132 extern enum lttng_condition_status
133 lttng_condition_buffer_usage_get_threshold(
134 const struct lttng_condition
*condition
,
135 uint64_t *threshold_bytes
);
138 * Set the buffer usage threshold in bytes of a buffer usage condition.
140 * Setting a threshold, either as a ratio or as an absolute size in bytes
141 * will override any previously set threshold.
143 * Returns LTTNG_CONDITION_STATUS_OK on success, LTTNG_CONDITION_STATUS_INVALID
144 * if invalid paramenters are passed.
146 extern enum lttng_condition_status
147 lttng_condition_buffer_usage_set_threshold(
148 struct lttng_condition
*condition
,
149 uint64_t threshold_bytes
);
152 * Get the session name property of a buffer usage condition.
154 * The caller does not assume the ownership of the returned session name. The
155 * session name shall only only be used for the duration of the condition's
156 * lifetime, or before a different session name is set.
158 * Returns LTTNG_CONDITION_STATUS_OK and a pointer to the condition's session
159 * name on success, LTTNG_CONDITION_STATUS_INVALID if an invalid
160 * parameter is passed, or LTTNG_CONDITION_STATUS_UNSET if a session name
161 * was not set prior to this call.
163 extern enum lttng_condition_status
164 lttng_condition_buffer_usage_get_session_name(
165 const struct lttng_condition
*condition
,
166 const char **session_name
);
169 * Set the session name property of a buffer usage condition.
171 * The passed session name parameter will be copied to the condition.
173 * Returns LTTNG_CONDITION_STATUS_OK on success, LTTNG_CONDITION_STATUS_INVALID
174 * if invalid paramenters are passed.
176 extern enum lttng_condition_status
177 lttng_condition_buffer_usage_set_session_name(
178 struct lttng_condition
*condition
,
179 const char *session_name
);
182 * Get the channel name property of a buffer usage condition.
184 * The caller does not assume the ownership of the returned channel name. The
185 * channel name shall only only be used for the duration of the condition's
186 * lifetime, or before a different channel name is set.
188 * Returns LTTNG_CONDITION_STATUS_OK and a pointer to the condition's channel
189 * name on success, LTTNG_CONDITION_STATUS_INVALID if an invalid
190 * parameter is passed, or LTTNG_CONDITION_STATUS_UNSET if a channel name
191 * was not set prior to this call.
193 extern enum lttng_condition_status
194 lttng_condition_buffer_usage_get_channel_name(
195 const struct lttng_condition
*condition
,
196 const char **channel_name
);
199 * Set the channel name property of a buffer usage condition.
201 * The passed channel name parameter will be copied to the condition.
203 * Returns LTTNG_CONDITION_STATUS_OK on success, LTTNG_CONDITION_STATUS_INVALID
204 * if invalid paramenters are passed.
206 extern enum lttng_condition_status
207 lttng_condition_buffer_usage_set_channel_name(
208 struct lttng_condition
*condition
,
209 const char *channel_name
);
212 * Get the domain type property of a buffer usage condition.
214 * Returns LTTNG_CONDITION_STATUS_OK and sets the domain type output parameter
215 * on success, LTTNG_CONDITION_STATUS_INVALID if an invalid parameter is passed,
216 * or LTTNG_CONDITION_STATUS_UNSET if a domain type was not set prior to this
219 extern enum lttng_condition_status
220 lttng_condition_buffer_usage_get_domain_type(
221 const struct lttng_condition
*condition
,
222 enum lttng_domain_type
*type
);
225 * Set the domain type property of a buffer usage condition.
227 * Returns LTTNG_CONDITION_STATUS_OK on success, LTTNG_CONDITION_STATUS_INVALID
228 * if invalid paramenters are passed.
230 extern enum lttng_condition_status
231 lttng_condition_buffer_usage_set_domain_type(
232 struct lttng_condition
*condition
,
233 enum lttng_domain_type type
);
237 * lttng_evaluation_buffer_usage are specialised lttng_evaluations which
238 * allow users to query a number of properties resulting from the evaluation
239 * of a condition which evaluated to true.
241 * The evaluation of a buffer usage condition yields two different results:
242 * - the usage ratio of the channel buffers at the time of the evaluation,
243 * - the usage, in bytes, of the channel buffers at the time of evaluation.
247 * Get the buffer usage ratio property of a buffer usage evaluation.
249 * Returns LTTNG_EVALUATION_STATUS_OK on success and a threshold expressed as
250 * as a ratio of the buffer's capacity, or LTTNG_EVALUATION_STATUS_INVALID if
251 * an invalid parameter is passed.
253 extern enum lttng_evaluation_status
254 lttng_evaluation_buffer_usage_get_usage_ratio(
255 const struct lttng_evaluation
*evaluation
,
256 double *usage_ratio
);
259 * Get the buffer usage property of a buffer usage evaluation.
261 * Returns LTTNG_EVALUATION_STATUS_OK on success and a threshold expressed in
262 * bytes, or LTTNG_EVALUATION_STATUS_INVALID if an invalid parameter is passed.
264 extern enum lttng_evaluation_status
265 lttng_evaluation_buffer_usage_get_usage(
266 const struct lttng_evaluation
*evaluation
,
267 uint64_t *usage_bytes
);
273 #endif /* LTTNG_CONDITION_BUFFER_USAGE_H */
This page took 0.034981 seconds and 5 git commands to generate.