实现方式有以下三种:
第一种:
mysql> select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
+--------------+----------+
| ip | count(*) |
+--------------+----------+
| 172.17.0.7 | 2 |
| 192.168.6.23 | 10 |
| localhost | 3 |
+--------------+----------+
3 rows in set (0.03 sec)
第二种:
mysql -u root -p -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c
2 172.17.0.7
10 192.168.6.23
3 localhost
第三种:
mysql -u root -p --skip-column-names -e "show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq –c
版权声明:本文为u011208304原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。