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