MySQL - Get a list of connections grouped by host
Topics: MySQL administration
The following SQL statement generates a list of current connections (except the query itself). To provide a connection count per hostname, it strips off the specific port numbers.
select substring_index(host, ':', 1) as hostname, count(id)
from performance_schema.processlist
where id <> connection_id()
group by hostname;