Is there a tool/command to show connections per sec?

I've tried a few iptraf and iftop but I can't see anything about connection rates.

  • hopefully there's a tool for doing this. The only thing I found so far is: you run netstat -stc ... this will run netstat once a second, but you're still left with compiling the data and performing the rate calculations yourself. – Michael Martinez Apr 1 '14 at 21:27
  • Define connection? Are you talking about a new TCP session(count completed 3 way handshakes). Are about an individual http requests (pipelining and such means that multiple http request can be in a single TCP connection. Are you talking about some non-TCP protocol? Are you talking about some kind of established session that has been succesfully authenticated? Your tags mentions IP, but IP is connectionless, so simply polling the interfaces counters could be what you are asking for? – Zoredache Apr 1 '14 at 23:51
  • 1
    @Zoredache - yes. It's not http but a private protocol. changed tag to tcp – hookenz Apr 1 '14 at 23:52

I believe you can use /proc/net/ to view the number of connections at that instant. Check this every second.

# cat /proc/net/sockstat
sockets: used 124
TCP: inuse 23 orphan 0 tw 20 alloc 28 mem 10
UDP: inuse 6 mem 0
RAW: inuse 5
FRAG: inuse 0 memory 0

And to count the number of TCP connections at this moment, do:

# wc -l /proc/net/tcp
28 /proc/net/tcp
  • you can use ss -s to get this info nicely formatted – LinuxDevOps Apr 2 '14 at 0:22
  • But that's not what I'm wanting. I'm wanting a rate of connections/s. Looks like I might have to write such a tool – hookenz Apr 2 '14 at 0:23
  • /proc/net/ is probably the best information available. Not sure you can get more reliable then the kernel. – Stefan Lasiewski Apr 3 '14 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.