Check mysql-joins
Overview
Checks if many joins per day without indexes were executed on MySQL/MariaDB. Logic is taken from MySQLTuner script:mysql_stats(), v1.9.8.
Hints:
On RHEL 7+, one way to install the Python MySQL Connector is via
pip install pymysql
Compared to check_mysql / MySQLTuner this check currently:
supports only simple login with username/password (not via SSL/TLS)
does not support a connection via socket
Fact Sheet
Check Plugin Download |
https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/mysql-joins |
Check Interval Recommendation |
Once an hour |
Can be called without parameters |
Yes |
Available for |
Python 3, Windows |
Requirements |
Python module |
Help
usage: mysql-joins [-h] [-V] [--always-ok] [-H HOSTNAME] [-p PASSWORD]
[--port PORT] [-u USERNAME]
Checks if many joins per day without indexes were executed on MySQL/MariaDB.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--always-ok Always returns OK.
-H HOSTNAME, --hostname HOSTNAME
MySQL/MariaDB hostname. Default: 127.0.0.1
-p PASSWORD, --password PASSWORD
Use the indicated password to authenticate the
connection. Default:
--port PORT MySQL/MariaDB port. Default: 3306
-u USERNAME, --username USERNAME
MySQL/MariaDB username. Default: root
Usage Examples
./mysql-joins --hostname localhost --username root --password mypassword
Output:
3909 joins performed without indexes [WARNING]. Set join_buffer_size > 4194304, or always use indexes with JOINs. Raise the join_buffer_size until JOINs not using indexes are found.
States
WARN if there are more than 250 joins without indexes per day.
Perfdata / Metrics
Name |
Type |
Description |
---|---|---|
mysql_join_buffer_size |
Bytes |
Minimum size in bytes of the buffer used for queries that cannot use an index, and instead perform a full table scan. Increase to get faster full joins when adding indexes is not possible, although be aware of memory issues, since joins will always allocate the minimum size. |
mysql_select_full_join |
Continous Counter |
Number of joins which did not use an index. If not zero, you may need to check table indexes. |
mysql_select_range_check |
Continous Counter |
Number of joins without keys that check for key usage after each row. If not zero, you may need to check table indexes. |
mysql_uptime |
Seconds |
Number of seconds the server has been running. |
mysql_joins_without_indexes |
Continous Counter |
Select_range_check + Select_full_join |
mysql_joins_without_indexes_per_day |
Number |
joins_without_indexes / Uptime in days |
Credits, License
Authors: Linuxfabrik GmbH, Zurich
License: The Unlicense, see LICENSE file.
Credits:
heavily inspired by MySQLTuner (https://github.com/major/MySQLTuner-perl)