LoginSignup
5
6

More than 5 years have passed since last update.

[MySQL] processlistをgrep

Last updated at Posted at 2014-08-26

普段よく使う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 |       |                  |
5
6
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
5
6