health check API
[lttng-tools.git] / include / lttng / health.h
CommitLineData
d74df422
MD
1#ifndef LTTNG_HEALTH_H
2#define LTTNG_HEALTH_H
3
4/*
5 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
6 * Copyright (C) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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
22struct lttng_health;
23struct lttng_health_thread;
24
25enum lttng_health_consumerd {
26 LTTNG_HEALTH_CONSUMERD_UST_32,
27 LTTNG_HEALTH_CONSUMERD_UST_64,
28 LTTNG_HEALTH_CONSUMERD_KERNEL,
29};
30
31/**
32 * lttng_health_create_sessiond - Create sessiond health object
33 *
34 * Return a newly allocated health object, or NULL on error.
35 */
36struct lttng_health *lttng_health_create_sessiond(void);
37
38/**
39 * lttng_health_create_consumerd - Create consumerd health object
40 * @consumerd: consumer daemon identifier
41 *
42 * Return a newly allocated health object, or NULL on error.
43 */
44struct lttng_health *
45 lttng_health_create_consumerd(enum lttng_health_consumerd consumerd);
46
47/**
48 * lttng_health_create_relayd - Create relayd health object
49 * @path: path to relay daemon health socket.
50 *
51 * "path" needs to refer to a local unix socket file matching the file
52 * used by the relay daemon to query.
53 *
54 * Return a newly allocated health object, or NULL on error.
55 */
56struct lttng_health *lttng_health_create_relayd(const char *path);
57
58/**
59 * lttng_health_destroy - Destroy health object
60 * @health: health object to destroy
61 */
62void lttng_health_destroy(struct lttng_health *health);
63
64/**
65 * lttng_health_query - Query component health
66 * @health: health state (input/output).
67 *
68 * Return 0 on success, negative value on error. This return value only
69 * reports if the query has been successfully performed, *NOT* the
70 * actual state. lttng_health_state() should be used for the latter.
71 */
72int lttng_health_query(struct lttng_health *health);
73
74/**
75 * lttng_health_state - Inspect the state of a health structure
76 * @health: health state (input).
77 *
78 * "path" needs to refer to a local unix socket file matching the file
79 * used by the relay daemon to query.
80 *
81 * Return 0 on success, negative value if the component has at least one
82 * thread in error. It also returns a negative return value if
83 * lttng_health_query() has not yet successfully completed on @health.
84 */
85int lttng_health_state(const struct lttng_health *health);
86
87/**
88 * lttng_health_get_nr_threads - Get number of threads in health component
89 * @health: health state (input)
90 *
91 * Return the number of threads (>= 0) on success, else negative value
92 * on error.
93 */
94int lttng_health_get_nr_threads(const struct lttng_health *health);
95
96/**
97 * lttng_health_get_thread - Get thread health
98 * @health: health state (input)
99 * @nth_thread: nth thread to lookup
100 *
101 * Return a pointer to the health thread, else NULL on error. This
102 * pointer should not be freed by the caller, and can be used until
103 * lttng_health_destroy() is called on @health.
104 */
105const struct lttng_health_thread *
106 lttng_health_get_thread(const struct lttng_health *health,
107 int nth_thread);
108
109/**
110 * lttng_health_thread_state - Get thread health state
111 * @thread: thread health
112 *
113 * Return 0 if thread is OK, else negative error value.
114 */
115int lttng_health_thread_state(const struct lttng_health_thread *thread);
116
117/**
118 * lttng_health_thread_name - Get thread name
119 * @thread: thread health
120 *
121 * Return thread name, NULL on error.
122 */
123const char *lttng_health_thread_name(const struct lttng_health_thread *thread);
124
125#endif /* LTTNG_HEALTH_H */
This page took 0.02639 seconds and 4 git commands to generate.