要統計數據庫的鏈接數,咱們一般狀況下是統計總數,細分到每一個ip地址:mysql
方法一:sql
select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
方法二:數據庫
mysql -u root -p 123456 -h127.0.0.1 -e "show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c