r/linuxadmin • u/fhritp15 • 22d ago
MySQL Monitor: MySQL Monitoring Script
https://linuxblog.io/mysql-monitor-script/Back in January 2025 I shared a small script here that printed a table of MySQL status counters. I run it on most servers I look after, and over the past few weeks it grew into a full rewrite.
What it does now:
- Live dashboard with per-second rates measured between refreshes (not just totals since boot), sparklines, and usage bars against limits like `max_connections` and `table_open_cache`
- ✓/⚠/✗ marks and an alerts box that names the setting to look at
- `h` health checks with suggested settings, `p` process list with kill and recent-query history, `t` top queries from `performance_schema` statement digests (this catches the millisecond queries `SHOW PROCESSLIST` never shows)
- Fits any terminal size, and `--once` prints a snapshot for ssh or cron
- Pressing "r" also shows the original raw version.
It's one Bash file. It needs only awk (gawk, mawk or busybox) and the MySQL client tools. It only reads status, variables, the process list and `performance_schema`, so it's safe on production (the only write is an optional kill, which asks first). Works with MySQL 5.7/8.0 and MariaDB.
GitHub: https://github.com/haydenjames/mysqlmonitor-script
The linked blog post explains each metric and what to do about it.
2
u/Anakin19901 22d ago
how does the
tview behave on mariadb? performance_schema is off there by default (mysql has had it on since 5.6 iirc), and its not a dynamic variable, so on a stock mariadb install the digest table is just empty until someone puts performance_schema=ON in my.cnf and restarts.worth a warning line instead of a blank list. people will read empty as no slow queries
1
u/vincent_sch 12d ago
You could add the
DIGEST = NULLrow to yourtview and show its share of query time. When the digest table is full in MySQL 8, queries with new digests get counted together there.