Check mysql-connections
Overview
Checks the connection usage rate, the rate of aborted connections and if name resolution is active for new connections on MySQL/MariaDB. Logic is taken from MySQLTuner script:mysql_stats(), v1.9.8.
Hints:
Fact Sheet
Check Plugin Download |
https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/mysql-connections |
Check Interval Recommendation |
Once a minute |
Can be called without parameters |
Yes |
Compiled for |
Linux, Windows |
Requirements |
User with no privileges, locked down to |
3rd Party Python modules |
|
Help
usage: mysql-connections [-h] [-V] [--always-ok]
[--defaults-file DEFAULTS_FILE]
[--defaults-group DEFAULTS_GROUP]
[--ignore-name-resolution] [--timeout TIMEOUT]
Checks the connection usage rate, the rate of aborted connections and if name
resolution is active for new connections 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.
--defaults-file DEFAULTS_FILE
Specifies a cnf file to read parameters like user,
host and password from (instead of specifying them on
the command line), for 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
--ignore-name-resolution
Do not check if name resolution is active. Default:
False
--timeout TIMEOUT Network timeout in seconds. Default: 3 (seconds)
Usage Examples
./mysql-connections --defaults-file=/var/spool/icinga2/.my.cnf
Output:
0.0% aborted connections (0.0/3.1K); current 90% used (136/151, 5 threads running) [WARNING]; peak 93% used (140/151) at 2023-10-06 10:08:47; ; interactive_timeout = 1h, wait_timeout = 1; Name resolution is active [WARNING]
Recommendations:
* Reduce or eliminate unclosed connections and network issues.
* Reduce or eliminate persistent connections to reduce connection usage (set connections > 10, wait_timeout < 28800 and/or interactive_timeout < 28800).
* A reverse name resolution is made for each new connection and can reduce performance. Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=ON.
States
WARN if the number of connections is more than 85% of the maximum possible number of simultaneous client connections (setting
max_connections
).WARN if the number of aborted connections is more than 3% of all client connections.
WARN if name resolution is active (if –ignore-name-resolution is ommitted).
Perfdata / Metrics
Name |
Type |
Description |
---|---|---|
mysql_aborted_connects |
Continous Counter |
Value of the MySQL |
mysql_connections |
Continous Counter |
Value of the MySQL |
mysql_interactive_timeout |
Seconds |
Value of the MySQL |
mysql_max_connections |
Number |
Value of the MySQL |
mysql_max_used_connections |
Number |
Value of the MySQL |
mysql_pct_connections_aborted |
Percentage |
Aborted_connects / Connections * 100 |
mysql_pct_connections_used |
Percentage |
Threads_connected / max_connections * 100 |
mysql_threads_connected |
None |
Value of the MySQL |
mysql_threads_running |
None |
Value of the MySQL |
mysql_wait_timeout |
Seconds |
Value of the MySQL |
Credits, License
Authors: Linuxfabrik GmbH, Zurich
License: The Unlicense, see LICENSE file.
Credits:
heavily inspired by MySQLTuner (https://github.com/major/MySQLTuner-perl)