Check mysql-table-cache
Overview
Checks the hit rate for open tables cache lookups in MySQL/MariaDB. Logic is taken from MySQLTuner script:mysql_stats(), v1.9.8.
Hints:
Requires MySQL/MariaDB v5.1+.
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-cache |
Check Interval Recommendation |
Every 5 minutes |
Can be called without parameters |
Yes |
Available for |
Python 3, Windows |
Requirements |
Python module |
Help
usage: mysql-table-cache [-h] [-V] [--always-ok] [-H HOSTNAME] [-p PASSWORD]
[--port PORT] [-u USERNAME]
Checks the hit rate for open tables cache lookups 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-cache --hostname localhost --username root --password mypassword
Output:
100.0% table cache hit rate (2.3M hits / 2.3M requests)
States
WARN if
table_cache_hit_rate
< 20%
Perfdata / Metrics
Name |
Type |
Description |
---|---|---|
mysql_open_files_limit |
Number |
The number of file descriptors available to MariaDB. |
mysql_open_tables |
Number |
Number of currently opened tables, excluding temporary tables. |
mysql_opened_tables |
Continous Counter |
Number of tables the server has opened. |
mysql_table_cache_hit_rate |
Percentage |
Table_open_cache_hits / (Table_open_cache_hits + Table_open_cache_misses) * 100. If Table_open_cache_hits is not available: Open_tables / Opened_tables * 100 |
mysql_table_open_cache |
Number |
Maximum number of open tables cached in one table cache instance. |
mysql_table_open_cache_hits |
Continous Counter |
Number of hits for open tables cache lookups. |
mysql_table_open_cache_misses |
Continous Counter |
Number of misses for open tables cache lookups. |
Credits, License
Authors: Linuxfabrik GmbH, Zurich
License: The Unlicense, see LICENSE file.
Credits:
heavily inspired by MySQLTuner (https://github.com/major/MySQLTuner-perl)