Add creation and destruction of monitors to maxadmin
Maxadmin can now create and destroy monitors. The created monitors are not started as they would be useless without added servers and configuration parameters.
This commit is contained in:
@ -1081,6 +1081,18 @@ static void createListener(DCB *dcb, SERVICE *service, char *name, char *address
|
||||
}
|
||||
}
|
||||
|
||||
static void createMonitor(DCB *dcb, const char *name, const char *module)
|
||||
{
|
||||
if (runtime_create_monitor(name, module))
|
||||
{
|
||||
dcb_printf(dcb, "Created monitor '%s'\n", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb_printf(dcb, "Failed to create monitor '%s', see log for more details\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
struct subcommand createoptions[] =
|
||||
{
|
||||
{
|
||||
@ -1127,6 +1139,16 @@ struct subcommand createoptions[] =
|
||||
ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING,
|
||||
}
|
||||
},
|
||||
{
|
||||
"monitor", 2, 2, createMonitor,
|
||||
"Create a new monitor",
|
||||
"Usage: create monitor NAME MODULE\n"
|
||||
"NAME Monitor name\n"
|
||||
"MODULE Monitor module\n",
|
||||
{
|
||||
ARG_TYPE_STRING, ARG_TYPE_STRING
|
||||
}
|
||||
},
|
||||
{
|
||||
EMPTY_OPTION
|
||||
}
|
||||
@ -1162,6 +1184,22 @@ static void destroyListener(DCB *dcb, SERVICE *service, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void destroyMonitor(DCB *dcb, MONITOR *monitor)
|
||||
{
|
||||
char name[strlen(monitor->name) + 1];
|
||||
strcpy(name, monitor->name);
|
||||
|
||||
if (runtime_destroy_monitor(monitor))
|
||||
{
|
||||
dcb_printf(dcb, "Destroyed monitor '%s'\n", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb_printf(dcb, "Failed to destroy monitor '%s', see log file for more details\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
struct subcommand destroyoptions[] =
|
||||
{
|
||||
{
|
||||
@ -1176,6 +1214,12 @@ struct subcommand destroyoptions[] =
|
||||
"Usage: destroy listener SERVICE NAME",
|
||||
{ARG_TYPE_SERVICE, ARG_TYPE_STRING}
|
||||
},
|
||||
{
|
||||
"monitor", 1, 1, destroyMonitor,
|
||||
"Destroy a monitor",
|
||||
"Usage: destroy monitor NAME",
|
||||
{ARG_TYPE_MONITOR}
|
||||
},
|
||||
{
|
||||
EMPTY_OPTION
|
||||
}
|
||||
|
Reference in New Issue
Block a user