MySQL: Use CheckMk to monitor MySQL

CheckMk is a great tool for monitoring. Especially when it comes to standard functions for operating systems.
But CheckMk is also great for the monitoring of MySQL databases.
If you want to use it, just install the CheckMk agent on the MySQL server. Additionally, you'll need the MySQL plugin:
Setup -> Linux -> Plugins -> mk_mysql
Copy it to
/usr/lib/check_mk_agent/plugins
and change execution rights:
# chmod +x mk_mysql
Additionally, you'll need something to make the plugin able to login to the database(s), like a configuration file:
/etc/check_mk/mysql.cfg
Only user and password are used. To simplify, I used plaintext, but you could also use other configurations:
[client]
user=root
password=XxXxXxXx
If your environment is more complex, you should look at the CheckMk documentation.
You can test the Plugin like that (using the root
user):
# cd /usr/lib/check_mk_agent/plugins
# MK_CONFDIR=/etc/check_mk ./mk_mysql
The output should look like this:
<<<mysql_ping>>>
[[]]
mysqld is alive
<<<mysql>>>
[[]]
Aborted_clients 0
Aborted_connects 0
Acl_cache_items_count 0
Binlog_cache_disk_use 0
Binlog_cache_use 0
Binlog_stmt_cache_disk_use 0
Binlog_stmt_cache_use 0
Bytes_received 190381
Bytes_sent 5237168
[...]
tls_version TLSv1.2,TLSv1.3
tmp_table_size 16777216
tmpdir /tmp
transaction_alloc_block_size 8192
transaction_isolation REPEATABLE-READ
transaction_prealloc_size 4096
transaction_read_only OFF
unique_checks ON
updatable_views_with_limit YES
version 9.2.0
version_comment MySQL Community Server - GPL
version_compile_machine x86_64
version_compile_os Linux
version_compile_zlib 1.2.13
wait_timeout 28800
windowing_use_high_precision ON
xa_detach_on_prepare ON
<<<mysql_capacity>>>
[[]]
information_schema 0 0
mysql 2736128 339738624
performance_schema 0 0
sys 16384 0
<<<mysql_replica_slave>>>
[[]]
To be able to monitor the MySQL plugin results, we have to run the service discovery (the yellow box):

We can now finde new services:

We can acknowledge them, an then, MySQL is under monitoring.

To make sure that all the changes are persisted, we have to acknowledge the changes:


After a while, the plugin has collected some data, and you can see it in monitoring:
