return ctdb_traverse(ctdb_db, dumpdb_fn, f);
}
+/*
+ get the pid of a ctdb daemon
+ */
+int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid)
+{
+ int ret;
+ TDB_DATA data, outdata;
+ int32_t res;
+
+ ZERO_STRUCT(data);
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_GET_PID, 0, data,
+ ctdb, &outdata, &res, &timeout);
+ if (ret != 0 || res != 0) {
+ DEBUG(0,(__location__ " ctdb_control for getrecmode failed\n"));
+ return -1;
+ }
+
+ *pid = ((uint32_t *)outdata.dptr)[0];
+
+ return 0;
+}
+
return 0;
}
+ case CTDB_CONTROL_GET_PID: {
+ outdata->dsize = sizeof(uint32_t);
+ outdata->dptr = (unsigned char *)talloc_array(outdata, uint32_t, 1);
+ *((uint32_t *)(&outdata->dptr[0])) = (uint32_t)getpid();
+
+ return 0;
+ }
+
case CTDB_CONTROL_CONFIG: {
CHECK_CONTROL_DATA_SIZE(0);
ctdb->status.controls.get_config++;
int ctdb_dump_db(struct ctdb_db_context *ctdb_db, FILE *f);
+/*
+ get the pid of a ctdb daemon
+ */
+int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *pid);
+
#endif
CTDB_CONTROL_UPDATE_SEQNUM,
CTDB_CONTROL_SET_SEQNUM_FREQUENCY,
CTDB_CONTROL_DUMP_MEMORY,
+ CTDB_CONTROL_GET_PID,
};
echo
echo "killing off node #0"
echo "==================="
-CTDBPID=`ps aux | grep ctdbd | grep -v grep | head -1 | sed -e "s/^[^ ]* *//" -e "s/ .*$//"`
+CTDBPID=`./bin/ctdb_control getpid 0 | sed -e "s/Pid://"`
kill $CTDBPID
sleep 1
" setrecmode <vnn> <mode> set recovery mode\n"
" writerecord <vnn> <dbid> <key> <data>\n"
" recover <vnn> recover the cluster\n"
- " attach <dbname> attach a database\n");
+ " attach <dbname> attach a database\n"
+ " getpid <vnn> get the pid of a ctdb daemon\n"
+ );
exit(1);
}
return 0;
}
+/*
+ display pid of a ctdb daemon
+ */
+static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ uint32_t vnn, pid;
+ int ret;
+
+
+ if (argc < 1) {
+ usage();
+ }
+
+ vnn = strtoul(argv[0], NULL, 0);
+
+ ret = ctdb_ctrl_getpid(ctdb, timeval_current_ofs(1, 0), vnn, &pid);
+ if (ret != 0) {
+ printf("Unable to get daemon pid from node %u\n", vnn);
+ return ret;
+ }
+ printf("Pid:%d\n",pid);
+
+ return 0;
+}
+
/*
display recovery mode of a remote node
*/
{ "writerecord", control_writerecord },
{ "attach", control_attach },
{ "dumpmemory", control_dumpmemory },
+ { "getpid", control_getpid },
};
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);