Shell trick: track new tcp connections per second in Linux

This little snippet is for when you want to see new active connections per second, not concurrent established, as most tools show you:


C=0; while true; do echo "new connections: $C"; c1=`netstat -s -t|grep "active connections openings"|awk '{print $1;}'`; sleep 1; c2=`netstat -s -t|grep "active connections openings"|awk '{print $1;}'`; C=`expr $c2 - $c1` ; done

Enjoy!

Leave a Reply