Check mysql-traffic¶
Overview¶
Reports MySQL/MariaDB traffic statistics including uptime, queries per second, total connections, bytes transferred, and the read/write ratio based on SELECT, INSERT, UPDATE, DELETE, and REPLACE. Logic taken from MySQLTuner:mysql_stats() and verified in sync with MySQLTuner.
Important Notes:
This plugin is purely informational and always returns OK
The single-line summary shows lifetime totals (since
Uptime) for human reading. Trends are best inspected on the Grafana dashboard, which plots the per-second rates persisted in the local SQLite cache
Data Collection:
Queries
SHOW GLOBAL STATUSforBytes_received,Bytes_sent,Com_delete,Com_insert,Com_replace,Com_select,Com_update,Connections,Questions, andUptimeCalculates queries per second as
Questions / UptimeCalculates the read/write ratio from
SELECT(reads) andINSERT+UPDATE+DELETE+REPLACE(writes)Cumulative counters are persisted in a local SQLite cache between runs so the dashboard plots per-second rates without
non_negative_difference()workarounds
Fact Sheet¶
Fact |
Value |
|---|---|
Check Plugin Download |
https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/mysql-traffic |
Nagios/Icinga Check Name |
|
Check Interval Recommendation |
Every minute |
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-traffic [-h] [-V] [--defaults-file DEFAULTS_FILE]
[--defaults-group DEFAULTS_GROUP] [--timeout TIMEOUT]
Reports MySQL/MariaDB traffic statistics: uptime, queries per second, total
connections, bytes transferred, and the SELECT-vs-write ratio. Purely
informational; the plugin always returns OK. Cumulative counters
(`Bytes_received`, `Bytes_sent`, `Connections`, `Questions`, `Com_*`) are
emitted as in-plugin-computed per-second rates so the Grafana dashboard plots
them without `non_negative_difference()` workarounds.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--defaults-file DEFAULTS_FILE
MySQL/MariaDB cnf file to read user, host and password
from. Example: `--defaults-
file=/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-traffic
Output:
Up 1W 3D (907.7K q [1.0 qps], 470.0 conn, TX: 560.2M, RX: 96.4M); Read/Write: 65.3%/34.7%
States¶
Always returns OK.
Perfdata / Metrics¶
Name |
Type |
Description |
|---|---|---|
mysql_bytes_received_per_second |
Rate |
Per-second rate of |
mysql_bytes_sent_per_second |
Rate |
Per-second rate of |
mysql_com_delete_per_second |
Rate |
Per-second rate of |
mysql_com_insert_per_second |
Rate |
Per-second rate of |
mysql_com_replace_per_second |
Rate |
Per-second rate of |
mysql_com_select_per_second |
Rate |
Per-second rate of |
mysql_com_update_per_second |
Rate |
Per-second rate of |
mysql_connections_per_second |
Rate |
Per-second rate of |
mysql_pct_reads |
Percentage |
|
mysql_pct_writes |
Percentage |
|
mysql_qps |
Number |
Lifetime queries per second ( |
mysql_questions_per_second |
Rate |
Per-second rate of |
mysql_uptime |
Seconds |
|
Credits, License¶
Authors: Linuxfabrik GmbH, Zurich
License: The Unlicense, see LICENSE file.
Credits:
heavily inspired by MySQLTuner (https://github.com/major/MySQLTuner-perl)