Add missing parameters to alter monitor

The `script_timeout` and `journal_max_age` parameters weren't handled in
the monitor alteration code.

Also added missing documentation to maxadmin help output for
`alter monitor`.
This commit is contained in:
Markus Mäkelä 2017-09-27 12:54:07 +03:00
parent 7b6680b8fa
commit f20005dddc
3 changed files with 32 additions and 6 deletions

View File

@ -503,6 +503,24 @@ bool runtime_alter_monitor(MXS_MONITOR *monitor, const char *key, const char *va
monitorSetNetworkTimeout(monitor, MONITOR_CONNECT_ATTEMPTS, ival);
}
}
else if (strcmp(key, CN_JOURNAL_MAX_AGE) == 0)
{
long ival = get_positive_int(value);
if (ival)
{
valid = true;
monitorSetJournalMaxAge(monitor, ival);
}
}
else if (strcmp(key, CN_SCRIPT_TIMEOUT) == 0)
{
long ival = get_positive_int(value);
if (ival)
{
valid = true;
monitorSetScriptTimeout(monitor, ival);
}
}
else
{
/** We're modifying module specific parameters and we need to stop the monitor */

View File

@ -1489,6 +1489,8 @@ static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filena
dprintf(file, "%s=%d\n", CN_BACKEND_WRITE_TIMEOUT, monitor->write_timeout);
dprintf(file, "%s=%d\n", CN_BACKEND_READ_TIMEOUT, monitor->read_timeout);
dprintf(file, "%s=%d\n", CN_BACKEND_CONNECT_ATTEMPTS, monitor->connect_attempts);
dprintf(file, "%s=%ld\n", CN_JOURNAL_MAX_AGE, monitor->journal_max_age);
dprintf(file, "%s=%d\n", CN_SCRIPT_TIMEOUT, monitor->script_timeout);
if (monitor->databases)
{
@ -1516,6 +1518,8 @@ static bool create_monitor_config(const MXS_MONITOR *monitor, const char *filena
CN_BACKEND_WRITE_TIMEOUT,
CN_BACKEND_READ_TIMEOUT,
CN_BACKEND_CONNECT_ATTEMPTS,
CN_JOURNAL_MAX_AGE,
CN_SCRIPT_TIMEOUT,
CN_SERVERS
};
@ -1699,6 +1703,7 @@ json_t* monitor_parameters_to_json(const MXS_MONITOR* monitor)
json_object_set_new(rval, CN_BACKEND_WRITE_TIMEOUT, json_integer(monitor->write_timeout));
json_object_set_new(rval, CN_BACKEND_CONNECT_ATTEMPTS, json_integer(monitor->connect_attempts));
json_object_set_new(rval, CN_JOURNAL_MAX_AGE, json_integer(monitor->journal_max_age));
json_object_set_new(rval, CN_SCRIPT_TIMEOUT, json_integer(monitor->script_timeout));
/** Add custom module parameters */
const MXS_MODULE* mod = get_module(monitor->module_name, MODULE_MONITOR);

View File

@ -1584,12 +1584,15 @@ struct subcommand alteroptions[] =
"KEY=VALUE List of `key=value` pairs separated by spaces\n"
"\n"
"All monitors support the following values for KEY:\n"
"user Username used when connecting to servers\n"
"password Password used when connecting to servers\n"
"monitor_interval Monitoring interval in milliseconds\n"
"backend_connect_timeout Server coneection timeout in seconds\n"
"backend_write_timeout Server write timeout in seconds\n"
"backend_read_timeout Server read timeout in seconds\n"
"user Username used when connecting to servers\n"
"password Password used when connecting to servers\n"
"monitor_interval Monitoring interval in milliseconds\n"
"backend_connect_timeout Server coneection timeout in seconds\n"
"backend_write_timeout Server write timeout in seconds\n"
"backend_read_timeout Server read timeout in seconds\n"
"backend_connect_attempts Number of re-connection attempts\n"
"journal_max_age Maximum age of server state journal\n"
"script_timeout Timeout in seconds for monitor scripts\n"
"\n"
"This will alter an existing parameter of a monitor. To remove parameters,\n"
"pass an empty value for a key e.g. 'maxadmin alter monitor my-monitor my-key='\n"