查看数据库负载并记录到文件中

查看数据库负载主要是查询数,连接进程数,正在运行的进程如下:

#!/bin/bash
# screen -D -m -S check_mysql_status sh /path2script/script &
while true; do
sudo mysql --execute='show global status;' | awk '/Queries/{q=$2} /Threads_connected/{tc=$2} /Threads_running/{printf"%20s %20s %20s
", q, tc, $2}' >> output_log.txt
echo "Sleep 5 seconds"; sleep 5;
done
Queries:
The number of statements excuted by the server

Threads_connected:
The number of currently open connections.

threads_running:
The number of threads that are not sleeping.


原文地址:https://www.cnblogs.com/wlemory/p/5509538.html