Check mysql-table-locks
Overview
Checks whether a certain percentage of table locks had to wait in 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-table-locks |
Check Interval Recommendation |
Once an hour |
Can be called without parameters |
Yes |
Available for |
Python 3, Windows |
Requirements |
Python module |
Help
usage: mysql-table-locks [-h] [-V] [--always-ok] [-H HOSTNAME] [-p PASSWORD]
[--port PORT] [-u USERNAME]
Checks whether a certain percentage of table locks had to wait in
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-table-locks --hostname localhost --username root --password mypassword
Output:
100% table locks acquired immediately (2.6K immediate / 2.6K locks).
States
WARN if less than 95% table locks were completed immediately.
Perfdata / Metrics
Name |
Type |
Description |
---|---|---|
mysql_pct_table_locks_immediate |
Percentage |
Table_locks_immediate / (Table_locks_waited + Table_locks_immediate) * 100 |
mysql_table_locks_immediate |
Continous Counter |
Number of table locks which were completed immediately. |
mysql_table_locks_waited |
Continous Counter |
Number of table locks which had to wait. Indicates table lock contention. |
Credits, License
Authors: Linuxfabrik GmbH, Zurich
License: The Unlicense, see LICENSE file.
Credits:
heavily inspired by MySQLTuner (https://github.com/major/MySQLTuner-perl)