Created
February 24, 2016 15:33
-
-
Save hartfordfive/461aecd220eeb3efe79b to your computer and use it in GitHub Desktop.
Get total number of active and closing connections for a given port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !/bin/bash | |
| PORT=$1 | |
| if [ "$PORT" == "" ]; then | |
| echo "Usage: $0 [PORT]" | |
| exit 1 | |
| fi | |
| while [ true ] | |
| do | |
| clear | |
| CONNS=$(netstat -tulpna | grep :$PORT) | |
| ACTIVE=$(echo "$CONNS" | grep ESTABLISHED) | |
| CLOSING=$(echo "$CONNS" | grep FIN_WAIT) | |
| echo "Total connections:" | |
| echo "$CONNS" | wc -l | |
| echo "Total connections active:" | |
| echo "$ACTIVE" | wc -l | |
| echo "Total closing:" | |
| echo "$CLOSING" | wc -l | |
| sleep 2 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment