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