Improvements to CLI commands and client
This commit is contained in:
@ -24,6 +24,7 @@
|
|||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 13/06/14 Mark Riddoch Initial implementation
|
* 13/06/14 Mark Riddoch Initial implementation
|
||||||
|
* 15/06/14 Mark Riddoch Addition of source command
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -51,6 +52,7 @@ static int connectMaxScale(char *hostname, char *port);
|
|||||||
static int setipaddress(struct in_addr *a, char *p);
|
static int setipaddress(struct in_addr *a, char *p);
|
||||||
static int authMaxScale(int so, char *user, char *password);
|
static int authMaxScale(int so, char *user, char *password);
|
||||||
static int sendCommand(int so, char *cmd);
|
static int sendCommand(int so, char *cmd);
|
||||||
|
static void DoSource(int so, char *cmd);
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
prompt(EditLine *el __attribute__((__unused__)))
|
prompt(EditLine *el __attribute__((__unused__)))
|
||||||
@ -243,6 +245,10 @@ char *cmd;
|
|||||||
fprintf(stdout, "%4d %s\n",
|
fprintf(stdout, "%4d %s\n",
|
||||||
ev.num, ev.str);
|
ev.num, ev.str);
|
||||||
}
|
}
|
||||||
|
else if (!strncasecmp(buf, "source", 6))
|
||||||
|
{
|
||||||
|
DoSource(so, buf);
|
||||||
|
}
|
||||||
else if (*buf)
|
else if (*buf)
|
||||||
{
|
{
|
||||||
sendCommand(so, buf);
|
sendCommand(so, buf);
|
||||||
@ -371,3 +377,44 @@ int i;
|
|||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
DoSource(int so, char *buf)
|
||||||
|
{
|
||||||
|
char *ptr, *pe;
|
||||||
|
char line[132];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
/* Find the filename */
|
||||||
|
ptr = &buf[strlen("source")];
|
||||||
|
while (*ptr && isspace(*ptr))
|
||||||
|
ptr++;
|
||||||
|
|
||||||
|
if ((fp = fopen(ptr, "r")) == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unable to open command file '%s'.\n",
|
||||||
|
ptr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((ptr = fgets(line, 132, fp)) != NULL)
|
||||||
|
{
|
||||||
|
/* Strip tailing newlines */
|
||||||
|
pe = &ptr[strlen(ptr)-1];
|
||||||
|
while (pe >= ptr && (*pe == '\r' || *pe == '\n'))
|
||||||
|
{
|
||||||
|
*pe = '\0';
|
||||||
|
pe--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ptr != '#') /* Comment */
|
||||||
|
{
|
||||||
|
if (! sendCommand(so, ptr))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@ -1170,6 +1170,8 @@ DCB *dcb;
|
|||||||
|
|
||||||
spinlock_acquire(&dcbspin);
|
spinlock_acquire(&dcbspin);
|
||||||
dcb = allDCBs;
|
dcb = allDCBs;
|
||||||
|
dcb_printf(pdcb, "Descriptor Control Blocks\n");
|
||||||
|
dcb_printf(pdcb, "------------+----------------------------+----------------------+----------\n");
|
||||||
dcb_printf(pdcb, " %-10s | %-26s | %-20s | %s\n",
|
dcb_printf(pdcb, " %-10s | %-26s | %-20s | %s\n",
|
||||||
"DCB", "State", "Service", "Remote");
|
"DCB", "State", "Service", "Remote");
|
||||||
dcb_printf(pdcb, "------------+----------------------------+----------------------+----------\n");
|
dcb_printf(pdcb, "------------+----------------------------+----------------------+----------\n");
|
||||||
@ -1182,7 +1184,7 @@ DCB *dcb;
|
|||||||
(dcb->remote ? dcb->remote : ""));
|
(dcb->remote ? dcb->remote : ""));
|
||||||
dcb = dcb->next;
|
dcb = dcb->next;
|
||||||
}
|
}
|
||||||
dcb_printf(pdcb, "------------+----------------------------+----------------------+----------\n");
|
dcb_printf(pdcb, "------------+----------------------------+----------------------+----------\n\n");
|
||||||
spinlock_release(&dcbspin);
|
spinlock_release(&dcbspin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +207,8 @@ int i;
|
|||||||
ptr = allFilters;
|
ptr = allFilters;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
|
dcb_printf(dcb, "Filters\n");
|
||||||
|
dcb_printf(dcb, "--------------------+-----------------+----------------------------------------\n");
|
||||||
dcb_printf(dcb, "%-18s | %-15s | Options\n",
|
dcb_printf(dcb, "%-18s | %-15s | Options\n",
|
||||||
"Filter", "Module");
|
"Filter", "Module");
|
||||||
dcb_printf(dcb, "--------------------+-----------------+----------------------------------------\n");
|
dcb_printf(dcb, "--------------------+-----------------+----------------------------------------\n");
|
||||||
@ -221,7 +223,7 @@ int i;
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
if (allFilters)
|
if (allFilters)
|
||||||
dcb_printf(dcb, "--------------------+-----------------+----------------------------------------\n");
|
dcb_printf(dcb, "--------------------+-----------------+----------------------------------------\n\n");
|
||||||
spinlock_release(&filter_spin);
|
spinlock_release(&filter_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +359,8 @@ dprintAllModules(DCB *dcb)
|
|||||||
{
|
{
|
||||||
MODULES *ptr = registered;
|
MODULES *ptr = registered;
|
||||||
|
|
||||||
|
dcb_printf(dcb, "Modules.\n");
|
||||||
|
dcb_printf(dcb, "----------------+-------------+---------+-------+-------------------------\n");
|
||||||
dcb_printf(dcb, "%-15s | %-11s | Version | API | Status\n", "Module Name", "Module Type");
|
dcb_printf(dcb, "%-15s | %-11s | Version | API | Status\n", "Module Name", "Module Type");
|
||||||
dcb_printf(dcb, "----------------+-------------+---------+-------+-------------------------\n");
|
dcb_printf(dcb, "----------------+-------------+---------+-------+-------------------------\n");
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -380,5 +382,5 @@ MODULES *ptr = registered;
|
|||||||
dcb_printf(dcb, "\n");
|
dcb_printf(dcb, "\n");
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
dcb_printf(dcb, "----------------+-------------+---------+-------+-------------------------\n");
|
dcb_printf(dcb, "----------------+-------------+---------+-------+-------------------------\n\n");
|
||||||
}
|
}
|
||||||
|
@ -312,14 +312,16 @@ char *stat;
|
|||||||
ptr = allServers;
|
ptr = allServers;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "%-18s | %-15s | Port | %-18s | Connections\n",
|
dcb_printf(dcb, "Servers.\n");
|
||||||
|
dcb_printf(dcb, "-------------------+-----------------+-------+----------------------+------------\n");
|
||||||
|
dcb_printf(dcb, "%-18s | %-15s | Port | %-20s | Connections\n",
|
||||||
"Server", "Address", "Status");
|
"Server", "Address", "Status");
|
||||||
dcb_printf(dcb, "-------------------+-----------------+-------+--------------------+------------\n");
|
dcb_printf(dcb, "-------------------+-----------------+-------+----------------------+------------\n");
|
||||||
}
|
}
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
stat = server_status(ptr);
|
stat = server_status(ptr);
|
||||||
dcb_printf(dcb, "%-18s | %-15s | %5d | %-18s | %4d\n",
|
dcb_printf(dcb, "%-18s | %-15s | %5d | %-20s | %4d\n",
|
||||||
ptr->unique_name, ptr->name,
|
ptr->unique_name, ptr->name,
|
||||||
ptr->port, stat,
|
ptr->port, stat,
|
||||||
ptr->stats.n_current);
|
ptr->stats.n_current);
|
||||||
@ -327,7 +329,7 @@ char *stat;
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
if (allServers)
|
if (allServers)
|
||||||
dcb_printf(dcb, "-------------------+-----------------+-------+--------------------+------------\n");
|
dcb_printf(dcb, "-------------------+-----------------+-------+----------------------+------------\n\n");
|
||||||
spinlock_release(&server_spin);
|
spinlock_release(&server_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,6 +826,8 @@ SERVICE *ptr;
|
|||||||
ptr = allServices;
|
ptr = allServices;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
|
dcb_printf(dcb, "Services.\n");
|
||||||
|
dcb_printf(dcb, "--------------------------+----------------------+--------+---------------\n");
|
||||||
dcb_printf(dcb, "%-25s | %-20s | #Users | Total Sessions\n",
|
dcb_printf(dcb, "%-25s | %-20s | #Users | Total Sessions\n",
|
||||||
"Service Name", "Router Module");
|
"Service Name", "Router Module");
|
||||||
dcb_printf(dcb, "--------------------------+----------------------+--------+---------------\n");
|
dcb_printf(dcb, "--------------------------+----------------------+--------+---------------\n");
|
||||||
@ -838,7 +840,7 @@ SERVICE *ptr;
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
if (allServices)
|
if (allServices)
|
||||||
dcb_printf(dcb, "--------------------------+----------------------+--------+---------------\n");
|
dcb_printf(dcb, "--------------------------+----------------------+--------+---------------\n\n");
|
||||||
spinlock_release(&service_spin);
|
spinlock_release(&service_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,9 +859,11 @@ SERV_PROTOCOL *lptr;
|
|||||||
ptr = allServices;
|
ptr = allServices;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
|
dcb_printf(dcb, "Listeners.\n");
|
||||||
|
dcb_printf(dcb, "---------------------+--------------------+-----------------+-------+--------\n");
|
||||||
dcb_printf(dcb, "%-20s | %-18s | %-15s | Port | State\n",
|
dcb_printf(dcb, "%-20s | %-18s | %-15s | Port | State\n",
|
||||||
"Service Name", "Protocol Module", "Address");
|
"Service Name", "Protocol Module", "Address");
|
||||||
dcb_printf(dcb, "---------------------+--------------------+-----------------+-------+------\n");
|
dcb_printf(dcb, "---------------------+--------------------+-----------------+-------+--------\n");
|
||||||
}
|
}
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
@ -868,7 +872,7 @@ SERV_PROTOCOL *lptr;
|
|||||||
{
|
{
|
||||||
dcb_printf(dcb, "%-20s | %-18s | %-15s | %5d | %s\n",
|
dcb_printf(dcb, "%-20s | %-18s | %-15s | %5d | %s\n",
|
||||||
ptr->name, lptr->protocol,
|
ptr->name, lptr->protocol,
|
||||||
(lptr != NULL) ? lptr->address : "*",
|
(lptr && lptr->address) ? lptr->address : "*",
|
||||||
lptr->port,
|
lptr->port,
|
||||||
(lptr->listener->session->state == SESSION_STATE_LISTENER_STOPPED) ? "Stopped" : "Running"
|
(lptr->listener->session->state == SESSION_STATE_LISTENER_STOPPED) ? "Stopped" : "Running"
|
||||||
);
|
);
|
||||||
@ -878,7 +882,7 @@ SERV_PROTOCOL *lptr;
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
if (allServices)
|
if (allServices)
|
||||||
dcb_printf(dcb, "---------------------+--------------------+-----------------+-------+------\n");
|
dcb_printf(dcb, "---------------------+--------------------+-----------------+-------+--------\n\n");
|
||||||
spinlock_release(&service_spin);
|
spinlock_release(&service_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,19 +537,23 @@ SESSION *ptr;
|
|||||||
ptr = allSessions;
|
ptr = allSessions;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "Session | Client | State\n");
|
dcb_printf(dcb, "Sessions.\n");
|
||||||
dcb_printf(dcb, "-----------------+-----------------+----------------\n");
|
dcb_printf(dcb, "-----------------+-----------------+----------------+--------------------------\n");
|
||||||
|
dcb_printf(dcb, "Session | Client | Service | State\n");
|
||||||
|
dcb_printf(dcb, "-----------------+-----------------+----------------+--------------------------\n");
|
||||||
}
|
}
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "%-16p | %-15s | %s\n", ptr,
|
dcb_printf(dcb, "%-16p | %-15s | %-14s | %s\n", ptr,
|
||||||
((ptr->client && ptr->client->remote)
|
((ptr->client && ptr->client->remote)
|
||||||
? ptr->client->remote : ""),
|
? ptr->client->remote : ""),
|
||||||
|
(ptr->service && ptr->service->name ? ptr->service->name
|
||||||
|
: ""),
|
||||||
session_state(ptr->state));
|
session_state(ptr->state));
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
if (allSessions)
|
if (allSessions)
|
||||||
dcb_printf(dcb, "-----------------+-----------------+----------------\n");
|
dcb_printf(dcb, "-----------------+-----------------+----------------+--------------------------\n\n");
|
||||||
spinlock_release(&session_spin);
|
spinlock_release(&session_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user