Check mysql-table-locks¶
Overview¶
Checks the rate of table locks that had to wait in MySQL/MariaDB. A high wait rate indicates contention between concurrent queries. Logic is taken from MySQLTuner script:mysql_stats(), v1.9.8.
Important Notes:
Data Collection:
Queries
SHOW GLOBAL STATUSforTable_locks_immediateandTable_locks_waitedCalculates the immediate lock rate as
Table_locks_immediate / (Table_locks_waited + Table_locks_immediate) * 100
Fact Sheet¶
Fact |
Value |
|---|---|
Check Plugin Download |
https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/mysql-table-locks |
Nagios/Icinga Check Name |
|
Check Interval Recommendation |
Every hour |
Can be called without parameters |
Yes |
Runs on |
Cross-platform |
Compiled for Windows |
No |
Requirements |
User with no privileges, locked down to |
3rd Party Python modules |
|
Help¶
usage: mysql-table-locks [-h] [-V] [--always-ok]
[--defaults-file DEFAULTS_FILE]
[--defaults-group DEFAULTS_GROUP] [--timeout TIMEOUT]
Checks the rate of table locks that had to wait in MySQL/MariaDB. A high wait
rate indicates contention between concurrent queries. Alerts when the lock
wait rate is too high.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--always-ok Always returns OK.
--defaults-file DEFAULTS_FILE
MySQL/MariaDB cnf file to read parameters like user,
host and password from (instead of specifying them on
the command line). Example:
`/var/spool/icinga2/.my.cnf`. Default:
/var/spool/icinga2/.my.cnf
--defaults-group DEFAULTS_GROUP
Group/section to read from in the cnf file. Default:
client
--timeout TIMEOUT Network timeout in seconds. Default: 3 (seconds)
Usage Examples¶
./mysql-table-locks --defaults-file=/var/spool/icinga2/.my.cnf
Output:
100% table locks acquired immediately (2.6K immediate / 2.6K locks).
States¶
OK if 95% or more of table locks were acquired immediately.
WARN if less than 95% of table locks were acquired immediately.
--always-oksuppresses all alerts and always returns OK.
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 |
Continuous Counter |
Number of table locks which were completed immediately. |
mysql_table_locks_waited |
Continuous 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)