From 5ec1391ac616458db01fae1188fdbc1ba130cabc Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 8 Jun 2009 10:49:25 -0500 Subject: cpgx: improve options Signed-off-by: David Teigland --- cpgx/cpgx.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'cpgx/cpgx.c') diff --git a/cpgx/cpgx.c b/cpgx/cpgx.c index 398c715..c2555ad 100644 --- a/cpgx/cpgx.c +++ b/cpgx/cpgx.c @@ -53,6 +53,9 @@ static char *exec_name = "corosync"; #define DUMP_SIZE (1024 * 1024) #define HISTORY_EVENTS (1024 * 1024) #define DEFAULT_SYNC_MAX 2000 /* sync up to this many events */ +#define DEFAULT_TIMEOUT_SEC 60 +#define DEFAULT_PORT 5405 +#define DEFAULT_RESTART_SEC 10 #define DUMP_WRITE_PATH "/var/log/cluster/cpgx_debug.txt" #define LEAVE_TIME_MAX 10 /* leave or exit up to this long after join*/ @@ -137,7 +140,7 @@ static int dct_cpg_fd; static char iptables_a[128]; static char iptables_d[128]; static char exec_addr[64]; -static int exec_port = 5405; +static int exec_port = DEFAULT_PORT; static int exec_join = 0; static int prog_quit; static int cluster_down; @@ -145,7 +148,8 @@ static int opt_leave = 1; static int opt_exit = 1; static int opt_die = 0; static int iterations_sec = 0; -static int timeout_sec = 0; +static int timeout_sec = DEFAULT_TIMEOUT_SEC; +static int restart_sec = DEFAULT_RESTART_SEC; static int run_iptables = 0; static int continue_after_error = 0; static int opt_print_event = 1; @@ -1511,7 +1515,7 @@ void restart_cluster(void) /* others should see us fail before we rejoin, not sure 10s will be enough for some people */ - sleep(10); + sleep(restart_sec); system(iptables_d); @@ -1652,17 +1656,19 @@ void print_usage(void) printf(" (program kills and restarts %s)\n", exec_name); printf(" -s sync up to num events, default %d\n", DEFAULT_SYNC_MAX); - printf(" -t timeout after no dispatch for this many seconds, default 0 (never)\n"); + printf(" -t timeout after no dispatch for this many seconds, default %d\n", DEFAULT_TIMEOUT_SEC); + printf(" (0 to wait forever)\n"); printf(" -i run for this many seconds, default 0 (forever)\n"); - printf(" -j join cluster by running \"%s\", not cman_tool\n", exec_name); - printf(" (used by -d restart after killing %s\n", exec_name); - printf(" -a IP address used for %s communication\n", exec_name); - printf(" (implies that iptables should be used with -d)\n"); - printf(" -p udp port used for %s communication\n", exec_name); - printf(" -I [A|D] run iptables Append or Delete to block/unblock %s communication\n", exec_name); - printf(" (use with -a and optionally -p)\n"); printf(" -c continue after error\n"); printf(" -V print version\n"); + printf(" die options, used with -d1:\n"); + printf(" -j restart cluster by running \"%s\", not cman_tool\n", exec_name); + printf(" -w wait this many seconds between kill and restart, default %d\n", DEFAULT_RESTART_SEC); + printf(" -a IP address used for %s communication\n", exec_name); + printf(" iptables blocks before kill, unblocks before restart\n"); + printf(" -p udp port used for %s communication, default %d\n", exec_name, DEFAULT_PORT); + printf(" -I [A|D] run iptables Append or Delete to block/unblock %s comms\n", exec_name); + printf(" (utility, not used by test, use with -a, optionally -p)\n"); printf("\n"); printf("Output:\n"); printf("