X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fhealth%2Fhealth_check.c;h=9109b1824336219627a24b346b28bd282ca9dba5;hb=5da3fc8579a9f93ea4767729a107784bf2d034ae;hp=0569a418775c98b9c9a5f24aac086be43f1b7786;hpb=6c71277b0dc97ce8a4ac6b8d359b4b349c04b658;p=lttng-tools.git diff --git a/tests/regression/tools/health/health_check.c b/tests/regression/tools/health/health_check.c index 0569a4187..9109b1824 100644 --- a/tests/regression/tools/health/health_check.c +++ b/tests/regression/tools/health/health_check.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2012 - Christian Babeux + * Copyright (C) 2014 - Mathieu Desnoyers * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License, version 2 only, as @@ -17,16 +18,23 @@ #include #include +#include #include +static const char *relayd_path; + static -int check_component(struct lttng_health *lh, const char *component_name) +int check_component(struct lttng_health *lh, const char *component_name, + int ok_if_not_running) { const struct lttng_health_thread *thread; int nr_threads, i, status; if (lttng_health_query(lh)) { + if (ok_if_not_running) { + return 0; + } fprintf(stderr, "Error querying %s health\n", component_name); return -1; @@ -75,7 +83,7 @@ int check_sessiond(void) return -1; } - status = check_component(lh, "sessiond"); + status = check_component(lh, "sessiond", 0); lttng_health_destroy(lh); @@ -99,22 +107,54 @@ int check_consumerd(enum lttng_health_consumerd hc) return -1; } - status = check_component(lh, cnames[hc]); + status = check_component(lh, cnames[hc], 1); lttng_health_destroy(lh); return status; } +static +int check_relayd(const char *path) +{ + struct lttng_health *lh; + int status; + + lh = lttng_health_create_relayd(path); + if (!lh) { + perror("lttng_health_create_relayd"); + return -1; + } + + status = check_component(lh, "relayd", 0); + + lttng_health_destroy(lh); + + return status; +} int main(int argc, char *argv[]) { int status = 0, i; + for (i = 1; i < argc; i++) { + size_t relayd_path_arg_len = strlen("--relayd-path="); + if (!strncmp(argv[i], "--relayd-path=", + relayd_path_arg_len)) { + relayd_path = &argv[i][relayd_path_arg_len]; + } else { + fprintf(stderr, "Unknown option \"%s\". Try --relayd-path=PATH.\n", argv[i]); + exit(EXIT_FAILURE); + } + } + status |= check_sessiond(); for (i = 0; i < NR_LTTNG_HEALTH_CONSUMERD; i++) { status |= check_consumerd(i); } + if (relayd_path) { + status |= check_relayd(relayd_path); + } if (!status) { exit(EXIT_SUCCESS); } else {