ctdb-logging: Remove log ringbuffer
[vlendec/samba-autobuild/.git] / ctdb / tools / ctdb.c
index 82783d8dfa1affeaa0a79b32641f3c7c70f0811e..71dfc28779fb25d2c355c859ca6f308e7e30c226 100644 (file)
@@ -4503,127 +4503,6 @@ static int control_chktcpport(struct ctdb_context *ctdb, int argc, const char **
 }
 
 
-
-static void log_handler(struct ctdb_context *ctdb, uint64_t srvid, 
-                            TDB_DATA data, void *private_data)
-{
-       DEBUG(DEBUG_ERR,("Log data received\n"));
-       if (data.dsize > 0) {
-               printf("%s", data.dptr);
-       }
-
-       exit(0);
-}
-
-/*
-  display a list of log messages from the in memory ringbuffer
- */
-static int control_getlog(struct ctdb_context *ctdb, int argc, const char **argv)
-{
-       int ret, i;
-       bool main_daemon;
-       struct ctdb_get_log_addr log_addr;
-       TDB_DATA data;
-       struct timeval tv;
-
-       /* Process options */
-       main_daemon = true;
-       log_addr.pnn = ctdb_get_pnn(ctdb);
-       log_addr.level = DEBUG_NOTICE;
-       for (i = 0; i < argc; i++) {
-               if (strcmp(argv[i], "recoverd") == 0) {
-                       main_daemon = false;
-               } else {
-                       if (isalpha(argv[i][0]) || argv[i][0] == '-') { 
-                               log_addr.level = get_debug_by_desc(argv[i]);
-                       } else {
-                               log_addr.level = strtol(argv[i], NULL, 0);
-                       }
-               }
-       }
-
-       /* Our message port is our PID */
-       log_addr.srvid = getpid();
-
-       data.dptr = (unsigned char *)&log_addr;
-       data.dsize = sizeof(log_addr);
-
-       DEBUG(DEBUG_ERR, ("Pulling logs from node %u\n", options.pnn));
-
-       ctdb_client_set_message_handler(ctdb, log_addr.srvid, log_handler, NULL);
-       sleep(1);
-
-       DEBUG(DEBUG_ERR,("Listen for response on %d\n", (int)log_addr.srvid));
-
-       if (main_daemon) {
-               int32_t res;
-               char *errmsg;
-               TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-
-               ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_GET_LOG,
-                                  0, data, tmp_ctx, NULL, &res, NULL, &errmsg);
-               if (ret != 0 || res != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to get logs - %s\n", errmsg));
-                       talloc_free(tmp_ctx);
-                       return -1;
-               }
-               talloc_free(tmp_ctx);
-       } else {
-               ret = ctdb_client_send_message(ctdb, options.pnn,
-                                              CTDB_SRVID_GETLOG, data);
-               if (ret != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to send getlog request message to %u\n", options.pnn));
-                       return -1;
-               }
-       }
-
-       tv = timeval_current();
-       /* this loop will terminate when we have received the reply */
-       while (timeval_elapsed(&tv) < (double)options.timelimit) {
-               event_loop_once(ctdb->ev);
-       }
-
-       DEBUG(DEBUG_INFO,("Timed out waiting for log data.\n"));
-
-       return 0;
-}
-
-/*
-  clear the in memory log area
- */
-static int control_clearlog(struct ctdb_context *ctdb, int argc, const char **argv)
-{
-       int ret;
-
-       if (argc == 0 || (argc >= 1 && strcmp(argv[0], "recoverd") != 0)) {
-               /* "recoverd" not given - get logs from main daemon */
-               int32_t res;
-               char *errmsg;
-               TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-
-               ret = ctdb_control(ctdb, options.pnn, 0, CTDB_CONTROL_CLEAR_LOG,
-                                  0, tdb_null, tmp_ctx, NULL, &res, NULL, &errmsg);
-               if (ret != 0 || res != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to clear logs\n"));
-                       talloc_free(tmp_ctx);
-                       return -1;
-               }
-
-               talloc_free(tmp_ctx);
-       } else {
-               TDB_DATA data; /* unused in recoverd... */
-               data.dsize = 0;
-
-               ret = ctdb_client_send_message(ctdb, options.pnn, CTDB_SRVID_CLEARLOG, data);
-               if (ret != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to send clearlog request message to %u\n", options.pnn));
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
 /* Reload public IPs on a specified nodes */
 static int control_reloadips(struct ctdb_context *ctdb, int argc, const char **argv)
 {
@@ -6356,8 +6235,6 @@ static const struct {
        { "enablemonitor",      control_enable_monmode, true,   false,  "set monitoring mode to ACTIVE" },
        { "setdebug",        control_setdebug,          true,   false,  "set debug level",                      "<EMERG|ALERT|CRIT|ERR|WARNING|NOTICE|INFO|DEBUG>" },
        { "getdebug",        control_getdebug,          true,   false,  "get debug level" },
-       { "getlog",          control_getlog,            true,   false,  "get the log data from the in memory ringbuffer", "[<level>] [recoverd]" },
-       { "clearlog",          control_clearlog,        true,   false,  "clear the log data from the in memory ringbuffer", "[recoverd]" },
        { "attach",          control_attach,            true,   false,  "attach to a database",                 "<dbname> [persistent]" },
        { "detach",          control_detach,            false,  false,  "detach from a database",                 "<dbname|dbid> [<dbname|dbid> ...]" },
        { "dumpmemory",      control_dumpmemory,        true,   false,  "dump memory map to stdout" },