e76b4b2e2625bebc19eba052a658d131247e236d
[obnox/samba/samba-obnox.git] / ctdb / utils / pmda / pmda_ctdb.c
1 /*
2  * CTDB Performance Metrics Domain Agent (PMDA) for Performance Co-Pilot (PCP)
3  *
4  * Copyright (c) 1995,2004 Silicon Graphics, Inc.  All Rights Reserved.
5  * Copyright (c) 2011 David Disseldorp
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation; either version 2 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20  */
21
22 #include "replace.h"
23 #include "system/network.h"
24
25 #include <talloc.h>
26 #include <tevent.h>
27
28 #include "lib/util/time.h"
29
30 #include "ctdb_private.h"
31 #include "ctdb_client.h"
32 #include "ctdb_protocol.h"
33
34 #include "common/system.h"
35 #include "common/common.h"
36
37 #include <pcp/pmapi.h>
38 #include <pcp/impl.h>
39 #include <pcp/pmda.h>
40
41 #include "domain.h"
42
43 /*
44  * CTDB PMDA
45  *
46  * This PMDA connects to the locally running ctdbd daemon and pulls
47  * statistics for export via PCP. The ctdbd Unix domain socket path can be
48  * specified with the CTDB_SOCKET environment variable, otherwise the default
49  * path is used.
50  */
51
52 /*
53  * All metrics supported in this PMDA - one table entry for each.
54  * The 4th field specifies the serial number of the instance domain
55  * for the metric, and must be either PM_INDOM_NULL (denoting a
56  * metric that only ever has a single value), or the serial number
57  * of one of the instance domains declared in the instance domain table
58  * (i.e. in indomtab, above).
59  */
60 static pmdaMetric metrictab[] = {
61         /* num_clients */
62         { NULL, { PMDA_PMID(0,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
63                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
64         /* frozen */
65         { NULL, { PMDA_PMID(0,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
66                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
67         /* recovering */
68         { NULL, { PMDA_PMID(0,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
69                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
70         /* client_packets_sent */
71         { NULL, { PMDA_PMID(0,3), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
72                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
73         /* client_packets_recv */
74         { NULL, { PMDA_PMID(0,4), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
75                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
76         /* node_packets_sent */
77         { NULL, { PMDA_PMID(0,5), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
78                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
79         /* node_packets_recv */
80         { NULL, { PMDA_PMID(0,6), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
81                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
82         /* keepalive_packets_sent */
83         { NULL, { PMDA_PMID(0,7), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
84                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
85         /* keepalive_packets_recv */
86         { NULL, { PMDA_PMID(0,8), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
87                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
88         /* req_call */
89         { NULL, { PMDA_PMID(1,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
90                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
91         /* reply_call */
92         { NULL, { PMDA_PMID(1,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
93                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
94         /* req_dmaster */
95         { NULL, { PMDA_PMID(1,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
96                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
97         /* reply_dmaster */
98         { NULL, { PMDA_PMID(1,3), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
99                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
100         /* reply_error */
101         { NULL, { PMDA_PMID(1,4), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
102                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
103         /* req_message */
104         { NULL, { PMDA_PMID(1,5), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
105                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
106         /* req_control */
107         { NULL, { PMDA_PMID(1,6), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
108                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
109         /* reply_control */
110         { NULL, { PMDA_PMID(1,7), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
111                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
112         /* req_call */
113         { NULL, { PMDA_PMID(2,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
114                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
115         /* req_message */
116         { NULL, { PMDA_PMID(2,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
117                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
118         /* req_control */
119         { NULL, { PMDA_PMID(2,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
120                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
121         /* call */
122         { NULL, { PMDA_PMID(3,0), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
123                 PMDA_PMUNITS(0,0,1,0,0,0) }, },
124         /* control */
125         { NULL, { PMDA_PMID(3,1), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
126                 PMDA_PMUNITS(0,0,1,0,0,0) }, },
127         /* traverse */
128         { NULL, { PMDA_PMID(3,2), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
129                 PMDA_PMUNITS(0,0,1,0,0,0) }, },
130         /* total_calls */
131         { NULL, { PMDA_PMID(0,9), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
132                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
133         /* pending_calls */
134         { NULL, { PMDA_PMID(0,10), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
135                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
136         /* locks.num_calls */
137         { NULL, { PMDA_PMID(0,11), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
138                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
139         /* locks.num_pending */
140         { NULL, { PMDA_PMID(0,12), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
141                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
142         /* childwrite_calls */
143         { NULL, { PMDA_PMID(0,13), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_COUNTER,
144                 PMDA_PMUNITS(0,0,1,0,0,PM_COUNT_ONE) }, },
145         /* pending_childwrite_calls */
146         { NULL, { PMDA_PMID(0,14), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
147                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
148         /* memory_used */
149         { NULL, { PMDA_PMID(0,15), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
150                 PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
151         /* max_hop_count */
152         { NULL, { PMDA_PMID(0,16), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
153                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
154         /* reclock.ctdbd.max */
155         { NULL, { PMDA_PMID(0,17), PM_TYPE_DOUBLE, PM_INDOM_NULL, PM_SEM_INSTANT,
156                 PMDA_PMUNITS(0,1,0,0,PM_TIME_SEC,0) }, },
157         /* reclock.recd.max */
158         { NULL, { PMDA_PMID(0,18), PM_TYPE_DOUBLE, PM_INDOM_NULL, PM_SEM_INSTANT,
159                 PMDA_PMUNITS(0,1,0,0,PM_TIME_SEC,0) }, },
160         /* call_latency.max */
161         { NULL, { PMDA_PMID(0,19), PM_TYPE_DOUBLE, PM_INDOM_NULL, PM_SEM_INSTANT,
162                 PMDA_PMUNITS(0,1,0,0,PM_TIME_SEC,0) }, },
163         /* locks.latency.max */
164         { NULL, { PMDA_PMID(0,20), PM_TYPE_DOUBLE, PM_INDOM_NULL, PM_SEM_INSTANT,
165                 PMDA_PMUNITS(0,1,0,0,PM_TIME_SEC,0) }, },
166         /* childwrite_latency.max */
167         { NULL, { PMDA_PMID(0,21), PM_TYPE_DOUBLE, PM_INDOM_NULL, PM_SEM_INSTANT,
168                 PMDA_PMUNITS(0,1,0,0,PM_TIME_SEC,0) }, },
169         /* num_recoveries */
170         { NULL, { PMDA_PMID(0,22), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_INSTANT,
171                 PMDA_PMUNITS(0,0,0,0,0,0) }, },
172 };
173
174 static struct tevent_context *ev;
175 static struct ctdb_context *ctdb;
176 static struct ctdb_statistics *stats;
177
178 static void
179 pmda_ctdb_q_read_cb(uint8_t *data, size_t cnt, void *args)
180 {
181         if (cnt == 0) {
182                 fprintf(stderr, "ctdbd unreachable\n");
183                 /* cleanup on request timeout */
184                 return;
185         }
186
187         ctdb_client_read_cb(data, cnt, args);
188 }
189
190
191 static int
192 pmda_ctdb_daemon_connect(void)
193 {
194         const char *socket_name;
195         int ret;
196         struct sockaddr_un addr;
197
198         ev = tevent_context_init(NULL);
199         if (ev == NULL) {
200                 fprintf(stderr, "Failed to init event ctx\n");
201                 return -1;
202         }
203
204         ctdb = ctdb_init(ev);
205         if (ctdb == NULL) {
206                 fprintf(stderr, "Failed to init ctdb\n");
207                 goto err_ev;
208         }
209
210         socket_name = getenv("CTDB_SOCKET");
211         if (socket_name == NULL) {
212                 socket_name = CTDB_SOCKET;
213         }
214
215         ret = ctdb_set_socketname(ctdb, socket_name);
216         if (ret == -1) {
217                 fprintf(stderr, "ctdb_set_socketname failed - %s\n",
218                                 ctdb_errstr(ctdb));
219                 goto err_ctdb;
220         }
221
222         /*
223          * ctdb_socket_connect() sets a default queue callback handler that
224          * calls exit() if ctdbd is unavailable on recv, use our own wrapper to
225          * work around this
226          */
227
228         memset(&addr, 0, sizeof(addr));
229         addr.sun_family = AF_UNIX;
230         strncpy(addr.sun_path, ctdb->daemon.name, sizeof(addr.sun_path));
231
232         ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0);
233         if (ctdb->daemon.sd == -1) {
234                 fprintf(stderr, "Failed to open client socket\n");
235                 goto err_ctdb;
236         }
237
238         set_nonblocking(ctdb->daemon.sd);
239         set_close_on_exec(ctdb->daemon.sd);
240
241         if (connect(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
242                 fprintf(stderr, "Failed to connect to ctdb daemon via %s\n",
243                         ctdb->daemon.name);
244                 goto err_sd;
245         }
246
247         ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd,
248                                               CTDB_DS_ALIGNMENT,
249                                               pmda_ctdb_q_read_cb, ctdb,
250                                               "to-ctdbd");
251         if (ctdb->daemon.queue == NULL) {
252                 fprintf(stderr, "Failed to setup queue\n");
253                 goto err_sd;
254         }
255
256         ctdb->pnn = ctdb_ctrl_getpnn(ctdb, timeval_current_ofs(3, 0),
257                                      CTDB_CURRENT_NODE);
258         if (ctdb->pnn == (uint32_t)-1) {
259                 fprintf(stderr, "Failed to get ctdb pnn\n");
260                 goto err_sd;
261         }
262
263         return 0;
264 err_sd:
265         close(ctdb->daemon.sd);
266 err_ctdb:
267         talloc_free(ctdb);
268 err_ev:
269         talloc_free(ev);
270         ctdb = NULL;
271         return -1;
272 }
273
274 static void
275 pmda_ctdb_daemon_disconnect(void)
276 {
277         if (ctdb->methods) {
278                 ctdb->methods->shutdown(ctdb);
279         }
280
281         if (ctdb->daemon.sd != -1) {
282                 close(ctdb->daemon.sd);
283         }
284
285         talloc_free(ctdb);
286         talloc_free(ev);
287         ctdb = NULL;
288 }
289
290 static int
291 fill_base(unsigned int item, pmAtomValue *atom)
292 {
293         switch (item) {
294         case 0:
295                 atom->ul = stats->num_clients;
296                 break;
297         case 1:
298                 atom->ul = stats->frozen;
299                 break;
300         case 2:
301                 atom->ul = stats->recovering;
302                 break;
303         case 3:
304                 atom->ul = stats->client_packets_sent;
305                 break;
306         case 4:
307                 atom->ul = stats->client_packets_recv;
308                 break;
309         case 5:
310                 atom->ul = stats->node_packets_sent;
311                 break;
312         case 6:
313                 atom->ul = stats->node_packets_recv;
314                 break;
315         case 7:
316                 atom->ul = stats->keepalive_packets_sent;
317                 break;
318         case 8:
319                 atom->ul = stats->keepalive_packets_recv;
320                 break;
321         case 9:
322                 atom->ul = stats->total_calls;
323                 break;
324         case 10:
325                 atom->ul = stats->pending_calls;
326                 break;
327         case 11:
328                 atom->ul = stats->locks.num_calls;
329                 break;
330         case 12:
331                 atom->ul = stats->locks.num_pending;
332                 break;
333         case 13:
334                 atom->ul = stats->childwrite_calls;
335                 break;
336         case 14:
337                 atom->ul = stats->pending_childwrite_calls;
338                 break;
339         case 15:
340                 atom->ul = stats->memory_used;
341                 break;
342         case 16:
343                 atom->ul = stats->max_hop_count;
344                 break;
345         case 17:
346                 atom->d = stats->reclock.ctdbd.max;
347                 break;
348         case 18:
349                 atom->d = stats->reclock.recd.max;
350                 break;
351         case 19:
352                 atom->d = stats->call_latency.max;
353                 break;
354         case 20:
355                 atom->d = stats->locks.latency.max;
356                 break;
357         case 21:
358                 atom->d = stats->childwrite_latency.max;
359                 break;
360         case 22:
361                 atom->d = stats->num_recoveries;
362                 break;
363         default:
364                 return PM_ERR_PMID;
365         }
366
367         return 0;
368 }
369
370 static int
371 fill_node(unsigned int item, pmAtomValue *atom)
372 {
373         switch (item) {
374         case 0:
375                atom->ul = stats->node.req_call;
376                break;
377         case 1:
378                atom->ul = stats->node.reply_call;
379                break;
380         case 2:
381                atom->ul = stats->node.req_dmaster;
382                break;
383         case 3:
384                atom->ul = stats->node.reply_dmaster;
385                break;
386         case 4:
387                atom->ul = stats->node.reply_error;
388                break;
389         case 5:
390                atom->ul = stats->node.req_message;
391                break;
392         case 6:
393                atom->ul = stats->node.req_control;
394                break;
395         case 7:
396                 atom->ul = stats->node.reply_control;
397                 break;
398         default:
399                 return PM_ERR_PMID;
400         }
401
402         return 0;
403 }
404
405
406 static int
407 fill_client(unsigned int item, pmAtomValue *atom)
408 {
409         switch (item) {
410         case 0:
411                 atom->ul = stats->client.req_call;
412                 break;
413         case 1:
414                 atom->ul = stats->client.req_message;
415                 break;
416         case 2:
417                 atom->ul = stats->client.req_control;
418                 break;
419         default:
420                 return PM_ERR_PMID;
421         }
422
423         return 0;
424 }
425
426 static int
427 fill_timeout(unsigned int item, pmAtomValue *atom)
428 {
429         switch (item) {
430         case 0:
431                 atom->ul = stats->timeouts.call;
432                 break;
433         case 1:
434                 atom->ul = stats->timeouts.control;
435                 break;
436         case 2:
437                 atom->ul = stats->timeouts.traverse;
438                 break;
439         default:
440                 return PM_ERR_PMID;
441         }
442
443         return 0;
444 }
445
446 /*
447  * callback provided to pmdaFetch
448  */
449 static int
450 pmda_ctdb_fetch_cb(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
451 {
452         int ret;
453         __pmID_int *id = (__pmID_int *)&(mdesc->m_desc.pmid);
454
455         if (inst != PM_IN_NULL) {
456                 return PM_ERR_INST;
457         }
458
459         if (stats == NULL) {
460                 fprintf(stderr, "stats not available\n");
461                 ret = PM_ERR_VALUE;
462                 goto err_out;
463         }
464
465
466         switch (id->cluster) {
467         case 0:
468                 ret = fill_base(id->item, atom);
469                 if (ret) {
470                         goto err_out;
471                 }
472                 break;
473         case 1:
474                 ret = fill_node(id->item, atom);
475                 if (ret) {
476                         goto err_out;
477                 }
478                 break;
479         case 2:
480                 ret = fill_client(id->item, atom);
481                 if (ret) {
482                         goto err_out;
483                 }
484                 break;
485         case 3:
486                 ret = fill_timeout(id->item, atom);
487                 if (ret) {
488                         goto err_out;
489                 }
490                 break;
491         default:
492                 return PM_ERR_PMID;
493         }
494
495         ret = 0;
496 err_out:
497         return ret;
498 }
499
500 /*
501  * This routine is called once for each pmFetch(3) operation, so is a
502  * good place to do once-per-fetch functions, such as value caching or
503  * instance domain evaluation.
504  */
505 static int
506 pmda_ctdb_fetch(int numpmid, pmID pmidlist[], pmResult **resp, pmdaExt *pmda)
507 {
508         int ret;
509         TDB_DATA data;
510         int32_t res;
511         struct timeval ctdb_timeout;
512
513         if (ctdb == NULL) {
514                 fprintf(stderr, "attempting reconnect to ctdbd\n");
515                 ret = pmda_ctdb_daemon_connect();
516                 if (ret < 0) {
517                         fprintf(stderr, "reconnect failed\n");
518                         return PM_ERR_VALUE;
519                 }
520         }
521
522         ctdb_timeout = timeval_current_ofs(1, 0);
523         ret = ctdb_control(ctdb, ctdb->pnn, 0,
524                            CTDB_CONTROL_STATISTICS, 0, tdb_null,
525                            ctdb, &data, &res, &ctdb_timeout, NULL);
526
527         if (ret != 0 || res != 0) {
528                 fprintf(stderr, "ctdb control for statistics failed, reconnecting\n");
529                 pmda_ctdb_daemon_disconnect();
530                 ret = PM_ERR_VALUE;
531                 goto err_out;
532         }
533
534         stats = (struct ctdb_statistics *)data.dptr;
535
536         if (data.dsize != sizeof(struct ctdb_statistics)) {
537                 fprintf(stderr, "incorrect statistics size %zu - not %zu\n",
538                         data.dsize, sizeof(struct ctdb_statistics));
539                 ret = PM_ERR_VALUE;
540                 goto err_stats;
541         }
542
543         ret = pmdaFetch(numpmid, pmidlist, resp, pmda);
544
545 err_stats:
546         talloc_free(stats);
547 err_out:
548         return ret;
549 }
550
551 void pmda_ctdb_init(pmdaInterface *dp);
552
553 /*
554  * Initialise the agent
555  */
556 void
557 pmda_ctdb_init(pmdaInterface *dp)
558 {
559         if (dp->status != 0) {
560                 return;
561         }
562
563         dp->version.two.fetch = pmda_ctdb_fetch;
564         pmdaSetFetchCallBack(dp, pmda_ctdb_fetch_cb);
565
566         pmdaInit(dp, NULL, 0, metrictab,
567                  (sizeof(metrictab) / sizeof(metrictab[0])));
568 }
569
570 static char *
571 helpfile(void)
572 {
573         static char buf[MAXPATHLEN];
574
575         if (!buf[0]) {
576                 snprintf(buf, sizeof(buf), "%s/ctdb/help",
577                          pmGetConfig("PCP_PMDAS_DIR"));
578         }
579         return buf;
580 }
581
582 static void
583 usage(void)
584 {
585         fprintf(stderr, "Usage: %s [options]\n\n", pmProgname);
586         fputs("Options:\n"
587           "  -d domain        use domain (numeric) for metrics domain of PMDA\n"
588           "  -l logfile       write log into logfile rather than using default log name\n"
589           "\nExactly one of the following options may appear:\n"
590           "  -i port          expect PMCD to connect on given inet port (number or name)\n"
591           "  -p               expect PMCD to supply stdin/stdout (pipe)\n"
592           "  -u socket        expect PMCD to connect on given unix domain socket\n",
593           stderr);
594         exit(1);
595 }
596
597 /*
598  * Set up the agent if running as a daemon.
599  */
600 int
601 main(int argc, char **argv)
602 {
603         int err = 0;
604         char log_file[] = "pmda_ctdb.log";
605         pmdaInterface dispatch;
606
607         __pmSetProgname(argv[0]);
608
609         pmdaDaemon(&dispatch, PMDA_INTERFACE_2, pmProgname, CTDB,
610                    log_file, helpfile());
611
612         if (pmdaGetOpt(argc, argv, "d:i:l:pu:?", &dispatch, &err) != EOF) {
613                 err++;
614         }
615
616         if (err) {
617                 usage();
618         }
619
620         pmdaOpenLog(&dispatch);
621         pmda_ctdb_init(&dispatch);
622         pmdaConnect(&dispatch);
623         pmdaMain(&dispatch);
624
625         exit(0);
626 }
627