Using Percona Toolkit’s pt‑stalk for MySQL Monitoring and Diagnostics
This article introduces the Percona Toolkit utility pt‑stalk, explains its OS‑level and MySQL‑level monitoring capabilities, details configuration parameters and usage scenarios, shows example command lines, describes the generated diagnostic output, and briefly covers the companion pt‑sift tool for analysis.
The author shares a practical guide to the Percona Toolkit tool pt‑stalk , which collects OS and MySQL diagnostic information when specified trigger conditions are met.
Overview : After a previous article on MySQL row‑lock timeout monitoring, the author discovered that pt‑stalk can monitor those locks and many other metrics.
Introduction : pt‑stalk is part of the Percona Toolkit suite, alongside familiar tools such as pt‑query‑digest and pt‑online‑schema‑change . It is a shell script that gathers CPU, I/O, memory, disk, network data at the OS level and row‑lock wait, session, replication, and status variables at the MySQL level.
Key Features : OS metrics: CPU, I/O, memory, disk, network. MySQL metrics: row‑lock wait, session connections, replication status, various status variables.
Usage : The tool runs as a background service monitoring MySQL and triggers data collection based on configurable parameters:
function – default status (monitors SHOW GLOBAL STATUS ) or processlist (monitors SHOW PROCESSLIST ).
variable – default Threads_running ; can be set to any status variable such as Threads_connected .
threshold – default 25; the metric must exceed this value to trigger.
cycles – default 5; the condition must be observed consecutively this many times.
Connection parameters: host , port , user , password , socket .
Other options: iterations , run‑time , sleep , interval , dest , retention‑time , daemonize , log , collect (including collect‑gdb , collect‑strace , collect‑tcpdump ).
Example command :
pt‑stalk --function status --variable Threads_connected --threshold 2500 --daemonize --user=root --password=######
Scenarios : Monitor Threads_connected and trigger when it exceeds 1000 for five consecutive checks. Monitor Threads_running with a threshold of 500. Run a one‑off collection for 60 seconds without any trigger, useful for quick problem capture.
Monitoring Output : pt‑stalk creates many files named after the commands that generated them, including lock‑waits and transactions which are valuable for diagnosing row‑lock issues.
pt‑sift : The companion tool pt‑sift can summarize the data collected by pt‑stalk , providing a concise report of the most relevant diagnostics.
Conclusion : pt‑stalk is a lightweight, trigger‑based monitoring solution ideal for environments without a full‑blown monitoring system, especially for temporary MySQL troubleshooting. Its main limitations are that it works best on local MySQL instances and supports only a single trigger condition at a time.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.