diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 9d7ef84ba6b..095e528d127 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -3651,3 +3651,26 @@ int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval return 0; } + +/* + get the name of the reclock file + */ +int ctdb_ctrl_getreclock(struct ctdb_context *ctdb, struct timeval timeout, + uint32_t destnode, TALLOC_CTX *mem_ctx, + const char **name) +{ + int ret; + int32_t res; + TDB_DATA data; + + ret = ctdb_control(ctdb, destnode, 0, + CTDB_CONTROL_GET_RECLOCK_FILE, 0, tdb_null, + mem_ctx, &data, &res, &timeout, NULL); + if (ret != 0 || res != 0) { + return -1; + } + + *name = discard_const(data.dptr); + + return 0; +} diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 98dab0785db..0502d9e35d4 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -567,6 +567,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96, CTDB_CONTROL_TRAVERSE_KILL = 97, CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98, + CTDB_CONTROL_GET_RECLOCK_FILE = 99, }; /* diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 72e60c526b9..141622025b4 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -445,6 +445,13 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, CHECK_CONTROL_DATA_SIZE(sizeof(double)); ctdb_reclock_latency(ctdb, "recd reclock", &ctdb->statistics.reclock.recd, *((double *)indata.dptr)); return 0; + case CTDB_CONTROL_GET_RECLOCK_FILE: + CHECK_CONTROL_DATA_SIZE(0); + if (ctdb->recovery_lock_file != NULL) { + outdata->dptr = discard_const(ctdb->recovery_lock_file); + outdata->dsize = strlen(ctdb->recovery_lock_file) + 1; + } + return 0; default: DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode)); return -1; diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 589533b6d00..6c8a941d73c 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -2248,6 +2248,27 @@ static int control_getdebug(struct ctdb_context *ctdb, int argc, const char **ar return 0; } +/* + display reclock file of a node + */ +static int control_getreclock(struct ctdb_context *ctdb, int argc, const char **argv) +{ + int ret; + const char *reclock; + + ret = ctdb_ctrl_getreclock(ctdb, TIMELIMIT(), options.pnn, ctdb, &reclock); + if (ret != 0) { + DEBUG(DEBUG_ERR, ("Unable to get reclock file from node %u\n", options.pnn)); + return ret; + } else { + if (reclock == NULL) { + printf("No reclock file used.\n"); + } else { + printf("Reclock file:%s\n", reclock); + } + } + return 0; +} /* set debug level on a node or all nodes @@ -2991,6 +3012,7 @@ static const struct { { "scriptstatus", control_scriptstatus, false, false, "show the status of the monitoring scripts"}, { "natgwlist", control_natgwlist, false, false, "show the nodes belonging to this natgw configuration"}, { "xpnn", control_xpnn, true, true, "find the pnn of the local node without talking to the daemon (unreliable)" }, + { "getreclock", control_getreclock, false, false, "Show the reclock file of a node"}, }; /*