How to determine number of open sockets? VM Resource Issues

Solution 1:

netstat -nap
p shows the process id 

Solution 2:

netstat -an | grep ESTABLISHED | wc -l

This will count all opened sockets in the system and will output just the total. You can of course also change ESTABLISHED for whatever you need, for example a port or a communication status like CONNECTED or LISTENING.

Solution 3:

To watch live MySQL opened connections through UNIX socket, run (as root):

watch -n1 'netstat -np | grep -i mysqld'