From: Ronnie Sahlberg Date: Tue, 7 Aug 2007 02:51:25 +0000 (+1000) Subject: change error output in ctdb and in ctdb_cmdline_client to print to X-Git-Tag: tevent-0.9.20~348^2~2444^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d69055b789ac308ae35e157279f42969c7b9e9b3;p=thirdparty%2Fsamba.git change error output in ctdb and in ctdb_cmdline_client to print to stderr instead of stdout (This used to be ctdb commit 6e6e165c2d8f0963ce37567c23aaa012fc3e89d9) --- diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c index f8fca5e4a02..df01110e8a7 100644 --- a/ctdb/common/cmdline.c +++ b/ctdb/common/cmdline.c @@ -102,20 +102,20 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev) /* initialise ctdb */ ctdb = ctdb_init(ev); if (ctdb == NULL) { - printf("Failed to init ctdb\n"); + fprintf(stderr, "Failed to init ctdb\n"); exit(1); } /* tell ctdb the socket address */ ret = ctdb_set_socketname(ctdb, ctdb_cmdline.socketname); if (ret == -1) { - printf("ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb)); + fprintf(stderr, "ctdb_set_socketname failed - %s\n", ctdb_errstr(ctdb)); exit(1); } ret = ctdb_socket_connect(ctdb); if (ret != 0) { - DEBUG(0,(__location__ " Failed to connect to daemon\n")); + fprintf(stderr, __location__ " Failed to connect to daemon\n"); talloc_free(ctdb); return NULL; } diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 6e889abe41a..1663c78afd7 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -48,7 +48,7 @@ static int control_process_exists(struct ctdb_context *ctdb, int argc, const cha } if (sscanf(argv[0], "%u:%u", &vnn, &pid) != 2) { - printf("Badly formed vnn:pid\n"); + fprintf(stderr, "Badly formed vnn:pid\n"); return -1; } @@ -151,7 +151,7 @@ static int control_statistics_all(struct ctdb_context *ctdb) offsetof(struct ctdb_statistics, __last_counter) / sizeof(uint32_t); ret = ctdb_ctrl_statistics(ctdb, nodes[i], &s1); if (ret != 0) { - printf("Unable to get statistics from node %u\n", nodes[i]); + fprintf(stderr, "Unable to get statistics from node %u\n", nodes[i]); return ret; } for (j=0;jgeneration); @@ -287,14 +287,14 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_getrecmode(ctdb, TIMELIMIT(), options.vnn, &recmode); if (ret != 0) { - printf("Unable to get recmode from node %u\n", options.vnn); + fprintf(stderr, "Unable to get recmode from node %u\n", options.vnn); return ret; } printf("Recovery mode:%s (%d)\n",recmode==CTDB_RECOVERY_NORMAL?"NORMAL":"RECOVERY",recmode); ret = ctdb_ctrl_getrecmaster(ctdb, TIMELIMIT(), options.vnn, &recmaster); if (ret != 0) { - printf("Unable to get recmaster from node %u\n", options.vnn); + fprintf(stderr, "Unable to get recmaster from node %u\n", options.vnn); return ret; } printf("Recovery master:%d\n",recmaster); @@ -319,7 +319,7 @@ static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char * ret = ctdb_ctrl_get_tcp_tickles(ctdb, TIMELIMIT(), options.vnn, ctdb, vnn, &list); if (ret == -1) { - printf("Unable to list tickles\n"); + fprintf(stderr, "Unable to list tickles\n"); return -1; } @@ -348,18 +348,18 @@ static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv) } if (!parse_ip_port(argv[0], &killtcp.src)) { - printf("Bad IP:port '%s'\n", argv[0]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[0]); return -1; } if (!parse_ip_port(argv[1], &killtcp.dst)) { - printf("Bad IP:port '%s'\n", argv[1]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[1]); return -1; } ret = ctdb_ctrl_killtcp(ctdb, TIMELIMIT(), options.vnn, &killtcp); if (ret != 0) { - printf("Unable to killtcp from node %u\n", options.vnn); + fprintf(stderr, "Unable to killtcp from node %u\n", options.vnn); return ret; } @@ -379,18 +379,18 @@ static int tickle_tcp(struct ctdb_context *ctdb, int argc, const char **argv) } if (!parse_ip_port(argv[0], &src)) { - printf("Bad IP:port '%s'\n", argv[0]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[0]); return -1; } if (!parse_ip_port(argv[1], &dst)) { - printf("Bad IP:port '%s'\n", argv[1]); + fprintf(stderr, "Bad IP:port '%s'\n", argv[1]); return -1; } s = ctdb_sys_open_sending_socket(); if (s == -1) { - printf("Failed to open socket for sending tickle\n"); + fprintf(stderr, "Failed to open socket for sending tickle\n"); return 0; } @@ -399,7 +399,7 @@ static int tickle_tcp(struct ctdb_context *ctdb, int argc, const char **argv) if (ret==0) { return 0; } - printf("Error while sending tickle ack\n"); + fprintf(stderr, "Error while sending tickle ack\n"); return -1; } @@ -417,7 +417,7 @@ static int control_ip(struct ctdb_context *ctdb, int argc, const char **argv) ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.vnn, ctdb, &ips); if (ret != 0) { - printf("Unable to get public ips from node %u\n", options.vnn); + fprintf(stderr, "Unable to get public ips from node %u\n", options.vnn); return ret; } @@ -455,7 +455,7 @@ static int control_publicip(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.vnn, ctdb, &ips); if (ret != 0) { - printf("Unable to get public ips from node %u\n", options.vnn); + fprintf(stderr, "Unable to get public ips from node %u\n", options.vnn); return ret; } @@ -474,7 +474,7 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_getpid(ctdb, TIMELIMIT(), options.vnn, &pid); if (ret != 0) { - printf("Unable to get daemon pid from node %u\n", options.vnn); + fprintf(stderr, "Unable to get daemon pid from node %u\n", options.vnn); return ret; } printf("Pid:%d\n", pid); @@ -491,7 +491,7 @@ static int control_disable(struct ctdb_context *ctdb, int argc, const char **arg ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.vnn, NODE_FLAGS_PERMANENTLY_DISABLED, 0); if (ret != 0) { - printf("Unable to disable node %u\n", options.vnn); + fprintf(stderr, "Unable to disable node %u\n", options.vnn); return ret; } @@ -507,7 +507,7 @@ static int control_enable(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_modflags(ctdb, TIMELIMIT(), options.vnn, 0, NODE_FLAGS_PERMANENTLY_DISABLED); if (ret != 0) { - printf("Unable to enable node %u\n", options.vnn); + fprintf(stderr, "Unable to enable node %u\n", options.vnn); return ret; } @@ -590,7 +590,7 @@ static int control_shutdown(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_shutdown(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to shutdown node %u\n", options.vnn); + fprintf(stderr, "Unable to shutdown node %u\n", options.vnn); return ret; } @@ -606,13 +606,13 @@ static int control_recover(struct ctdb_context *ctdb, int argc, const char **arg ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to freeze node\n"); + fprintf(stderr, "Unable to freeze node\n"); return ret; } ret = ctdb_ctrl_setrecmode(ctdb, TIMELIMIT(), options.vnn, CTDB_RECOVERY_ACTIVE); if (ret != 0) { - printf("Unable to set recovery mode\n"); + fprintf(stderr, "Unable to set recovery mode\n"); return ret; } @@ -630,7 +630,7 @@ static int control_getmonmode(struct ctdb_context *ctdb, int argc, const char ** ret = ctdb_ctrl_getmonmode(ctdb, TIMELIMIT(), options.vnn, &monmode); if (ret != 0) { - printf("Unable to get monmode from node %u\n", options.vnn); + fprintf(stderr, "Unable to get monmode from node %u\n", options.vnn); return ret; } printf("Monitoring mode:%s (%d)\n",monmode==CTDB_MONITORING_ACTIVE?"ACTIVE":"DISABLED",monmode); @@ -654,7 +654,7 @@ static int control_setmonmode(struct ctdb_context *ctdb, int argc, const char ** ret = ctdb_ctrl_setmonmode(ctdb, TIMELIMIT(), options.vnn, monmode); if (ret != 0) { - printf("Unable to set monmode on node %u\n", options.vnn); + fprintf(stderr, "Unable to set monmode on node %u\n", options.vnn); return ret; } @@ -685,7 +685,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv) /* traverse and dump the cluster tdb */ ret = ctdb_dump_db(ctdb_db, stdout); if (ret == -1) { - printf("Unable to dump database\n"); + fprintf(stderr, "Unable to dump database\n"); return -1; } talloc_free(ctdb_db); @@ -705,7 +705,7 @@ static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_getdbmap(ctdb, TIMELIMIT(), options.vnn, ctdb, &dbmap); if (ret != 0) { - printf("Unable to get dbids from node %u\n", options.vnn); + fprintf(stderr, "Unable to get dbids from node %u\n", options.vnn); return ret; } @@ -756,7 +756,7 @@ static int control_getvar(struct ctdb_context *ctdb, int argc, const char **argv name = argv[0]; ret = ctdb_ctrl_get_tunable(ctdb, TIMELIMIT(), options.vnn, name, &value); if (ret == -1) { - printf("Unable to get tunable variable '%s'\n", name); + fprintf(stderr, "Unable to get tunable variable '%s'\n", name); return -1; } @@ -782,7 +782,7 @@ static int control_setvar(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_set_tunable(ctdb, TIMELIMIT(), options.vnn, name, value); if (ret == -1) { - printf("Unable to set tunable variable '%s'\n", name); + fprintf(stderr, "Unable to set tunable variable '%s'\n", name); return -1; } return 0; @@ -799,7 +799,7 @@ static int control_listvars(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_list_tunables(ctdb, TIMELIMIT(), options.vnn, ctdb, &list, &count); if (ret == -1) { - printf("Unable to list tunable variables\n"); + fprintf(stderr, "Unable to list tunable variables\n"); return -1; } @@ -822,7 +822,7 @@ static int control_getdebug(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_get_debuglevel(ctdb, options.vnn, &level); if (ret != 0) { - printf("Unable to get debuglevel response from node %u\n", + fprintf(stderr, "Unable to get debuglevel response from node %u\n", options.vnn); } else { printf("Node %u is at debug level %u\n", options.vnn, level); @@ -847,7 +847,7 @@ static int control_setdebug(struct ctdb_context *ctdb, int argc, const char **ar ret = ctdb_ctrl_set_debuglevel(ctdb, options.vnn, level); if (ret != 0) { - printf("Unable to set debug level on node %u\n", options.vnn); + fprintf(stderr, "Unable to set debug level on node %u\n", options.vnn); } return 0; } @@ -862,7 +862,7 @@ static int control_freeze(struct ctdb_context *ctdb, int argc, const char **argv ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to freeze node %u\n", options.vnn); + fprintf(stderr, "Unable to freeze node %u\n", options.vnn); } return 0; } @@ -876,7 +876,7 @@ static int control_thaw(struct ctdb_context *ctdb, int argc, const char **argv) ret = ctdb_ctrl_thaw(ctdb, TIMELIMIT(), options.vnn); if (ret != 0) { - printf("Unable to thaw node %u\n", options.vnn); + fprintf(stderr, "Unable to thaw node %u\n", options.vnn); } return 0; } @@ -1041,7 +1041,7 @@ int main(int argc, const char *argv[]) /* initialise ctdb */ ctdb = ctdb_cmdline_client(ev); if (ctdb == NULL) { - printf("Failed to init ctdb\n"); + fprintf(stderr, "Failed to init ctdb\n"); exit(1); } @@ -1075,7 +1075,7 @@ int main(int argc, const char *argv[]) } if (i == ARRAY_SIZE(ctdb_commands)) { - printf("Unknown control '%s'\n", control); + fprintf(stderr, "Unknown control '%s'\n", control); exit(1); }