139 Commits

Author SHA1 Message Date
Esa Korhonen
b9ec3f5130 Monitor json diagnostics printing cleanup
The 'events' and 'script' config values were defined for every monitor.
Removed the extra definitions and moved the variables to MXS_MONITOR.

MariaDBMonitor was printing config values a second time, they are
already printed by the caller.

Moved the events enum definition to the internal header since it's no longer
required by modules.

Added a default config setting "all" to 'events' to clarify that it enables
all events.
2018-08-10 11:19:09 +03:00
Markus Mäkelä
a252b45f18
Don't use auto&& in non-template code
Use explicit types instead.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
46ed043fb0
Display diagnostics for running monitors
If a monitor is not running, the diagnostics function will not be called.
2018-08-02 18:56:36 +03:00
Markus Mäkelä
d412b8d729
Move execute_worker_task into mxs::Worker
The function has use outside of the monitors as it makes execution of
worker tasks much more convenient. Currently, this change only moves the
code and takes it into use: there should be no functional changes.
2018-08-02 18:56:35 +03:00
Markus Mäkelä
ec420332ea
MXS-1929: Take ResultSet into use
Replaced the previous RESULTSET with the new implementation. As the new
ResultSet doesn't have a JSON streaming capability, the MaxInfo JSON
interface has been removed. This should not be a big problem as the REST
API offers the same information in a more secure and structured way.
2018-07-31 22:50:08 +03:00
Esa Korhonen
1e33ab69f2 Rename server_is_running() to server_is_usable()
The previous name was misleading. The new server_is_running() only
checks for the running bit so that a server is always either running
or down.
2018-07-31 14:53:56 +03:00
Markus Mäkelä
3be975ba5d
Fix fixing of std::string object names
Comparing two fixed std::strings would have equal C strings but comparing
with operator== they would be different. This was a result of the string
modification done by fix_object_name.

Converted the internal header into a C++ header, added std::string
overload and fixed use of the function.
2018-07-31 09:41:15 +03:00
Esa Korhonen
fbce38878b Turn server status macros to functions 2018-07-25 11:19:47 +03:00
Esa Korhonen
b421e56d1c Move execute_worker_task to MonitorInstance
The function is rather general and may of use to other monitor modules.
2018-07-24 15:07:18 +03:00
Markus Mäkelä
c31e78754d
Fix object name tokenization
Spaces must be considered a part of the object name in tokenization. This
ensures that the name normalization process generates correct names and
that tokens are split at correct places.
2018-07-17 11:52:23 +03:00
Markus Mäkelä
4a0ace2a72
Use module-style parameters with monitors
The common monitor parameters are now stored as module-style
parameters. This makes the error reporting as well as the type checks for
the parameters consistent with parameters declared by the modules.
2018-07-17 11:52:15 +03:00
Esa Korhonen
7ded2c436f Fix monitor shutdown and restart
Monitor restart was not working.
2018-07-03 10:32:06 +03:00
Johan Wikman
1eddb29d91 MXS-1915 Move Monitors on top of mxs::Worker
Monitors are now workers, so the path for making all interaction
between MaxScale proper and the monitors message based is now
open.
2018-06-26 09:19:46 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Markus Mäkelä
026313fcc7
Clear status bits of server that are down
At the start of the monitor tick, the monitor pending status is set to the
value of the current server status. This allows the informative and
history bits to survive even if a server goes down.

