Edited at

[MySQL] processlistをgrep

More than 5 years have passed since last update.

普段よく使うshow processlistですが、

mysql> show processlist;

+----+------+-----------+-------------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+-------------+---------+------+-------+-----------------------+
| 1 | root | localhost | foo_dev | Sleep | 3737 | | NULL |
| 3 | root | localhost | bar_dev | Query | 0 | init | show full processlist |
+----+------+-----------+-------------+---------+------+-------+-----------------------+
2 rows in set (0.00 sec)

mysqlクライアントから出て、

 $ mysqladmin -uroot -hyyyy -pxxxx processlist

としても見ることが可能です。

 $ mysqladmin -uroot -hxxxx -pyyyy processlist

+----+------+-----------+-----------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+-----------+---------+------+-------+------------------+
| 1 | root | localhost | foo_dev | Sleep | 3770 | | |
| 6 | root | localhost | | Query | 0 | init | show processlist |
+----+------+-----------+-----------+---------+------+-------+------------------+

後は好きなようにgrepすればok。

 $ mysqladmin -uroot -hxxxx -pyyyyy processlist |grep localhost |grep -v processlist

| 1 | root | localhost | foo_dev | Sleep | 4095 | | |