0

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.

hookenz
  • 14,472
  • 23
  • 88
  • 143
  • 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 01 '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 01 '14 at 23:51
  • 1
    @Zoredache - yes. It's not http but a private protocol. changed tag to tcp – hookenz Apr 01 '14 at 23:52

1 Answers1

0

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
Stefan Lasiewski
  • 23,667
  • 41
  • 132
  • 186