summaryrefslogtreecommitdiff
path: root/source4/cluster/ctdb/tools
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-04-21 07:23:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:51:17 -0500
commit650d81b252cc669ef848448afad7e9bb79c4f20e (patch)
tree7108ada18c4d7fff581470791832850c17eab6bf /source4/cluster/ctdb/tools
parent66a9f1e2764900a2c22a4bfad9f9caf3db729385 (diff)
downloadsamba-650d81b252cc669ef848448afad7e9bb79c4f20e.tar.gz
samba-650d81b252cc669ef848448afad7e9bb79c4f20e.tar.bz2
samba-650d81b252cc669ef848448afad7e9bb79c4f20e.zip
r22421: merged in latest ctdb changes from bzr
(This used to be commit 3633f862b966866819c9a0a6ad0238a858e15e62)
Diffstat (limited to 'source4/cluster/ctdb/tools')
-rw-r--r--source4/cluster/ctdb/tools/ctdb_status.c133
1 files changed, 133 insertions, 0 deletions
diff --git a/source4/cluster/ctdb/tools/ctdb_status.c b/source4/cluster/ctdb/tools/ctdb_status.c
new file mode 100644
index 0000000000..af4c62488d
--- /dev/null
+++ b/source4/cluster/ctdb/tools/ctdb_status.c
@@ -0,0 +1,133 @@
+/*
+ ctdb status tool
+
+ Copyright (C) Andrew Tridgell 2007
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include "includes.h"
+#include "lib/events/events.h"
+#include "system/filesys.h"
+#include "popt.h"
+#include "cmdline.h"
+#include "../include/ctdb_private.h"
+
+
+/*
+ display status structure
+ */
+static void show_status(struct ctdb_status *s)
+{
+ printf(" client_packets_sent %u\n", s->client_packets_sent);
+ printf(" client_packets_recv %u\n", s->client_packets_recv);
+ printf(" req_call %u\n", s->client.req_call);
+ printf(" req_message %u\n", s->client.req_message);
+ printf(" req_finished %u\n", s->client.req_finished);
+ printf(" req_register %u\n", s->client.req_register);
+ printf(" req_connect_wait %u\n", s->client.req_connect_wait);
+ printf(" req_shutdown %u\n", s->client.req_shutdown);
+ printf(" req_status %u\n", s->client.req_status);
+ printf(" node_packets_sent %u\n", s->node_packets_sent);
+ printf(" node_packets_recv %u\n", s->node_packets_recv);
+ printf(" req_call %u\n", s->client.req_call);
+ printf(" reply_call %u\n", s->count.reply_call);
+ printf(" reply_redirect %u\n", s->count.reply_redirect);
+ printf(" req_dmaster %u\n", s->count.req_dmaster);
+ printf(" reply_dmaster %u\n", s->count.reply_dmaster);
+ printf(" reply_error %u\n", s->count.reply_error);
+ printf(" reply_redirect %u\n", s->count.reply_redirect);
+ printf(" req_message %u\n", s->count.req_message);
+ printf(" req_finished %u\n", s->count.req_finished);
+ printf(" total_calls %u\n", s->total_calls);
+ printf(" pending_calls %u\n", s->pending_calls);
+ printf(" lockwait_calls %u\n", s->lockwait_calls);
+ printf(" pending_lockwait_calls %u\n", s->pending_lockwait_calls);
+ printf(" max_call_latency %.6f seconds\n", s->max_call_latency);
+ printf(" max_lockwait_latency %.6f seconds\n", s->max_lockwait_latency);
+}
+
+/*
+ show usage message
+ */
+static void usage(void)
+{
+ printf("Usage: ctdb_status <socketpath>\n");
+ exit(1);
+}
+
+/*
+ main program
+*/
+int main(int argc, const char *argv[])
+{
+ struct ctdb_context *ctdb;
+ struct poptOption popt_options[] = {
+ POPT_AUTOHELP
+ POPT_CTDB_CMDLINE
+ POPT_TABLEEND
+ };
+ int opt;
+ const char **extra_argv;
+ int extra_argc = 0;
+ int ret;
+ poptContext pc;
+ struct event_context *ev;
+ const char *ctdb_socket;
+ struct ctdb_status status;
+
+ pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
+
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ default:
+ fprintf(stderr, "Invalid option %s: %s\n",
+ poptBadOption(pc, 0), poptStrerror(opt));
+ exit(1);
+ }
+ }
+
+ /* setup the remaining options for the main program to use */
+ extra_argv = poptGetArgs(pc);
+ if (extra_argv) {
+ extra_argv++;
+ while (extra_argv[extra_argc]) extra_argc++;
+ }
+
+ if (extra_argc < 1) {
+ usage();
+ }
+
+ ctdb_socket = extra_argv[0];
+
+ ev = event_context_init(NULL);
+
+ /* initialise ctdb */
+ ctdb = ctdb_cmdline_client(ev, ctdb_socket);
+ if (ctdb == NULL) {
+ printf("Failed to init ctdb\n");
+ exit(1);
+ }
+
+ ret = ctdb_status(ctdb, &status);
+ if (ret != 0) {
+ printf("Failed to get ctdb status\n");
+ exit(1);
+ }
+
+ show_status(&status);
+
+ return 0;
+}