Hi List,
Is there an easy way to get a count of the number of active socket connections, or even better, number of socket connections in the time_wait state? (Something lightweight... under /proc/sys/net/ipv4/? I'd like to avoid the impact of listing out all the connections a-la netstat.)
Thanks! -Jeff
J Potter wrote:
netstat -an|grep TIME_WAIT|wc ?
I need to avoid anything that lists out all the connections -- the above would take too long if there are tens of thousands of connections.
I'm hoping there's a proc entry that has a summary count of the current number of connections?
With the -n added to the option it won't resolve IPs so it shouldn't take that long, but otherwise:
cat /proc/net/sockstat sockets: used 284 TCP: inuse 16 orphan 0 tw 0 alloc 18 mem 1 UDP: inuse 12 RAW: inuse 1 FRAG: inuse 0 memory 0
I believe the tw is the time_wait count, just:
awk '/TCP:/ {print $7}' /proc/net/sockstat
-Ross
______________________________________________________________________ This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy or printout thereof.
On Wed, 16 Apr 2008, J Potter wrote:
Is there an easy way to get a count of the number of active socket connections, or even better, number of socket connections in the time_wait state? (Something lightweight... under /proc/sys/net/ipv4/? I'd like to avoid the impact of listing out all the connections a-la netstat.)
[dag@rhun ~]$ dstat -t --tcp -----time----- ----tcp-sockets---- date/time |lis act syn tim clo 18-04 12:24:19| 4 9 0 4 0 18-04 12:24:20| 4 9 0 4 0 18-04 12:24:21| 4 9 0 4 0 18-04 12:24:22| 4 9 0 4 0
Although it is using /proc/net/tcp
You can use --debug to see how much time in milliseconds dstat spends on getting that information. Of course that number is impacted by the load on the system as well.
[dag@rhun ~]$ dstat -t --tcp --debug Module dstat_time Module dstat_tcp requires ['/proc/net/tcp', '/proc/net/tcp6'] -------time------- ----tcp-sockets---- date/time |lis act syn tim clo 18-04 12:26:17.932| 4 9 0 4 0 11.76ms 18-04 12:26:18.935| 4 9 0 4 0 25.83ms 18-04 12:26:19.936| 4 9 0 4 0 14.82ms 18-04 12:26:20.937| 4 9 0 4 0 14.51ms
Kind regards,