Tests: Add a health check utility program
[lttng-tools.git] / tests / tools / health / health_check.c
1 /*
2 * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program 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 General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #include <stdio.h>
19
20 #include "lttng/lttng.h"
21
22 #define HEALTH_CMD_FAIL (1 << 0)
23 #define HEALTH_APP_MNG_FAIL (1 << 1)
24 #define HEALTH_APP_REG_FAIL (1 << 2)
25 #define HEALTH_KERNEL_FAIL (1 << 3)
26 #define HEALTH_CSMR_FAIL (1 << 4)
27
28 int main(int argc, char *argv[])
29 {
30 int health = -1;
31 int status = 0;
32
33 /* Command thread */
34 health = lttng_health_check(LTTNG_HEALTH_CMD);
35 printf("Health check cmd: %d\n", health);
36
37 if (health) {
38 status |= HEALTH_CMD_FAIL;
39 }
40
41 /* App manage thread */
42 health = lttng_health_check(LTTNG_HEALTH_APP_MANAGE);
43 printf("Health check app. manage: %d\n", health);
44
45 if (health) {
46 status |= HEALTH_APP_MNG_FAIL;
47 }
48 /* App registration thread */
49 health = lttng_health_check(LTTNG_HEALTH_APP_REG);
50 printf("Health check app. registration: %d\n", health);
51
52 if (health) {
53 status |= HEALTH_APP_REG_FAIL;
54 }
55
56 /* Kernel thread */
57 health = lttng_health_check(LTTNG_HEALTH_KERNEL);
58 printf("Health check kernel: %d\n", health);
59
60 if (health) {
61 status |= HEALTH_KERNEL_FAIL;
62 }
63
64 /* Consumer thread */
65 health = lttng_health_check(LTTNG_HEALTH_CONSUMER);
66 printf("Health check consumer: %d\n", health);
67
68 if (health) {
69 status |= HEALTH_CSMR_FAIL;
70 }
71
72 return status;
73 }
This page took 0.04188 seconds and 4 git commands to generate.