我們通常情況下要統(tǒng)計(jì)數(shù)據(jù)庫(kù)的連接數(shù)指的是統(tǒng)計(jì)總數(shù),沒(méi)有細(xì)分到每個(gè)IP上。現(xiàn)在要監(jiān)控每個(gè)IP的連接數(shù),實(shí)現(xiàn)方式如下:
方法一:
復(fù)制代碼代碼如下:
select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
方法二:
復(fù)制代碼代碼如下:
mysql -u root -h127.0.0.1 -e "show processlist/G;"| egrep "Host/:" | awk -F: '{ print $2 }'| sort | uniq -c
方法三:
復(fù)制代碼代碼如下:
mysql -u root -h127.0.0.1 --skip-column-names -e "show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq –c
以上就是三種監(jiān)控IP連接數(shù)的實(shí)現(xiàn)方式,希望對(duì)大家的學(xué)習(xí)有所幫助。