From f20005dddca87ba72a0b4aa63c99fe69be2d67a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 27 Sep 2017 12:54:07 +0300 Subject: [PATCH] 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`. --- server/core/config_runtime.cc | 18 ++++++++++++++++++ server/core/monitor.cc | 5 +++++ server/modules/routing/debugcli/debugcmd.c | 15 +++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 3089be706..96836294f 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -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 */ diff --git a/server/core/monitor.cc b/server/core/monitor.cc index cccda7afb..a82bedebe 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -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); diff --git a/server/modules/routing/debugcli/debugcmd.c b/server/modules/routing/debugcli/debugcmd.c index 988a790de..f7e1b0aaa 100644 --- a/server/modules/routing/debugcli/debugcmd.c +++ b/server/modules/routing/debugcli/debugcmd.c @@ -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"