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:
@ -397,16 +397,15 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server)
|
|||||||
void
|
void
|
||||||
monitorAddUser(MONITOR *mon, char *user, char *passwd)
|
monitorAddUser(MONITOR *mon, char *user, char *passwd)
|
||||||
{
|
{
|
||||||
/** If a pointer to mon->password or mon->user is passed as one of the
|
if (user != mon->user)
|
||||||
* parameters the destination and source would overlap. Copy the values to
|
{
|
||||||
* a local buffer to avoid this. */
|
snprintf(mon->user, sizeof(mon->user), "%s", user);
|
||||||
char pwd[strlen(passwd) + 1];
|
}
|
||||||
char usr[strlen(user) + 1];
|
|
||||||
strcpy(usr, user);
|
|
||||||
strcpy(pwd, passwd);
|
|
||||||
|
|
||||||
snprintf(mon->user, sizeof(mon->user), "%s", usr);
|
if (passwd != mon->password)
|
||||||
snprintf(mon->password, sizeof(mon->password), "%s", pwd);
|
{
|
||||||
|
snprintf(mon->password, sizeof(mon->password), "%s", passwd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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[] =
|
struct subcommand createoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -1127,6 +1139,16 @@ struct subcommand createoptions[] =
|
|||||||
ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING,
|
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
|
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[] =
|
struct subcommand destroyoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -1176,6 +1214,12 @@ struct subcommand destroyoptions[] =
|
|||||||
"Usage: destroy listener SERVICE NAME",
|
"Usage: destroy listener SERVICE NAME",
|
||||||
{ARG_TYPE_SERVICE, ARG_TYPE_STRING}
|
{ARG_TYPE_SERVICE, ARG_TYPE_STRING}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"monitor", 1, 1, destroyMonitor,
|
||||||
|
"Destroy a monitor",
|
||||||
|
"Usage: destroy monitor NAME",
|
||||||
|
{ARG_TYPE_MONITOR}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
EMPTY_OPTION
|
EMPTY_OPTION
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user