Last active
May 30, 2022 16:13
-
-
Save sven-hash/56e1deb467b9ddb92b128a6772101cb7 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
# INSTALL wget https://gist.githubusercontent.com/sven-hash/56e1deb467b9ddb92b128a6772101cb7/raw -O /usr/local/bin/sockets && chmod +x /usr/local/bin/sockets | |
# RUN sockets <number of lines>, example sockets 15 | |
RED="\e[31m" | |
GREEN="\e[32m" | |
ENDCOLOR="\e[0m" | |
PORTS=(1080 1789 1790 8000 9000) | |
TOP=10 | |
if [ ! -z ${TOP} ];then | |
TOP=$1 | |
fi | |
for port in ${PORTS[@]};do | |
echo -e "${GREEN}Number of socket open for port $port${ENDCOLOR}" | |
ss -tan | grep $port | awk '{print $5}' | rev | cut -d: -f2- |rev | sort|uniq -c|sort -k3 | tail -${TOP} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment