Currently at Kinja we are in a middle of big architectural change
on database servers, so I have run into a problem regarding this.
Sometimes I have to check current connections on database
servers, to see what schemas are in use, what servers using a
given db server, or even which users are connected to database
server.
Previously when I had to determine connected hosts, I just used a
one-liner script in bash, what parsed through the output of
netstat and listed the number of connections from given servers
like this:
[root@sql-slave1 banyek]# netstat | grep mysql | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c
1 app01.bfc.kinja-ops.c
83 app05.bfc.kinja-ops.c
84 app09.bfc.kinja-ops.c
9 dbcacti.bfc.kinja-ops
1 nagios.bfc.kinja-ops.
1 sql-master1.bfc.kinja
This was enough to quickly see the connected hosts, but the
output wasn’t too chatty, and there are a lot of …
[Read more]