Addition of the list command to the debugcli to list servers,
services, listeners and sessions
This commit is contained in:
@ -279,6 +279,37 @@ char *stat;
|
|||||||
dcb_printf(dcb, "\tCurrent No. of conns: %d\n", server->stats.n_current);
|
dcb_printf(dcb, "\tCurrent No. of conns: %d\n", server->stats.n_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all servers in a tabular form to a DCB
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
dListServers(DCB *dcb)
|
||||||
|
{
|
||||||
|
SERVER *ptr;
|
||||||
|
char *stat;
|
||||||
|
|
||||||
|
spinlock_acquire(&server_spin);
|
||||||
|
ptr = allServers;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%-18s | %-15s | Port | %-18s | Connections\n",
|
||||||
|
"Server", "Address", "Status");
|
||||||
|
dcb_printf(dcb, "-------------------------------------------------------------------------------\n");
|
||||||
|
}
|
||||||
|
while (ptr)
|
||||||
|
{
|
||||||
|
stat = server_status(ptr);
|
||||||
|
dcb_printf(dcb, "%-18s | %-15s | %5d | %-18s | %4d\n",
|
||||||
|
ptr->unique_name, ptr->name,
|
||||||
|
ptr->port, stat,
|
||||||
|
ptr->stats.n_current);
|
||||||
|
free(stat);
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
spinlock_release(&server_spin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a set of server status flags to a string, the returned
|
* Convert a set of server status flags to a string, the returned
|
||||||
* string has been malloc'd and must be free'd by the caller
|
* string has been malloc'd and must be free'd by the caller
|
||||||
|
@ -726,6 +726,72 @@ SERVER *server = service->databases;
|
|||||||
dcb_printf(dcb, "\tCurrently connected: %d\n", service->stats.n_current);
|
dcb_printf(dcb, "\tCurrently connected: %d\n", service->stats.n_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List the defined services in a tabular format.
|
||||||
|
*
|
||||||
|
* @param dcb DCB to print the service list to.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
dListServices(DCB *dcb)
|
||||||
|
{
|
||||||
|
SERVICE *ptr;
|
||||||
|
|
||||||
|
spinlock_acquire(&service_spin);
|
||||||
|
ptr = allServices;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%-25s | %-20s | #Users | Total Sessions\n",
|
||||||
|
"Service Name", "Router Module");
|
||||||
|
dcb_printf(dcb, "--------------------------------------------------------------------------\n");
|
||||||
|
}
|
||||||
|
while (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%-25s | %-20s | %6d | %5d\n",
|
||||||
|
ptr->name, ptr->routerModule,
|
||||||
|
ptr->stats.n_current, ptr->stats.n_sessions);
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
spinlock_release(&service_spin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List the defined listeners in a tabular format.
|
||||||
|
*
|
||||||
|
* @param dcb DCB to print the service list to.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
dListListeners(DCB *dcb)
|
||||||
|
{
|
||||||
|
SERVICE *ptr;
|
||||||
|
SERV_PROTOCOL *lptr;
|
||||||
|
|
||||||
|
spinlock_acquire(&service_spin);
|
||||||
|
ptr = allServices;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%-20s | %-18s | %-15s | Port | State\n",
|
||||||
|
"Service Name", "Protocol Module", "Address");
|
||||||
|
dcb_printf(dcb, "---------------------------------------------------------------------------\n");
|
||||||
|
}
|
||||||
|
while (ptr)
|
||||||
|
{
|
||||||
|
lptr = ptr->ports;
|
||||||
|
while (lptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%-20s | %-18s | %-15s | %5d | %s\n",
|
||||||
|
ptr->name, lptr->protocol,
|
||||||
|
(lptr != NULL) ? lptr->address : "*",
|
||||||
|
lptr->port,
|
||||||
|
(lptr->listener->session->state == SESSION_STATE_LISTENER_STOPPED) ? "Stopped" : "Running"
|
||||||
|
);
|
||||||
|
|
||||||
|
lptr = lptr->next;
|
||||||
|
}
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
spinlock_release(&service_spin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the definition of a service
|
* Update the definition of a service
|
||||||
*
|
*
|
||||||
|
@ -398,6 +398,7 @@ int norouter = 0;
|
|||||||
if (norouter)
|
if (norouter)
|
||||||
printf("%d Sessions have no router session\n", norouter);
|
printf("%d Sessions have no router session\n", norouter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print all sessions to a DCB
|
* Print all sessions to a DCB
|
||||||
*
|
*
|
||||||
@ -448,6 +449,37 @@ dprintSession(DCB *dcb, SESSION *ptr)
|
|||||||
dcb_printf(dcb, "\tConnected: %s", asctime(localtime(&ptr->stats.connect)));
|
dcb_printf(dcb, "\tConnected: %s", asctime(localtime(&ptr->stats.connect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all sessions in tabular form to a DCB
|
||||||
|
*
|
||||||
|
* Designed to be called within a debugger session in order
|
||||||
|
* to display all active sessions within the gateway
|
||||||
|
*
|
||||||
|
* @param dcb The DCB to print to
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
dListSessions(DCB *dcb)
|
||||||
|
{
|
||||||
|
SESSION *ptr;
|
||||||
|
|
||||||
|
spinlock_acquire(&session_spin);
|
||||||
|
ptr = allSessions;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "Session | Client | State\n");
|
||||||
|
dcb_printf(dcb, "------------------------------------------\n");
|
||||||
|
}
|
||||||
|
while (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%-16p | %-15s | %s\n", ptr,
|
||||||
|
((ptr->client && ptr->client->remote)
|
||||||
|
? ptr->client->remote : ""),
|
||||||
|
session_state(ptr->state));
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
spinlock_release(&session_spin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a session state to a string representation
|
* Convert a session state to a string representation
|
||||||
*
|
*
|
||||||
|
@ -115,6 +115,7 @@ extern void printServer(SERVER *);
|
|||||||
extern void printAllServers();
|
extern void printAllServers();
|
||||||
extern void dprintAllServers(DCB *);
|
extern void dprintAllServers(DCB *);
|
||||||
extern void dprintServer(DCB *, SERVER *);
|
extern void dprintServer(DCB *, SERVER *);
|
||||||
|
extern void dListServers(DCB *);
|
||||||
extern char *server_status(SERVER *);
|
extern char *server_status(SERVER *);
|
||||||
extern void server_set_status(SERVER *, int);
|
extern void server_set_status(SERVER *, int);
|
||||||
extern void server_clear_status(SERVER *, int);
|
extern void server_clear_status(SERVER *, int);
|
||||||
|
@ -160,4 +160,6 @@ bool service_set_slave_conn_limit (
|
|||||||
char* valstr,
|
char* valstr,
|
||||||
count_spec_t count_spec);
|
count_spec_t count_spec);
|
||||||
extern void dprintService(DCB *, SERVICE *);
|
extern void dprintService(DCB *, SERVICE *);
|
||||||
|
extern void dListServices(DCB *);
|
||||||
|
extern void dListListeners(DCB *);
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,6 +93,7 @@ void printAllSessions();
|
|||||||
void printSession(SESSION *);
|
void printSession(SESSION *);
|
||||||
void dprintAllSessions(struct dcb *);
|
void dprintAllSessions(struct dcb *);
|
||||||
void dprintSession(struct dcb *, SESSION *);
|
void dprintSession(struct dcb *, SESSION *);
|
||||||
|
void dListSessions(struct dcb *);
|
||||||
char *session_state(int);
|
char *session_state(int);
|
||||||
bool session_link_dcb(SESSION *, struct dcb *);
|
bool session_link_dcb(SESSION *, struct dcb *);
|
||||||
SESSION* get_session_by_router_ses(void* rses);
|
SESSION* get_session_by_router_ses(void* rses);
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
|
|
||||||
static char *version_str = "V1.1.0";
|
static char *version_str = "V1.1.1";
|
||||||
|
|
||||||
/* The router entry points */
|
/* The router entry points */
|
||||||
static ROUTER *createInstance(SERVICE *service, char **options);
|
static ROUTER *createInstance(SERVICE *service, char **options);
|
||||||
|
@ -153,6 +153,34 @@ struct subcommand showoptions[] = {
|
|||||||
{0, 0, 0} }
|
{0, 0, 0} }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The subcommands of the list command
|
||||||
|
*/
|
||||||
|
struct subcommand listoptions[] = {
|
||||||
|
{ "listeners", 0, dListListeners,
|
||||||
|
"List all the listeners defined within MaxScale",
|
||||||
|
"List all the listeners defined within MaxScale",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "modules", 0, dprintAllModules,
|
||||||
|
"Show all currently loaded modules",
|
||||||
|
"Show all currently loaded modules",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "services", 0, dListServices,
|
||||||
|
"List all the services defined within MaxScale",
|
||||||
|
"List all the services defined within MaxScale",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "servers", 0, dListServers,
|
||||||
|
"List all the servers defined within MaxScale",
|
||||||
|
"List all the servers defined within MaxScale",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "sessions", 0, dListSessions,
|
||||||
|
"List all the active sessions within MaxScale",
|
||||||
|
"List all the active sessions within MaxScale",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ NULL, 0, NULL, NULL, NULL,
|
||||||
|
{0, 0, 0} }
|
||||||
|
};
|
||||||
|
|
||||||
extern void shutdown_server();
|
extern void shutdown_server();
|
||||||
static void shutdown_service(DCB *dcb, SERVICE *service);
|
static void shutdown_service(DCB *dcb, SERVICE *service);
|
||||||
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||||
@ -396,17 +424,18 @@ static struct {
|
|||||||
} cmds[] = {
|
} cmds[] = {
|
||||||
{ "add", addoptions },
|
{ "add", addoptions },
|
||||||
{ "clear", clearoptions },
|
{ "clear", clearoptions },
|
||||||
|
{ "disable", disableoptions },
|
||||||
|
{ "enable", enableoptions },
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
|
{ "fail", failoptions },
|
||||||
|
#endif
|
||||||
|
{ "list", listoptions },
|
||||||
|
{ "reload", reloadoptions },
|
||||||
{ "remove", removeoptions },
|
{ "remove", removeoptions },
|
||||||
{ "restart", restartoptions },
|
{ "restart", restartoptions },
|
||||||
{ "set", setoptions },
|
{ "set", setoptions },
|
||||||
{ "show", showoptions },
|
{ "show", showoptions },
|
||||||
{ "shutdown", shutdownoptions },
|
{ "shutdown", shutdownoptions },
|
||||||
{ "reload", reloadoptions },
|
|
||||||
{ "enable", enableoptions },
|
|
||||||
{ "disable", disableoptions },
|
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
{ "fail", failoptions },
|
|
||||||
#endif
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -488,7 +517,6 @@ execute_cmd(CLI_SESSION *cli)
|
|||||||
DCB *dcb = cli->session->client;
|
DCB *dcb = cli->session->client;
|
||||||
int argc, i, j, found = 0;
|
int argc, i, j, found = 0;
|
||||||
char *args[MAXARGS];
|
char *args[MAXARGS];
|
||||||
char *saveptr, *delim = " \t\r\n";
|
|
||||||
unsigned long arg1, arg2, arg3;
|
unsigned long arg1, arg2, arg3;
|
||||||
int in_quotes = 0, escape_next = 0;
|
int in_quotes = 0, escape_next = 0;
|
||||||
char *ptr, *lptr;
|
char *ptr, *lptr;
|
||||||
|
Reference in New Issue
Block a user