/** * Print all servers to a DCB * * Designed to be called within a debugger session in order * to display all active servers within the gateway */ void dprintAllServers(DCB *dcb) { SERVER *ptr; char *stat; spinlock_acquire(&server_spin); ptr = allServers; while (ptr) { dcb_printf(dcb, "Server %p (%s)\n", ptr, ptr->unique_name); dcb_printf(dcb, "\tServer: %s\n", ptr->name); stat = server_status(ptr); dcb_printf(dcb, "\tStatus: %s\n", stat); free(stat); dcb_printf(dcb, "\tProtocol: %s\n", ptr->protocol); dcb_printf(dcb, "\tPort: %d\n", ptr->port); if (ptr->server_string) dcb_printf(dcb, "\tServer Version:\t\t\t%s\n", ptr->server_string); dcb_printf(dcb, "\tNode Id: %d\n", ptr->node_id); dcb_printf(dcb, "\tMaster Id: %d\n", ptr->master_id); if (ptr->slaves) { int i; dcb_printf(dcb, "\tSlave Ids: "); for (i = 0; ptr->slaves[i]; i++) { if (i == 0) dcb_printf(dcb, "%li", ptr->slaves[i]); else dcb_printf(dcb, ", %li ", ptr->slaves[i]); } dcb_printf(dcb, "\n"); } dcb_printf(dcb, "\tRepl Depth: %d\n", ptr->depth); if (SERVER_IS_SLAVE(ptr) || SERVER_IS_RELAY_SERVER(ptr)) { if (ptr->rlag >= 0) { dcb_printf(dcb, "\tSlave delay:\t\t%d\n", ptr->rlag); } } if (ptr->node_ts > 0) { dcb_printf(dcb, "\tLast Repl Heartbeat:\t%lu\n", ptr->node_ts); } dcb_printf(dcb, "\tNumber of connections: %d\n", ptr->stats.n_connections); dcb_printf(dcb, "\tCurrent no. of conns: %d\n", ptr->stats.n_current); dcb_printf(dcb, "\tCurrent no. of operations: %d\n", ptr->stats.n_current_ops); ptr = ptr->next; } spinlock_release(&server_spin); }
/** * Print server details to a DCB * * Designed to be called within a debugger session in order * to display all active servers within the gateway */ void dprintServer(DCB *dcb, SERVER *server) { char *stat; SERVER_PARAM *param; dcb_printf(dcb, "Server %p (%s)\n", server, server->unique_name); dcb_printf(dcb, "\tServer: %s\n", server->name); stat = server_status(server); dcb_printf(dcb, "\tStatus: %s\n", stat); free(stat); dcb_printf(dcb, "\tProtocol: %s\n", server->protocol); dcb_printf(dcb, "\tPort: %d\n", server->port); if (server->server_string) dcb_printf(dcb, "\tServer Version:\t\t\t%s\n", server->server_string); dcb_printf(dcb, "\tNode Id: %d\n", server->node_id); dcb_printf(dcb, "\tMaster Id: %d\n", server->master_id); if (server->slaves) { int i; dcb_printf(dcb, "\tSlave Ids: "); for (i = 0; server->slaves[i]; i++) { if (i == 0) dcb_printf(dcb, "%li", server->slaves[i]); else dcb_printf(dcb, ", %li ", server->slaves[i]); } dcb_printf(dcb, "\n"); } dcb_printf(dcb, "\tRepl Depth: %d\n", server->depth); if (SERVER_IS_SLAVE(server) || SERVER_IS_RELAY_SERVER(server)) { if (server->rlag >= 0) { dcb_printf(dcb, "\tSlave delay:\t\t%d\n", server->rlag); } } if (server->node_ts > 0) { struct tm result; char buf[40]; dcb_printf(dcb, "\tLast Repl Heartbeat:\t%s", asctime_r(localtime_r((time_t *)(&server->node_ts), &result), buf)); } if ((param = server->parameters) != NULL) { dcb_printf(dcb, "\tServer Parameters:\n"); while (param) { dcb_printf(dcb, "\t\t%-20s\t%s\n", param->name, param->value); param = param->next; } } dcb_printf(dcb, "\tNumber of connections: %d\n", server->stats.n_connections); dcb_printf(dcb, "\tCurrent no. of conns: %d\n", server->stats.n_current); dcb_printf(dcb, "\tCurrent no. of operations: %d\n", server->stats.n_current_ops); }
/** * Print all servers in Json format to a DCB * * Designed to be called within a debugger session in order * to display all active servers within the gateway */ void dprintAllServersJson(DCB *dcb) { SERVER *ptr; char *stat; int len = 0; int el = 1; spinlock_acquire(&server_spin); ptr = allServers; while (ptr) { ptr = ptr->next; len++; } ptr = allServers; dcb_printf(dcb, "[\n"); while (ptr) { dcb_printf(dcb, " {\n \"server\": \"%s\",\n", ptr->name); stat = server_status(ptr); dcb_printf(dcb, " \"status\": \"%s\",\n", stat); free(stat); dcb_printf(dcb, " \"protocol\": \"%s\",\n", ptr->protocol); dcb_printf(dcb, " \"port\": \"%d\",\n", ptr->port); if (ptr->server_string) dcb_printf(dcb, " \"version\": \"%s\",\n", ptr->server_string); dcb_printf(dcb, " \"nodeId\": \"%d\",\n", ptr->node_id); dcb_printf(dcb, " \"masterId\": \"%d\",\n", ptr->master_id); if (ptr->slaves) { int i; dcb_printf(dcb, " \"slaveIds\": [ "); for (i = 0; ptr->slaves[i]; i++) { if (i == 0) dcb_printf(dcb, "%li", ptr->slaves[i]); else dcb_printf(dcb, ", %li ", ptr->slaves[i]); } dcb_printf(dcb, "],\n"); } dcb_printf(dcb, " \"replDepth\": \"%d\",\n", ptr->depth); if (SERVER_IS_SLAVE(ptr) || SERVER_IS_RELAY_SERVER(ptr)) { if (ptr->rlag >= 0) { dcb_printf(dcb, " \"slaveDelay\": \"%d\",\n", ptr->rlag); } } if (ptr->node_ts > 0) { dcb_printf(dcb, " \"lastReplHeartbeat\": \"%lu\",\n", ptr->node_ts); } dcb_printf(dcb, " \"totalConnections\": \"%d\",\n", ptr->stats.n_connections); dcb_printf(dcb, " \"currentConnections\": \"%d\",\n", ptr->stats.n_current); dcb_printf(dcb, " \"currentOps\": \"%d\"\n", ptr->stats.n_current_ops); if (el < len) { dcb_printf(dcb, " },\n"); } else { dcb_printf(dcb, " }\n"); } ptr = ptr->next; el++; } dcb_printf(dcb, "]\n"); spinlock_release(&server_spin); }
/** * Print all servers to a DCB * * Designed to be called within a debugger session in order * to display all active servers within the gateway */ void dprintAllServers(DCB *dcb) { SERVER *server; char *stat; spinlock_acquire(&server_spin); server = allServers; while (server) { dcb_printf(dcb, "Server %p (%s)\n", server, server->unique_name); dcb_printf(dcb, "\tServer: %s\n", server->name); stat = server_status(server); dcb_printf(dcb, "\tStatus: %s\n", stat); free(stat); dcb_printf(dcb, "\tProtocol: %s\n", server->protocol); dcb_printf(dcb, "\tPort: %d\n", server->port); if (server->server_string) dcb_printf(dcb, "\tServer Version:\t\t\t%s\n", server->server_string); dcb_printf(dcb, "\tNode Id: %d\n", server->node_id); dcb_printf(dcb, "\tMaster Id: %d\n", server->master_id); if (server->slaves) { int i; dcb_printf(dcb, "\tSlave Ids: "); for (i = 0; server->slaves[i]; i++) { if (i == 0) { dcb_printf(dcb, "%li", server->slaves[i]); } else { dcb_printf(dcb, ", %li ", server->slaves[i]); } } dcb_printf(dcb, "\n"); } dcb_printf(dcb, "\tRepl Depth: %d\n", server->depth); if (SERVER_IS_SLAVE(server) || SERVER_IS_RELAY_SERVER(server)) { if (server->rlag >= 0) { dcb_printf(dcb, "\tSlave delay:\t\t%d\n", server->rlag); } } if (server->node_ts > 0) { dcb_printf(dcb, "\tLast Repl Heartbeat:\t%lu\n", server->node_ts); } dcb_printf(dcb, "\tNumber of connections: %d\n", server->stats.n_connections); dcb_printf(dcb, "\tCurrent no. of conns: %d\n", server->stats.n_current); dcb_printf(dcb, "\tCurrent no. of operations: %d\n", server->stats.n_current_ops); if (server->persistpoolmax) { dcb_printf(dcb, "\tPersistent pool size: %d\n", server->stats.n_persistent); dcb_printf(dcb, "\tPersistent measured pool size: %d\n", dcb_persistent_clean_count(server->persistent, false)); dcb_printf(dcb, "\tPersistent max size achieved: %d\n", server->persistmax); dcb_printf(dcb, "\tPersistent pool size limit: %d\n", server->persistpoolmax); dcb_printf(dcb, "\tPersistent max time (secs): %d\n", server->persistmaxtime); } server = server->next; } spinlock_release(&server_spin); }