Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: christian.babeux@efficios.com (Christian Babeux)
Subject: [lttng-dev] [PATCH v2 lttng-tools 2/5] Tests: Add a health check utility program
Date: Tue,  2 Oct 2012 14:19:19 -0400	[thread overview]
Message-ID: <1349201959-9989-1-git-send-email-christian.babeux@efficios.com> (raw)
In-Reply-To: <1348770199-1618-2-git-send-email-christian.babeux@efficios.com>

The health_check program is a simple utility to query the health
status of the different threads of the sessiond.

Sample output:

> ./health_check
Health check cmd: 0
Health check app. manage: 0
Health check app. registration: 0
Health check kernel: 0
Health check consumer: 0

The return code is encoded to indicate which thread has failed.

Signed-off-by: Christian Babeux <christian.babeux at efficios.com>
---
 tests/tools/health/Makefile.am    | 20 +++++++++++
 tests/tools/health/health_check.c | 73 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)
 create mode 100644 tests/tools/health/Makefile.am
 create mode 100644 tests/tools/health/health_check.c

diff --git a/tests/tools/health/Makefile.am b/tests/tools/health/Makefile.am
new file mode 100644
index 0000000..09573db
--- /dev/null
+++ b/tests/tools/health/Makefile.am
@@ -0,0 +1,20 @@
+AM_CFLAGS = -I. -O2 -g -I../../../include
+AM_LDFLAGS =
+
+if LTTNG_TOOLS_BUILD_WITH_LIBDL
+AM_LDFLAGS += -ldl
+endif
+if LTTNG_TOOLS_BUILD_WITH_LIBC_DL
+AM_LDFLAGS += -lc
+endif
+
+UTILS=
+
+noinst_PROGRAMS = health_check
+
+health_check_SOURCES = health_check.c $(UTILS)
+health_check_LDADD = $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
+		     $(top_builddir)/src/common/libcommon.la
+
+noinst_SCRIPTS =
+EXTRA_DIST =
diff --git a/tests/tools/health/health_check.c b/tests/tools/health/health_check.c
new file mode 100644
index 0000000..3eef110
--- /dev/null
+++ b/tests/tools/health/health_check.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012 - Christian Babeux <christian.babeux at efficios.com>
+ *
+ * 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
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+
+#include "lttng/lttng.h"
+
+#define HEALTH_CMD_FAIL     (1 << 0)
+#define HEALTH_APP_MNG_FAIL (1 << 1)
+#define HEALTH_APP_REG_FAIL (1 << 2)
+#define HEALTH_KERNEL_FAIL  (1 << 3)
+#define HEALTH_CSMR_FAIL    (1 << 4)
+
+int main(int argc, char *argv[])
+{
+	int health = -1;
+	int status = 0;
+
+	/* Command thread */
+	health = lttng_health_check(LTTNG_HEALTH_CMD);
+	printf("Health check cmd: %d\n", health);
+
+	if (health) {
+		status |= HEALTH_CMD_FAIL;
+	}
+
+	/* App manage thread */
+	health = lttng_health_check(LTTNG_HEALTH_APP_MANAGE);
+	printf("Health check app. manage: %d\n", health);
+
+	if (health) {
+		status |= HEALTH_APP_MNG_FAIL;
+	}
+	/* App registration thread */
+	health = lttng_health_check(LTTNG_HEALTH_APP_REG);
+	printf("Health check app. registration: %d\n", health);
+
+	if (health) {
+		status |= HEALTH_APP_REG_FAIL;
+	}
+
+	/* Kernel thread */
+	health = lttng_health_check(LTTNG_HEALTH_KERNEL);
+	printf("Health check kernel: %d\n", health);
+
+	if (health) {
+		status |= HEALTH_KERNEL_FAIL;
+	}
+
+	/* Consumer thread */
+	health = lttng_health_check(LTTNG_HEALTH_CONSUMER);
+	printf("Health check consumer: %d\n", health);
+
+	if (health) {
+		status |= HEALTH_CSMR_FAIL;
+	}
+
+	return status;
+}
-- 
1.7.12.1




           reply	other threads:[~2012-10-02 18:19 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1348770199-1618-2-git-send-email-christian.babeux@efficios.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349201959-9989-1-git-send-email-christian.babeux@efficios.com \
    --to=christian.babeux@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox