I'm doing some comet benchmarks and would like to see how many open connections I have.
Actually I use netstat:
netstat -ant | grep 8080 | grep EST | wc -l
But it needs around 4-6 minutes to list the number, is there any tool that can do show it in real time? The number of open connections is between 100'000 - 250'000.
Don't know if
lsof
is better, but give this a try:If you just need to see connecton statistics, try
ss
utility fromiproute
suite:You also can view detailed information on all established connections like this:
…or ssh connections only:
Some numbers section at the bottom of this page may also interest you.
Another option would be to read
/proc/net/tcp
directly. To see all established TCP connections on, 8080, you would do something likeIf you want to do it in a single process (less IO overhead) and handle corner cases, the following tells you how many ESTABLISHED TCP connections have local port 8080:
If the software on your machine listening on 8080 has IPv6 support, you'll need to read
/proc/net/tcp6
also; if the program's using IPv6 sockets, connections will show up there even if they're using IPv4.more easy is
It will display number of TCP connection on system...