LoginSignup
13
15

More than 5 years have passed since last update.

MySQL の processlist を監視するワンライナー

Last updated at Posted at 2013-04-12
watch -n 1 mysqladmin processlist

この方法だと mysqladmin が毎秒 接続~切断 を繰り返すのでクエリログも tail -f で一緒に監視したい場合に不都合。


mysqladmin -i 1 processlist

この方法だとコンソールがクリアされないので見難い。


while :; do clear > $(tty); echo 'show processlist;'; sleep 1; done | mysql

clear でコンソールをクリアしつつパイプでつないだ mysqlshow processlist を少しずつ流しこむようにしてみた。

clear は tty に直接流しこまなくても stderr に送れば良い。

while :; do clear 1>&2; echo 'show processlist;'; sleep 1; done | mysql

クエリログを一緒に監視するなら↓のような感じで。

tail -f /var/log/mysql/query.log | grep -v 'show processlist'
13
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
15