diff --git a/ctdb/common/ctdb_client.c b/ctdb/common/ctdb_client.c index c95dc65f183..0a02ac20693 100644 --- a/ctdb/common/ctdb_client.c +++ b/ctdb/common/ctdb_client.c @@ -1722,3 +1722,50 @@ int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t d return 0; } + +/* + set the monitoring mode of a remote node + */ +int ctdb_ctrl_setmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t monmode) +{ + int ret; + TDB_DATA data, outdata; + int32_t res; + + data.dsize = sizeof(uint32_t); + data.dptr = (unsigned char *)&monmode; + + ret = ctdb_control(ctdb, destnode, 0, + CTDB_CONTROL_SET_MONMODE, 0, data, + ctdb, &outdata, &res, &timeout, NULL); + if (ret != 0 || res != 0) { + DEBUG(0,(__location__ " ctdb_control for setmonmode failed\n")); + return -1; + } + + return 0; +} + +/* + get the monitoring mode of a remote node + */ +int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode) +{ + int ret; + TDB_DATA data, outdata; + int32_t res; + + ZERO_STRUCT(data); + ret = ctdb_control(ctdb, destnode, 0, + CTDB_CONTROL_GET_MONMODE, 0, data, + ctdb, &outdata, &res, &timeout, NULL); + if (ret != 0) { + DEBUG(0,(__location__ " ctdb_control for getrecmode failed\n")); + return -1; + } + + *monmode = res; + + return 0; +} + diff --git a/ctdb/common/ctdb_control.c b/ctdb/common/ctdb_control.c index 3c3a6d17d36..db01072d75b 100644 --- a/ctdb/common/ctdb_control.c +++ b/ctdb/common/ctdb_control.c @@ -241,6 +241,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); return ctdb_control_set_recmode(ctdb, indata, errormsg); + case CTDB_CONTROL_SET_MONMODE: + CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); + ctdb->monitoring_mode = *(uint32_t *)indata.dptr; + return 0; + + case CTDB_CONTROL_GET_MONMODE: + return ctdb->monitoring_mode; + case CTDB_CONTROL_SHUTDOWN: exit(10); diff --git a/ctdb/common/ctdb_monitor.c b/ctdb/common/ctdb_monitor.c index a2a65241aef..44b2c4a6639 100644 --- a/ctdb/common/ctdb_monitor.c +++ b/ctdb/common/ctdb_monitor.c @@ -34,6 +34,13 @@ static void ctdb_check_for_dead_nodes(struct event_context *ev, struct timed_eve struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context); int i; + if (ctdb->monitoring_mode==CTDB_MONITORING_DISABLED) { + event_add_timed(ctdb->ev, ctdb, + timeval_current_ofs(CTDB_MONITORING_TIMEOUT, 0), + ctdb_check_for_dead_nodes, ctdb); + return; + } + /* send a keepalive to all other nodes, unless */ for (i=0;inum_nodes;i++) { struct ctdb_node *node = ctdb->nodes[i]; diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h index a330f709a51..2c50d969656 100644 --- a/ctdb/include/ctdb.h +++ b/ctdb/include/ctdb.h @@ -299,6 +299,14 @@ int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint set the recovery mode of a remote node */ int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t recmode); +/* + get the monitoring mode of a remote node + */ +int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode); +/* + set the monitoringmode of a remote node + */ +int ctdb_ctrl_setmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t monmode); /* get the recovery master of a remote node diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 61abf41d27e..0ab79410ac1 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -234,10 +234,14 @@ struct ctdb_write_record { enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN}; +#define CTDB_MONITORING_ACTIVE 0 +#define CTDB_MONITORING_DISABLED 1 + /* main state of the ctdb daemon */ struct ctdb_context { struct event_context *ev; uint32_t recovery_mode; + uint32_t monitoring_mode; enum ctdb_freeze_mode freeze_mode; struct ctdb_freeze_handle *freeze_handle; struct ctdb_address address; @@ -367,6 +371,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS, CTDB_CONTROL_THAW, CTDB_CONTROL_GET_VNN, CTDB_CONTROL_SHUTDOWN, + CTDB_CONTROL_GET_MONMODE, + CTDB_CONTROL_SET_MONMODE, }; diff --git a/ctdb/tools/ctdb_control.c b/ctdb/tools/ctdb_control.c index df0d755d0a1..992991c2324 100644 --- a/ctdb/tools/ctdb_control.c +++ b/ctdb/tools/ctdb_control.c @@ -55,6 +55,8 @@ static void usage(void) " setrecmode set recovery mode\n" " getrecmaster get recovery master\n" " setrecmaster set recovery master\n" + " getmonmode get monitoring mode\n" + " setmonmode set monitoring mode\n" " attach attach a database\n" " getpid get the pid of a ctdb daemon\n" " shutdown shutdown a remote ctdb\n" @@ -420,6 +422,56 @@ static int control_setrecmode(struct ctdb_context *ctdb, int argc, const char ** return 0; } +/* + display monitoring mode of a remote node + */ +static int control_getmonmode(struct ctdb_context *ctdb, int argc, const char **argv) +{ + uint32_t vnn, monmode; + int ret; + + + if (argc < 1) { + usage(); + } + + vnn = strtoul(argv[0], NULL, 0); + + ret = ctdb_ctrl_getmonmode(ctdb, timeval_current_ofs(timelimit, 0), vnn, &monmode); + if (ret != 0) { + printf("Unable to get monmode from node %u\n", vnn); + return ret; + } + printf("Monitoring mode:%s (%d)\n",monmode==CTDB_MONITORING_ACTIVE?"ACTIVE":"DISABLED",monmode); + + return 0; +} + +/* + set the monitoring mode of a remote node + */ +static int control_setmonmode(struct ctdb_context *ctdb, int argc, const char **argv) +{ + uint32_t vnn, monmode; + int ret; + + + if (argc < 2) { + usage(); + } + + vnn = strtoul(argv[0], NULL, 0); + monmode = strtoul(argv[1], NULL, 0); + + ret = ctdb_ctrl_setmonmode(ctdb, timeval_current_ofs(timelimit, 0), vnn, monmode); + if (ret != 0) { + printf("Unable to set monmode on node %u\n", vnn); + return ret; + } + + return 0; +} + /* display recovery master of a remote node */ @@ -994,6 +1046,8 @@ int main(int argc, const char *argv[]) { "setrecmode", control_setrecmode }, { "getrecmaster", control_getrecmaster }, { "setrecmaster", control_setrecmaster }, + { "getmonmode", control_getmonmode }, + { "setmonmode", control_setmonmode }, { "ping", control_ping }, { "debug", control_debug }, { "debuglevel", control_debuglevel },