To make sure that no stale state bits are in effect when the post_tick
method is called, the pending status must be cleared of all status bits.
2018-06-18 14:25:05 +03:00
Esa Korhonen
d0453bd3ed Measure monitor loop execution time when calculating sleep time 2018-06-11 13:30:36 +03:00
Johan Wikman
8afa8c2c5a MXS-1775 Add MonitorInstanceSimple class
MonitorInstanceSimple is intended for simple monitors that
probe servers in a straightforward fashion. More complex monitors
can be derived directly from MonitorInstance.
2018-06-07 15:13:26 +03:00
Johan Wikman
6d1863451a MXS-1775 Fix galera monitor
The statuses were flushed at the wrong place as far as the
Galera monitor was concerned.
2018-06-06 15:34:40 +03:00
Johan Wikman
af717426d5 MXS-1775 Load server journal unconditionally
The server journal is unconditionally loaded and need not be
done in @c pre_loop.
2018-06-06 15:25:57 +03:00
Johan Wikman
f600b3a769 MXS-1775 Check disk space in MariaDBMonitor 2018-06-06 15:25:57 +03:00
Johan Wikman
329a6df662 MXS-1775 Factor out post-processing
Further adjustments for being able to move MariaDBMonitor on
top of MonitorInstance::main().
2018-06-06 15:25:57 +03:00
Johan Wikman
71194d83d3 MXS-1775 Rearrange for moving main loop to MonitorInstance
This is another step in the process for moving the main loop
from MariaDBMonitor to MonitorInstance.
2018-06-06 15:25:57 +03:00
Johan Wikman
5172c43e29 MXS-1775 Add functions for checking disk space of servers 2018-06-06 15:25:57 +03:00
Markus Mäkelä
70fdd0fc17
Merge branch '2.2' into develop 2018-06-06 08:56:31 +03:00
Markus Mäkelä
f2b2951c99
Track the number of performed monitoring intervals
Tracking how many times the monitor has performed its monitoring allows
the test framework to consistently wait for an event instead of waiting
for a hard-coded time period. The MaxCtrl `api get` command can be used to
easily extract the numeric value.
2018-06-06 08:46:46 +03:00
Esa Korhonen
7cd19a12a2 MXS-1883 Remove locking during monitor loop
Since the admin cannot modify server states any more, the locks are not
required.
2018-06-01 15:03:07 +03:00
Johan Wikman
e8deb553be MXS-1775 Make MonitorInstance more resilient towards abuse
If MonitorInstance is in the wrong state when it is started/stopped
a warning is logged and the operation ignored.
2018-06-01 13:48:15 +03:00
Johan Wikman
a55019774d MXS-1775 Expose the state of the monitor 2018-06-01 13:48:15 +03:00
Johan Wikman
ebcb807438 MXS-1775 Add default implementations 2018-06-01 13:48:15 +03:00
Johan Wikman
9b7e37e112 MXS-1775 Change MonitorInstance::configure() prototype
Now return boolean, to allow derived class to signal a failure
to configure.
2018-06-01 13:48:15 +03:00
Johan Wikman
0833db8a48 MXS-1775 Flush pending status to servers using common code 2018-06-01 13:48:15 +03:00
Johan Wikman
15b1c270a3 MXS-1775 Check connection in MonitorInstance::tick()
Since the connection checking is done in an identical fashion in
all monitors, it can be moved to the base-class.
2018-06-01 13:48:15 +03:00
Johan Wikman
df4e19eb27 MXS-1775 Provide default implementation for MonitorInstance::tick 2018-06-01 13:48:15 +03:00
Johan Wikman
af9beecaef MXS-1775 Handle config param disk_space_check_interval 2018-06-01 13:48:15 +03:00
Johan Wikman
11c04ff8a8 MXS-1775 Add disk space threshold to server and monitor
- Instance variable.
- Functions for setting it from configuration file.
2018-06-01 13:48:15 +03:00
Esa Korhonen
c039821467 MXS-1883 Maintenance is now the only user-modifiable bit for a monitored server
The request to turn maintenance off/on is a separate flag, although the actual
status is still contained in the status bitfield.
2018-05-30 10:09:15 +03:00
Markus Mäkelä
0848bedf34
Add comment to static_assert
The C++11 version requires a second parameter.
2018-05-24 12:49:19 +03:00
Esa Korhonen
a2cd4feeaf Store server states as 64-bit to the monitor journal
The journal schema version was changed.
2018-05-24 11:35:34 +03:00
Esa Korhonen
f8940d4a2a Use 64bits for server status flags
Monitor journal still uses 32bits.
2018-05-23 16:19:08 +03:00
Johan Wikman
9d526332d8 MXS-1775 Ensure MonitorInstance::start() returns correct value
Since we need to call mysql_thread_init(), which can fail, in
the monitor thread, we need to wait for the outcome of that
before we can return from start().
2018-05-18 16:00:05 +03:00
Johan Wikman
650a739c92 MXS-1775 Move monitor loop to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
db30ea96f2 MXS-1775 m_master is now a member variable of MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
6db4ce54a9 MXS-1775 MonitorInstance now calls mysql_thread_[init|finish]() 2018-05-18 16:00:05 +03:00
Johan Wikman
15e3a2887c MXS-1775 Move status management to MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
1e084b78b1 MXS-1775 MonitorInstance::m_script is now a std::string 2018-05-18 16:00:05 +03:00
Johan Wikman
c7eb0a9958 MXS-1775 Thread starting is now handled by MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
adb7f156d6 MXS-1775 Introduce MonitorInstance::has_sufficient_permissions()
With this function in place, it is now possible to move the thread
starting to MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
3606a5ed1c MXS-1775 Introduce MonitorInstance::configure() function
The configuring of the monitor instance is now performed in a
separate function. That is in preparation for the moving of the
start function to maxscale::MonitorInstance.
2018-05-18 16:00:05 +03:00
Johan Wikman
bcb7d09a15 MXS-1775 Monitor stopping moved to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00
Johan Wikman
1304fd6147 MXS-1775 Move thread main function to maxscale::MonitorInstance 2018-05-18 16:00:05 +03:00