MXS-2329 Use durations in monitor (common parts)
This commit is contained in:
@ -19,47 +19,67 @@ the `monitorpw` parameter, that value will be used instead.
|
|||||||
|
|
||||||
### `monitor_interval`
|
### `monitor_interval`
|
||||||
|
|
||||||
Defines, in milliseconds, how often the monitor updates the status of the
|
Defines how often the monitor updates the status of the
|
||||||
servers. The default value is 2000 (2 seconds). Choose a lower value if servers
|
servers. The default value is 2 seconds. Choose a lower value if servers
|
||||||
should be queried more often. The smallest possible value is 100. If querying
|
should be queried more often. The smallest possible value is 100 milliseconds.
|
||||||
the servers takes longer than `monitor_interval`, the effective update rate is
|
If querying the servers takes longer than `monitor_interval`, the effective
|
||||||
reduced.
|
update rate is reduced.
|
||||||
|
|
||||||
The default value of `monitor_interval` was updated from 10000 milliseconds to
|
The default value of `monitor_interval` was updated from 10000 milliseconds to
|
||||||
2000 milliseconds in MaxScale 2.2.0.
|
2000 milliseconds in MaxScale 2.2.0.
|
||||||
|
|
||||||
```
|
```
|
||||||
monitor_interval=2500
|
monitor_interval=2500ms
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The interval is specified as documented
|
||||||
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
|
is provided, the value is interpreted as milliseconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected.
|
||||||
|
|
||||||
### `backend_connect_timeout`
|
### `backend_connect_timeout`
|
||||||
|
|
||||||
This parameter controls the timeout for connecting to a monitored server. It is
|
This parameter controls the timeout for connecting to a monitored server.
|
||||||
in seconds and the minimum value is 1 second. The default value for this
|
The interval is specified as documented
|
||||||
parameter is 3 seconds.
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
|
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected. Note that since the granularity
|
||||||
|
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
|
||||||
|
even if the duration is longer than a second. The minimum value is 1 second and
|
||||||
|
the default value for this is 3 seconds.
|
||||||
|
|
||||||
```
|
```
|
||||||
backend_connect_timeout=6
|
backend_connect_timeout=6s
|
||||||
```
|
```
|
||||||
|
|
||||||
### `backend_write_timeout`
|
### `backend_write_timeout`
|
||||||
|
|
||||||
This parameter controls the timeout for writing to a monitored server. It is in
|
This parameter controls the timeout for writing to a monitored server.
|
||||||
seconds and the minimum value is 1 second. The default value for this parameter
|
The timeout is specified as documented
|
||||||
is 3 seconds.
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
|
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected. Note that since the granularity
|
||||||
|
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
|
||||||
|
even if the duration is longer than a second. The minimum value is 1 second and
|
||||||
|
the default value for this is 3 seconds.
|
||||||
|
|
||||||
```
|
```
|
||||||
backend_write_timeout=4
|
backend_write_timeout=4s
|
||||||
```
|
```
|
||||||
|
|
||||||
### `backend_read_timeout`
|
### `backend_read_timeout`
|
||||||
|
|
||||||
This parameter controls the timeout for reading from a monitored server. It is
|
This parameter controls the timeout for reading from a monitored server.
|
||||||
in seconds and the minimum value is 1 second. The default value for this
|
The timeout is specified as documented
|
||||||
parameter is 3 seconds.
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
|
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected. Note that since the granularity
|
||||||
|
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
|
||||||
|
even if the duration is longer than a second. The minimum value is 1 second and
|
||||||
|
the default value for this is 3 seconds.
|
||||||
|
|
||||||
```
|
```
|
||||||
backend_read_timeout=2
|
backend_read_timeout=2s
|
||||||
```
|
```
|
||||||
|
|
||||||
### `backend_connect_attempts`
|
### `backend_connect_attempts`
|
||||||
@ -161,10 +181,13 @@ at `/DbData` while both `server2` and `server3` have it mounted on
|
|||||||
|
|
||||||
### `disk_space_check_interval`
|
### `disk_space_check_interval`
|
||||||
|
|
||||||
With this positive integer parameter it can be specified in milliseconds
|
With this parameter it can be specified the minimum amount of time
|
||||||
the minimum amount of time between disk space checks. The default value
|
between disk space checks. The interval is specified as documented
|
||||||
is `20000`, which means that the disk space situation will be checked
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
once every 20 seconds.
|
is provided, the value is interpreted as milliseconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected.
|
||||||
|
The default value is 0, which means that by default the disk space
|
||||||
|
will not be checked.
|
||||||
|
|
||||||
Note that as the checking is made as part of the regular monitor interval
|
Note that as the checking is made as part of the regular monitor interval
|
||||||
cycle, the disk space check interval is affected by the value of
|
cycle, the disk space check interval is affected by the value of
|
||||||
@ -172,7 +195,7 @@ cycle, the disk space check interval is affected by the value of
|
|||||||
`disk_space_check_interval` is smaller than that of `monitor_interval`,
|
`disk_space_check_interval` is smaller than that of `monitor_interval`,
|
||||||
the checking will still take place at `monitor_interval` intervals.
|
the checking will still take place at `monitor_interval` intervals.
|
||||||
```
|
```
|
||||||
disk_space_check_interval=10000
|
disk_space_check_interval=10000ms
|
||||||
```
|
```
|
||||||
|
|
||||||
### `script`
|
### `script`
|
||||||
@ -220,8 +243,12 @@ case-insensitive.
|
|||||||
|
|
||||||
### `script_timeout`
|
### `script_timeout`
|
||||||
|
|
||||||
The timeout for the executed script in seconds. The default value is 90
|
The timeout for the executed script. The interval is specified as documented
|
||||||
seconds.
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
|
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected. Note that since the granularity
|
||||||
|
of the timeout is seconds, a timeout specified in milliseconds will be rejected,
|
||||||
|
even if the duration is longer than a second. The default value is 90 seconds.
|
||||||
|
|
||||||
If the script execution exceeds the configured timeout, it is stopped by sending
|
If the script execution exceeds the configured timeout, it is stopped by sending
|
||||||
a SIGTERM signal to it. If the process does not stop, a SIGKILL signal will be
|
a SIGTERM signal to it. If the process does not stop, a SIGKILL signal will be
|
||||||
@ -254,7 +281,12 @@ new_slave |A new Slave was detected
|
|||||||
|
|
||||||
### `journal_max_age`
|
### `journal_max_age`
|
||||||
|
|
||||||
The maximum journal file age in seconds. The default value is 28800 seconds.
|
The maximum journal file age. The interval is specified as documented
|
||||||
|
[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit unit
|
||||||
|
is provided, the value is interpreted as seconds in MaxScale 2.4. In subsequent
|
||||||
|
versions a value without a unit may be rejected. Note that since the granularity
|
||||||
|
of the max age is seconds, a max age specified in milliseconds will be rejected,
|
||||||
|
even if the duration is longer than a second. The default value is 28800 seconds.
|
||||||
|
|
||||||
When the monitor starts, it reads any stored journal files. If the journal file
|
When the monitor starts, it reads any stored journal files. If the journal file
|
||||||
is older than the value of _journal_max_age_, it will be removed and the monitor
|
is older than the value of _journal_max_age_, it will be removed and the monitor
|
||||||
|
|||||||
@ -522,13 +522,14 @@ const MXS_MODULE_PARAM config_monitor_params[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_MONITOR_INTERVAL,
|
CN_MONITOR_INTERVAL,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MXS_MODULE_PARAM_DURATION,
|
||||||
"2000"
|
"2000ms"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_BACKEND_CONNECT_TIMEOUT,
|
CN_BACKEND_CONNECT_TIMEOUT,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MXS_MODULE_PARAM_DURATION,
|
||||||
"3"
|
"3s",
|
||||||
|
MXS_MODULE_OPT_DURATION_S
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_BACKEND_READ_TIMEOUT,
|
CN_BACKEND_READ_TIMEOUT,
|
||||||
@ -537,8 +538,9 @@ const MXS_MODULE_PARAM config_monitor_params[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_BACKEND_WRITE_TIMEOUT,
|
CN_BACKEND_WRITE_TIMEOUT,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MXS_MODULE_PARAM_DURATION,
|
||||||
"2"
|
"2s",
|
||||||
|
MXS_MODULE_OPT_DURATION_S
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_BACKEND_CONNECT_ATTEMPTS,
|
CN_BACKEND_CONNECT_ATTEMPTS,
|
||||||
@ -547,8 +549,9 @@ const MXS_MODULE_PARAM config_monitor_params[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_JOURNAL_MAX_AGE,
|
CN_JOURNAL_MAX_AGE,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MXS_MODULE_PARAM_DURATION,
|
||||||
"28800"
|
"28800s",
|
||||||
|
MXS_MODULE_OPT_DURATION_S
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_DISK_SPACE_THRESHOLD,
|
CN_DISK_SPACE_THRESHOLD,
|
||||||
@ -556,8 +559,8 @@ const MXS_MODULE_PARAM config_monitor_params[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_DISK_SPACE_CHECK_INTERVAL,
|
CN_DISK_SPACE_CHECK_INTERVAL,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MXS_MODULE_PARAM_DURATION,
|
||||||
"0"
|
"0ms"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_SCRIPT, // Cannot be a path type as the script may have parameters
|
CN_SCRIPT, // Cannot be a path type as the script may have parameters
|
||||||
@ -565,8 +568,9 @@ const MXS_MODULE_PARAM config_monitor_params[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_SCRIPT_TIMEOUT,
|
CN_SCRIPT_TIMEOUT,
|
||||||
MXS_MODULE_PARAM_COUNT,
|
MXS_MODULE_PARAM_DURATION,
|
||||||
"90"
|
"90s",
|
||||||
|
MXS_MODULE_OPT_DURATION_S
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CN_EVENTS,
|
CN_EVENTS,
|
||||||
|
|||||||
@ -433,23 +433,27 @@ const char* Monitor::name() const
|
|||||||
return m_name.c_str();
|
return m_name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using std::chrono::milliseconds;
|
||||||
|
using std::chrono::seconds;
|
||||||
|
|
||||||
bool Monitor::configure(const MXS_CONFIG_PARAMETER* params)
|
bool Monitor::configure(const MXS_CONFIG_PARAMETER* params)
|
||||||
{
|
{
|
||||||
m_settings.interval = params->get_integer(CN_MONITOR_INTERVAL);
|
m_settings.interval = params->get_duration<milliseconds>(CN_MONITOR_INTERVAL).count();
|
||||||
m_settings.journal_max_age = params->get_integer(CN_JOURNAL_MAX_AGE);
|
m_settings.journal_max_age = params->get_duration<seconds>(CN_JOURNAL_MAX_AGE).count();
|
||||||
m_settings.script_timeout = params->get_integer(CN_SCRIPT_TIMEOUT);
|
m_settings.script_timeout = params->get_duration<seconds>(CN_SCRIPT_TIMEOUT).count();
|
||||||
m_settings.script = params->get_string(CN_SCRIPT);
|
m_settings.script = params->get_string(CN_SCRIPT);
|
||||||
m_settings.events = params->get_enum(CN_EVENTS, mxs_monitor_event_enum_values);
|
m_settings.events = params->get_enum(CN_EVENTS, mxs_monitor_event_enum_values);
|
||||||
|
|
||||||
m_settings.conn_settings.read_timeout = params->get_integer(CN_BACKEND_READ_TIMEOUT);
|
MonitorServer::ConnectionSettings& conn_settings = m_settings.conn_settings;
|
||||||
m_settings.conn_settings.write_timeout = params->get_integer(CN_BACKEND_WRITE_TIMEOUT);
|
conn_settings.read_timeout = params->get_duration<seconds>(CN_BACKEND_READ_TIMEOUT).count();
|
||||||
m_settings.conn_settings.connect_timeout = params->get_integer(CN_BACKEND_CONNECT_TIMEOUT);
|
conn_settings.write_timeout = params->get_duration<seconds>(CN_BACKEND_WRITE_TIMEOUT).count();
|
||||||
m_settings.conn_settings.connect_attempts = params->get_integer(CN_BACKEND_CONNECT_ATTEMPTS);
|
conn_settings.connect_timeout = params->get_duration<seconds>(CN_BACKEND_CONNECT_TIMEOUT).count();
|
||||||
m_settings.conn_settings.username = params->get_string(CN_USER);
|
conn_settings.connect_attempts = params->get_integer(CN_BACKEND_CONNECT_ATTEMPTS);
|
||||||
m_settings.conn_settings.password = params->get_string(CN_PASSWORD);
|
conn_settings.username = params->get_string(CN_USER);
|
||||||
|
conn_settings.password = params->get_string(CN_PASSWORD);
|
||||||
|
|
||||||
// Disk check interval is given in ms, duration is constructed from seconds.
|
// Disk check interval is given in ms, duration is constructed from seconds.
|
||||||
auto dsc_interval = params->get_integer(CN_DISK_SPACE_CHECK_INTERVAL);
|
auto dsc_interval = params->get_duration<milliseconds>(CN_DISK_SPACE_CHECK_INTERVAL).count();
|
||||||
// 0 implies disabling -> save negative value to interval.
|
// 0 implies disabling -> save negative value to interval.
|
||||||
m_settings.disk_space_check_interval = (dsc_interval > 0) ?
|
m_settings.disk_space_check_interval = (dsc_interval > 0) ?
|
||||||
mxb::Duration(static_cast<double>(dsc_interval) / 1000) : mxb::Duration(-1);
|
mxb::Duration(static_cast<double>(dsc_interval) / 1000) : mxb::Duration(-1);
|
||||||
|
|||||||
Reference in New Issue
Block a user