Check mysql-temp-tables¶
Overview¶
Checks the ratio of on-disk versus in-memory temporary tables in MySQL/MariaDB. A high rate of disk-based temporary tables indicates that tmp_table_size or max_heap_table_size may need to be increased. Logic is taken from MySQLTuner script:mysql_stats(), v1.9.8.
Important Notes:
Data Collection:
Queries
SHOW GLOBAL VARIABLESformax_heap_table_sizeandtmp_table_sizeQueries
SHOW GLOBAL STATUSforCreated_tmp_disk_tablesandCreated_tmp_tablesCalculates the disk temporary table rate as
Created_tmp_disk_tables / Created_tmp_tables * 100
Fact Sheet¶
Fact |
Value |
|---|---|
Check Plugin Download |
https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/mysql-temp-tables |
Nagios/Icinga Check Name |
|
Check Interval Recommendation |
Every 15 minutes |
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-temp-tables [-h] [-V] [--always-ok]
[--defaults-file DEFAULTS_FILE]
[--defaults-group DEFAULTS_GROUP] [--timeout TIMEOUT]
Checks the ratio of on-disk versus in-memory temporary tables in
MySQL/MariaDB. A high rate of disk-based temporary tables indicates that
tmp_table_size or max_heap_table_size may need to be increased. Alerts when
the disk-based temporary table 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-temp-tables --defaults-file=/var/spool/icinga2/.my.cnf
Output:
34.6% temporary tables created on disk (540.0 on disk / 1.6K total)
Recommendations:
* Set tmp_table_size > 128.0MiB and max_heap_table_size > 128.0MiB
* When making adjustments, make tmp_table_size/max_heap_table_size equal
* Reduce your SELECT DISTINCT queries which have no LIMIT clause
States¶
OK if the disk-based temporary table rate is 25% or lower, or if no temporary tables have been created.
WARN if more than 25% of temporary tables are created on disk.
--always-oksuppresses all alerts and always returns OK.
Perfdata / Metrics¶
Name |
Type |
Description |
|---|---|---|
mysql_created_tmp_disk_tables |
Continuous Counter |
Number of on-disk temporary tables created. |
mysql_created_tmp_tables |
Continuous Counter |
Number of in-memory temporary tables created. |
mysql_max_heap_table_size |
Bytes |
Maximum size in bytes for user-created MEMORY tables. |
mysql_max_tmp_table_size |
Bytes |
max(max_heap_table_size, tmp_table_size) |
mysql_pct_temp_disk |
Percentage |
Created_tmp_disk_tables / Created_tmp_tables * 100 |
mysql_tmp_table_size |
Bytes |
The largest size for temporary tables in memory (not MEMORY tables) although if max_heap_table_size is smaller the lower limit will apply. |
Credits, License¶
Authors: Linuxfabrik GmbH, Zurich
License: The Unlicense, see LICENSE file.
Credits:
heavily inspired by MySQLTuner (https://github.com/major/MySQLTuner-perl)