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;
+}
+
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);
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;i<ctdb->num_nodes;i++) {
struct ctdb_node *node = ctdb->nodes[i];
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
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;
CTDB_CONTROL_THAW,
CTDB_CONTROL_GET_VNN,
CTDB_CONTROL_SHUTDOWN,
+ CTDB_CONTROL_GET_MONMODE,
+ CTDB_CONTROL_SET_MONMODE,
};
" setrecmode <vnn> <mode> set recovery mode\n"
" getrecmaster <vnn> get recovery master\n"
" setrecmaster <vnn> <master_vnn> set recovery master\n"
+ " getmonmode <vnn> get monitoring mode\n"
+ " setmonmode <vnn> <mode> set monitoring mode\n"
" attach <dbname> attach a database\n"
" getpid <vnn> get the pid of a ctdb daemon\n"
" shutdown <vnn> shutdown a remote ctdb\n"
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
*/
{ "setrecmode", control_setrecmode },
{ "getrecmaster", control_getrecmaster },
{ "setrecmaster", control_setrecmaster },
+ { "getmonmode", control_getmonmode },
+ { "setmonmode", control_setmonmode },
{ "ping", control_ping },
{ "debug", control_debug },
{ "debuglevel", control_debuglevel },