summaryrefslogtreecommitdiffstats
path: root/ctdb/client/ctdb_client.c
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-08-23 16:52:02 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-10-04 15:15:34 +1000
commit5d47f28e159872a2d3452320c9907b943c22f01d (patch)
tree9dec78ac3ef626dd3e0a4fc5e27d5ec0704e7c7d /ctdb/client/ctdb_client.c
parent105afa543e7a428eaeb7317215701dfb917d0aae (diff)
downloadsamba-5d47f28e159872a2d3452320c9907b943c22f01d.tar.gz
samba-5d47f28e159872a2d3452320c9907b943c22f01d.tar.xz
samba-5d47f28e159872a2d3452320c9907b943c22f01d.zip
client: Add ctdb_ctrl_getdbstatistics() function
Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 1e7fca5cdc1d7205cf084e35aace1a5dc46ea294)
Diffstat (limited to 'ctdb/client/ctdb_client.c')
-rw-r--r--ctdb/client/ctdb_client.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 42645133bf..9addc63151 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -1233,6 +1233,60 @@ int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ct
}
/*
+ * get db statistics
+ */
+int ctdb_ctrl_dbstatistics(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
+ TALLOC_CTX *mem_ctx, struct ctdb_db_statistics **dbstat)
+{
+ int ret;
+ TDB_DATA indata, outdata;
+ int32_t res;
+ struct ctdb_db_statistics *wire, *s;
+ char *ptr;
+ int i;
+
+ indata.dptr = (uint8_t *)&dbid;
+ indata.dsize = sizeof(dbid);
+
+ ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_DB_STATISTICS,
+ 0, indata, ctdb, &outdata, &res, NULL, NULL);
+ if (ret != 0 || res != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for dbstatistics failed\n"));
+ return -1;
+ }
+
+ if (outdata.dsize < offsetof(struct ctdb_db_statistics, hot_keys_wire)) {
+ DEBUG(DEBUG_ERR,(__location__ " Wrong dbstatistics size %zi - expected >= %lu\n",
+ outdata.dsize, sizeof(struct ctdb_statistics)));
+ return -1;
+ }
+
+ s = talloc_zero(mem_ctx, struct ctdb_db_statistics);
+ if (s == NULL) {
+ talloc_free(outdata.dptr);
+ CTDB_NO_MEMORY(ctdb, s);
+ }
+
+ wire = (struct ctdb_db_statistics *)outdata.dptr;
+ *s = *wire;
+ ptr = &wire->hot_keys_wire[0];
+ for (i=0; i<wire->num_hot_keys; i++) {
+ s->hot_keys[i].key.dptr = talloc_size(mem_ctx, s->hot_keys[i].key.dsize);
+ if (s->hot_keys[i].key.dptr == NULL) {
+ talloc_free(outdata.dptr);
+ CTDB_NO_MEMORY(ctdb, s->hot_keys[i].key.dptr);
+ }
+
+ memcpy(s->hot_keys[i].key.dptr, ptr, s->hot_keys[i].key.dsize);
+ ptr += wire->hot_keys[i].key.dsize;
+ }
+
+ talloc_free(outdata.dptr);
+ *dbstat = s;
+ return 0;
+}
+
+/*
shutdown a remote ctdb node
*/
int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)