Addition of show monitors command, shutdown monitor and restart monitor
This commit is contained in:
@ -66,7 +66,7 @@ MONITOR *mon;
|
|||||||
free(mon);
|
free(mon);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
mon->handle = (*mon->module->startMonitor)();
|
mon->handle = (*mon->module->startMonitor)(NULL);
|
||||||
|
|
||||||
spinlock_acquire(&monLock);
|
spinlock_acquire(&monLock);
|
||||||
mon->next = allMonitors;
|
mon->next = allMonitors;
|
||||||
@ -104,6 +104,29 @@ MONITOR *ptr;
|
|||||||
free(mon);
|
free(mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start an individual monitor that has previoulsy been stopped.
|
||||||
|
*
|
||||||
|
* @param monitor The Monitor that should be started
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
monitorStart(MONITOR *monitor)
|
||||||
|
{
|
||||||
|
monitor->handle = (*monitor->module->startMonitor)(monitor->handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop a given monitor
|
||||||
|
*
|
||||||
|
* @param monitor The monitor to stop
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
monitorStop(MONITOR *monitor)
|
||||||
|
{
|
||||||
|
monitor->module->stopMonitor(monitor->handle);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown all running monitors
|
* Shutdown all running monitors
|
||||||
*/
|
*/
|
||||||
@ -116,7 +139,7 @@ MONITOR *ptr;
|
|||||||
ptr = allMonitors;
|
ptr = allMonitors;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
ptr->module->stopMonitor(ptr->handle);
|
monitorStop(ptr);
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
spinlock_release(&monLock);
|
spinlock_release(&monLock);
|
||||||
@ -148,3 +171,26 @@ monitorAddUser(MONITOR *mon, char *user, char *passwd)
|
|||||||
{
|
{
|
||||||
mon->module->defaultUser(mon->handle, user, passwd);
|
mon->module->defaultUser(mon->handle, user, passwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show all monitors
|
||||||
|
*
|
||||||
|
* @param dcb DCB for printing output
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
monitorShowAll(DCB *dcb)
|
||||||
|
{
|
||||||
|
MONITOR *ptr;
|
||||||
|
|
||||||
|
spinlock_acquire(&monLock);
|
||||||
|
ptr = allMonitors;
|
||||||
|
while (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "Monitor: %p\n", ptr);
|
||||||
|
dcb_printf(dcb, "\tName: %s\n", ptr->name);
|
||||||
|
if (ptr->module->diagnostics)
|
||||||
|
ptr->module->diagnostics(dcb, ptr->handle);
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
spinlock_release(&monLock);
|
||||||
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
* Copyright SkySQL Ab 2013
|
* Copyright SkySQL Ab 2013
|
||||||
*/
|
*/
|
||||||
#include <server.h>
|
#include <server.h>
|
||||||
|
#include <dcb.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file monitor.h The interface to the monitor module
|
* @file monitor.h The interface to the monitor module
|
||||||
@ -27,6 +28,7 @@
|
|||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 07/07/13 Mark Riddoch Initial implementation
|
* 07/07/13 Mark Riddoch Initial implementation
|
||||||
|
* 25/07/13 Mark Riddoch Addition of diagnotics
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -57,11 +59,12 @@
|
|||||||
* monitored.
|
* monitored.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *(*startMonitor)();
|
void *(*startMonitor)(void *);
|
||||||
void (*stopMonitor)(void *);
|
void (*stopMonitor)(void *);
|
||||||
void (*registerServer)(void *, SERVER *);
|
void (*registerServer)(void *, SERVER *);
|
||||||
void (*unregisterServer)(void *, SERVER *);
|
void (*unregisterServer)(void *, SERVER *);
|
||||||
void (*defaultUser)(void *, char *, char *);
|
void (*defaultUser)(void *, char *, char *);
|
||||||
|
void (*diagnostics)(DCB *, void *);
|
||||||
} MONITOR_OBJECT;
|
} MONITOR_OBJECT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,5 +81,8 @@ extern MONITOR *monitor_alloc(char *, char *);
|
|||||||
extern void monitor_free(MONITOR *);
|
extern void monitor_free(MONITOR *);
|
||||||
extern void monitorAddServer(MONITOR *, SERVER *);
|
extern void monitorAddServer(MONITOR *, SERVER *);
|
||||||
extern void monitorAddUser(MONITOR *, char *, char *);
|
extern void monitorAddUser(MONITOR *, char *, char *);
|
||||||
|
extern void monitorStop(MONITOR *);
|
||||||
|
extern void monitorStart(MONITOR *);
|
||||||
extern void monitorStopAll();
|
extern void monitorStopAll();
|
||||||
|
extern void monitorShowAll(DCB *);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -39,18 +39,20 @@
|
|||||||
#include <skygw_utils.h>
|
#include <skygw_utils.h>
|
||||||
#include <log_manager.h>
|
#include <log_manager.h>
|
||||||
#include <secrets.h>
|
#include <secrets.h>
|
||||||
|
#include <dcb.h>
|
||||||
|
|
||||||
static void monitorMain(void *);
|
static void monitorMain(void *);
|
||||||
|
|
||||||
static char *version_str = "V1.0.0";
|
static char *version_str = "V1.0.0";
|
||||||
|
|
||||||
static void *startMonitor();
|
static void *startMonitor(void *);
|
||||||
static void stopMonitor(void *);
|
static void stopMonitor(void *);
|
||||||
static void registerServer(void *, SERVER *);
|
static void registerServer(void *, SERVER *);
|
||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUsers(void *, char *, char *);
|
static void defaultUsers(void *, char *, char *);
|
||||||
|
static void daignostics(DCB *, void *);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser };
|
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser, daignostics };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -96,17 +98,25 @@ GetModuleObject()
|
|||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static void *
|
static void *
|
||||||
startMonitor()
|
startMonitor(void *arg)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle;
|
MYSQL_MONITOR *handle;
|
||||||
|
|
||||||
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
if (arg != NULL)
|
||||||
return NULL;
|
{
|
||||||
handle->databases = NULL;
|
handle = (MYSQL_MONITOR *)arg;
|
||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
handle->defaultUser = NULL;
|
}
|
||||||
handle->deaultPasswd = NULL;
|
else
|
||||||
spinlock_init(&handle->lock);
|
{
|
||||||
|
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
handle->databases = NULL;
|
||||||
|
handle->shutdown = 0;
|
||||||
|
handle->defaultUser = NULL;
|
||||||
|
handle->deaultPasswd = NULL;
|
||||||
|
spinlock_init(&handle->lock);
|
||||||
|
}
|
||||||
thread_start(monitorMain, handle);
|
thread_start(monitorMain, handle);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@ -194,6 +204,43 @@ MONITOR_SERVERS *ptr, *lptr;
|
|||||||
spinlock_release(&handle->lock);
|
spinlock_release(&handle->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diagnostic interface
|
||||||
|
*
|
||||||
|
* @param dcb DCB to send output
|
||||||
|
* @param arg The monitor handle
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
diagnostics(DCB *dcbm void *handle)
|
||||||
|
{
|
||||||
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
|
MONITOR_SERVERS *db;
|
||||||
|
char *sep;
|
||||||
|
|
||||||
|
switch (handle->status)
|
||||||
|
{
|
||||||
|
case MONITOR_RUNNING:
|
||||||
|
dcb_printf(dcb, "\tMonitor running\n");
|
||||||
|
break;
|
||||||
|
case MONITOR_STOPPING:
|
||||||
|
dcb_printf(dcb, "\tMonitor stopping\n");
|
||||||
|
break;
|
||||||
|
case MONITOR_STOPPED:
|
||||||
|
dcb_printf(dcb, "\tMonitor stopped\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dcb_printf(dcb, "\tMonitored servers: ");
|
||||||
|
db = handle->databases;
|
||||||
|
sep = "";
|
||||||
|
while (db)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%s%s:%d", sep, db->server->name, db->server->port);
|
||||||
|
sep = ", ";
|
||||||
|
db = db->next;
|
||||||
|
}
|
||||||
|
dcb_printf(dcb, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default username and password to use to monitor if the server does not
|
* Set the default username and password to use to monitor if the server does not
|
||||||
* override this.
|
* override this.
|
||||||
@ -292,11 +339,14 @@ MONITOR_SERVERS *ptr;
|
|||||||
"module. Exiting.\n");
|
"module. Exiting.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
handle->status = MONITOR_RUNNING;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (handle->shutdown)
|
if (handle->shutdown)
|
||||||
{
|
{
|
||||||
|
handle->status = MONITOR_STOPPING;
|
||||||
mysql_thread_end();
|
mysql_thread_end();
|
||||||
|
handle->status = MONITOR_STOPPED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptr = handle->databases;
|
ptr = handle->databases;
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
* 08/07/13 Mark Riddoch Initial implementation
|
* 08/07/13 Mark Riddoch Initial implementation
|
||||||
* 11/07/13 Mark Riddoch Addition of code to check replication
|
* 11/07/13 Mark Riddoch Addition of code to check replication
|
||||||
* status
|
* status
|
||||||
|
* 25/07/13 Mark Riddoch Addition of decrypt for passwords and
|
||||||
|
* diagnostic interface
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -41,18 +43,20 @@
|
|||||||
#include <skygw_utils.h>
|
#include <skygw_utils.h>
|
||||||
#include <log_manager.h>
|
#include <log_manager.h>
|
||||||
#include <secrets.h>
|
#include <secrets.h>
|
||||||
|
#include <dcb.h>
|
||||||
|
|
||||||
static void monitorMain(void *);
|
static void monitorMain(void *);
|
||||||
|
|
||||||
static char *version_str = "V1.0.0";
|
static char *version_str = "V1.0.0";
|
||||||
|
|
||||||
static void *startMonitor();
|
static void *startMonitor(void *);
|
||||||
static void stopMonitor(void *);
|
static void stopMonitor(void *);
|
||||||
static void registerServer(void *, SERVER *);
|
static void registerServer(void *, SERVER *);
|
||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUser(void *, char *, char *);
|
static void defaultUser(void *, char *, char *);
|
||||||
|
static void diagnostics(DCB *, void *);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser };
|
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser, diagnostics };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -95,20 +99,29 @@ GetModuleObject()
|
|||||||
*
|
*
|
||||||
* This function creates a thread to execute the actual monitoring.
|
* This function creates a thread to execute the actual monitoring.
|
||||||
*
|
*
|
||||||
|
* @param arg The current handle - NULL if first start
|
||||||
* @return A handle to use when interacting with the monitor
|
* @return A handle to use when interacting with the monitor
|
||||||
*/
|
*/
|
||||||
static void *
|
static void *
|
||||||
startMonitor()
|
startMonitor(void *arg)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle;
|
MYSQL_MONITOR *handle;
|
||||||
|
|
||||||
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
if (arg)
|
||||||
return NULL;
|
{
|
||||||
handle->databases = NULL;
|
handle = arg; /* Must be a restart */
|
||||||
handle->shutdown = 0;
|
handle->shutdown = 0;
|
||||||
handle->defaultUser = NULL;
|
}
|
||||||
handle->defaultPasswd = NULL;
|
else
|
||||||
spinlock_init(&handle->lock);
|
{
|
||||||
|
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
handle->databases = NULL;
|
||||||
|
handle->shutdown = 0;
|
||||||
|
handle->defaultUser = NULL;
|
||||||
|
handle->defaultPasswd = NULL;
|
||||||
|
spinlock_init(&handle->lock);
|
||||||
|
}
|
||||||
thread_start(monitorMain, handle);
|
thread_start(monitorMain, handle);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@ -217,6 +230,42 @@ MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
|||||||
handle->defaultPasswd = strdup(passwd);
|
handle->defaultPasswd = strdup(passwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Daignostic interface
|
||||||
|
*
|
||||||
|
* @param dcb DCB to print diagnostics
|
||||||
|
* @param arg The monitor handle
|
||||||
|
*/
|
||||||
|
static void diagnostics(DCB *dcb, void *arg)
|
||||||
|
{
|
||||||
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
|
MONITOR_SERVERS *db;
|
||||||
|
char *sep;
|
||||||
|
|
||||||
|
switch (handle->status)
|
||||||
|
{
|
||||||
|
case MONITOR_RUNNING:
|
||||||
|
dcb_printf(dcb, "\tMonitor running\n");
|
||||||
|
break;
|
||||||
|
case MONITOR_STOPPING:
|
||||||
|
dcb_printf(dcb, "\tMonitor stopping\n");
|
||||||
|
break;
|
||||||
|
case MONITOR_STOPPED:
|
||||||
|
dcb_printf(dcb, "\tMonitor stopped\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dcb_printf(dcb, "\tMonitored servers: ");
|
||||||
|
db = handle->databases;
|
||||||
|
sep = "";
|
||||||
|
while (db)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, "%s%s:%d", sep, db->server->name, db->server->port);
|
||||||
|
sep = ", ";
|
||||||
|
db = db->next;
|
||||||
|
}
|
||||||
|
dcb_printf(dcb, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor an individual server
|
* Monitor an individual server
|
||||||
*
|
*
|
||||||
@ -328,11 +377,14 @@ MONITOR_SERVERS *ptr;
|
|||||||
"module. Exiting.\n");
|
"module. Exiting.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
handle->status = MONITOR_RUNNING;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (handle->shutdown)
|
if (handle->shutdown)
|
||||||
{
|
{
|
||||||
|
handle->status = MONITOR_STOPPING;
|
||||||
mysql_thread_end();
|
mysql_thread_end();
|
||||||
|
handle->status = MONITOR_STOPPED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptr = handle->databases;
|
ptr = handle->databases;
|
||||||
|
|||||||
@ -50,8 +50,14 @@ typedef struct monitor_servers {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
SPINLOCK lock; /**< The monitor spinlock */
|
SPINLOCK lock; /**< The monitor spinlock */
|
||||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||||
|
int status; /**< Monitor status */
|
||||||
char *defaultUser; /**< Default username for monitoring */
|
char *defaultUser; /**< Default username for monitoring */
|
||||||
char *defaultPasswd; /**< Default password for monitoring */
|
char *defaultPasswd; /**< Default password for monitoring */
|
||||||
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
||||||
} MYSQL_MONITOR;
|
} MYSQL_MONITOR;
|
||||||
|
|
||||||
|
#define MONITOR_RUNNING 1
|
||||||
|
#define MONITOR_STOPPING 2
|
||||||
|
#define MONITOR_STOPPED 3
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -56,6 +56,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <telnetd.h>
|
#include <telnetd.h>
|
||||||
#include <adminusers.h>
|
#include <adminusers.h>
|
||||||
|
#include <monitor.h>
|
||||||
#include <debugcli.h>
|
#include <debugcli.h>
|
||||||
|
|
||||||
#define MAXARGS 5
|
#define MAXARGS 5
|
||||||
@ -80,26 +81,28 @@ static void telnetdShowUsers(DCB *);
|
|||||||
* The subcommands of the show command
|
* The subcommands of the show command
|
||||||
*/
|
*/
|
||||||
struct subcommand showoptions[] = {
|
struct subcommand showoptions[] = {
|
||||||
{ "sessions", 0, dprintAllSessions, "Show all active sessions in MaxScale",
|
|
||||||
{0, 0, 0} },
|
|
||||||
{ "session", 1, dprintSession, "Show a single session in MaxScale, e.g. show session 0x284830",
|
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
|
||||||
{ "services", 0, dprintAllServices, "Show all configured services in MaxScale",
|
|
||||||
{0, 0, 0} },
|
|
||||||
{ "servers", 0, dprintAllServers, "Show all configured servers",
|
|
||||||
{0, 0, 0} },
|
|
||||||
{ "server", 1, dprintServer, "Show details for a server, e.g. show server 0x485390",
|
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
|
||||||
{ "modules", 0, dprintAllModules, "Show all currently loaded modules",
|
|
||||||
{0, 0, 0} },
|
|
||||||
{ "dcbs", 0, dprintAllDCBs, "Show all descriptor control blocks (network connections)",
|
{ "dcbs", 0, dprintAllDCBs, "Show all descriptor control blocks (network connections)",
|
||||||
{0, 0, 0} },
|
{0, 0, 0} },
|
||||||
{ "dcb", 1, dprintDCB, "Show a single descriptor control block e.g. show dcb 0x493340",
|
{ "dcb", 1, dprintDCB, "Show a single descriptor control block e.g. show dcb 0x493340",
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ "epoll", 0, dprintPollStats, "Show the poll statistics",
|
|
||||||
{0, 0, 0} },
|
|
||||||
{ "dbusers", 1, dcb_usersPrint, "Show statistics and user names for a service's user table",
|
{ "dbusers", 1, dcb_usersPrint, "Show statistics and user names for a service's user table",
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
|
{ "epoll", 0, dprintPollStats, "Show the poll statistics",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "modules", 0, dprintAllModules, "Show all currently loaded modules",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "monitors", 0, monitorShowAll, "Show the monitors that are configured",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "server", 1, dprintServer, "Show details for a server, e.g. show server 0x485390",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
|
{ "servers", 0, dprintAllServers, "Show all configured servers",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "services", 0, dprintAllServices, "Show all configured services in MaxScale",
|
||||||
|
{0, 0, 0} },
|
||||||
|
{ "session", 1, dprintSession, "Show a single session in MaxScale, e.g. show session 0x284830",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
|
{ "sessions", 0, dprintAllSessions, "Show all active sessions in MaxScale",
|
||||||
|
{0, 0, 0} },
|
||||||
{ "users", 0, telnetdShowUsers, "Show statistics and user names for the debug interface",
|
{ "users", 0, telnetdShowUsers, "Show statistics and user names for the debug interface",
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ NULL, 0, NULL, NULL,
|
{ NULL, 0, NULL, NULL,
|
||||||
@ -108,6 +111,7 @@ struct subcommand showoptions[] = {
|
|||||||
|
|
||||||
extern void shutdown_gateway();
|
extern void shutdown_gateway();
|
||||||
static void shutdown_service(DCB *dcb, SERVICE *service);
|
static void shutdown_service(DCB *dcb, SERVICE *service);
|
||||||
|
static void shutdown_monitor(DCB *dcb, MONITOR *monitor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The subcommands of the shutdown command
|
* The subcommands of the shutdown command
|
||||||
@ -117,6 +121,8 @@ struct subcommand shutdownoptions[] = {
|
|||||||
{0, 0, 0} },
|
{0, 0, 0} },
|
||||||
{ "maxscale", 0, shutdown_gateway, "Shutdown the MaxScale gateway",
|
{ "maxscale", 0, shutdown_gateway, "Shutdown the MaxScale gateway",
|
||||||
{0, 0, 0} },
|
{0, 0, 0} },
|
||||||
|
{ "monitor", 1, shutdown_monitor, "Shutdown a monitor, e.g. shutdown monitor 0x48381e0",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ "service", 1, shutdown_service, "Shutdown a service, e.g. shutdown service 0x4838320",
|
{ "service", 1, shutdown_service, "Shutdown a service, e.g. shutdown service 0x4838320",
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ NULL, 0, NULL, NULL,
|
{ NULL, 0, NULL, NULL,
|
||||||
@ -124,10 +130,13 @@ struct subcommand shutdownoptions[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void restart_service(DCB *dcb, SERVICE *service);
|
static void restart_service(DCB *dcb, SERVICE *service);
|
||||||
|
static void restart_monitor(DCB *dcb, MONITOR *monitor);
|
||||||
/**
|
/**
|
||||||
* The subcommands of the restart command
|
* The subcommands of the restart command
|
||||||
*/
|
*/
|
||||||
struct subcommand restartoptions[] = {
|
struct subcommand restartoptions[] = {
|
||||||
|
{ "monitor", 1, restart_monitor, "Restart a monitor, e.g. restart monitor 0x48181e0",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ "service", 1, restart_service, "Restart a service, e.g. restart service 0x4838320",
|
{ "service", 1, restart_service, "Restart a service, e.g. restart service 0x4838320",
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ NULL, 0, NULL, NULL,
|
{ NULL, 0, NULL, NULL,
|
||||||
@ -163,10 +172,10 @@ static void reload_config(DCB *dcb);
|
|||||||
* The subcommands of the reload command
|
* The subcommands of the reload command
|
||||||
*/
|
*/
|
||||||
struct subcommand reloadoptions[] = {
|
struct subcommand reloadoptions[] = {
|
||||||
{ "users", 1, reload_users, "Reload the user data for a service. E.g. reload users 0x849420",
|
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
|
||||||
{ "config", 0, reload_config, "Reload the configuration data for MaxScale.",
|
{ "config", 0, reload_config, "Reload the configuration data for MaxScale.",
|
||||||
{ARG_TYPE_ADDRESS, 0, 0} },
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
|
{ "users", 1, reload_users, "Reload the user data for a service. E.g. reload users 0x849420",
|
||||||
|
{ARG_TYPE_ADDRESS, 0, 0} },
|
||||||
{ NULL, 0, NULL, NULL,
|
{ NULL, 0, NULL, NULL,
|
||||||
{0, 0, 0} }
|
{0, 0, 0} }
|
||||||
};
|
};
|
||||||
@ -189,13 +198,13 @@ static struct {
|
|||||||
char *cmd;
|
char *cmd;
|
||||||
struct subcommand *options;
|
struct subcommand *options;
|
||||||
} cmds[] = {
|
} cmds[] = {
|
||||||
{ "show", showoptions },
|
{ "add", addoptions },
|
||||||
{ "shutdown", shutdownoptions },
|
{ "clear", clearoptions },
|
||||||
{ "restart", restartoptions },
|
{ "restart", restartoptions },
|
||||||
{ "set", setoptions },
|
{ "set", setoptions },
|
||||||
{ "clear", clearoptions },
|
{ "show", showoptions },
|
||||||
|
{ "shutdown", shutdownoptions },
|
||||||
{ "reload", reloadoptions },
|
{ "reload", reloadoptions },
|
||||||
{ "add", addoptions },
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -537,3 +546,27 @@ telnetdShowUsers(DCB *dcb)
|
|||||||
dcb_printf(dcb, "Administration interface users:\n");
|
dcb_printf(dcb, "Administration interface users:\n");
|
||||||
dcb_PrintAdminUsers(dcb);
|
dcb_PrintAdminUsers(dcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to shutdown a running monitor
|
||||||
|
*
|
||||||
|
* @param dcb The DCB to use to print messages
|
||||||
|
* @param monitor The monitor to shutdown
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
shutdown_monitor(DCB *dcb, MONITOR *monitor)
|
||||||
|
{
|
||||||
|
monitorStop(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to restart a stopped monitor
|
||||||
|
*
|
||||||
|
* @param dcb The DCB to use to print messages
|
||||||
|
* @param monitor The monitor to restart
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
restart_monitor(DCB *dcb, MONITOR *monitor)
|
||||||
|
{
|
||||||
|
monitorStart(monitor);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user