4 Copyright (C) Andrew Tridgell 2007
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "lib/events/events.h"
22 #include "system/filesys.h"
25 #include "../include/ctdb_private.h"
29 display status structure
31 static void show_status(struct ctdb_status *s)
33 printf(" client_packets_sent %u\n", s->client_packets_sent);
34 printf(" client_packets_recv %u\n", s->client_packets_recv);
35 printf(" req_call %u\n", s->client.req_call);
36 printf(" req_message %u\n", s->client.req_message);
37 printf(" req_finished %u\n", s->client.req_finished);
38 printf(" req_register %u\n", s->client.req_register);
39 printf(" req_connect_wait %u\n", s->client.req_connect_wait);
40 printf(" req_shutdown %u\n", s->client.req_shutdown);
41 printf(" req_status %u\n", s->client.req_status);
42 printf(" node_packets_sent %u\n", s->node_packets_sent);
43 printf(" node_packets_recv %u\n", s->node_packets_recv);
44 printf(" req_call %u\n", s->client.req_call);
45 printf(" reply_call %u\n", s->count.reply_call);
46 printf(" reply_redirect %u\n", s->count.reply_redirect);
47 printf(" req_dmaster %u\n", s->count.req_dmaster);
48 printf(" reply_dmaster %u\n", s->count.reply_dmaster);
49 printf(" reply_error %u\n", s->count.reply_error);
50 printf(" reply_redirect %u\n", s->count.reply_redirect);
51 printf(" req_message %u\n", s->count.req_message);
52 printf(" req_finished %u\n", s->count.req_finished);
53 printf(" total_calls %u\n", s->total_calls);
54 printf(" pending_calls %u\n", s->pending_calls);
55 printf(" lockwait_calls %u\n", s->lockwait_calls);
56 printf(" pending_lockwait_calls %u\n", s->pending_lockwait_calls);
57 printf(" max_call_latency %.6f seconds\n", s->max_call_latency);
58 printf(" max_lockwait_latency %.6f seconds\n", s->max_lockwait_latency);
64 static void usage(void)
66 printf("Usage: ctdb_status <socketpath>\n");
73 int main(int argc, const char *argv[])
75 struct ctdb_context *ctdb;
76 struct poptOption popt_options[] = {
82 const char **extra_argv;
86 struct event_context *ev;
87 const char *ctdb_socket;
88 struct ctdb_status status;
90 pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
92 while ((opt = poptGetNextOpt(pc)) != -1) {
95 fprintf(stderr, "Invalid option %s: %s\n",
96 poptBadOption(pc, 0), poptStrerror(opt));
101 /* setup the remaining options for the main program to use */
102 extra_argv = poptGetArgs(pc);
105 while (extra_argv[extra_argc]) extra_argc++;
108 if (extra_argc < 1) {
112 ctdb_socket = extra_argv[0];
114 ev = event_context_init(NULL);
116 /* initialise ctdb */
117 ctdb = ctdb_cmdline_client(ev, ctdb_socket);
119 printf("Failed to init ctdb\n");
123 ret = ctdb_status(ctdb, &status);
125 printf("Failed to get ctdb status\n");
129 show_status(&status);