Created
May 7, 2018 07:57
-
-
Save menzow/b6cf565964aa95f2b1d1fa69ee7a12ab to your computer and use it in GitHub Desktop.
Run slurp and grep time_wait sockets. Works on both linux as macos.
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
#!/bin/bash | |
function socket_count(){ | |
if [[ "$OSTYPE" == "darwin"* ]]; then | |
sysctl net.inet.tcp.tw_pcbcount | awk '{ print $2 }' | |
else | |
netstat -n | grep -i 80| grep -i time_wait | wc -l | |
fi | |
} | |
printf "Starting slurp..." && (slurp keyword -t example,example1,example2 &>/dev/null &) | |
sockets="$()" | |
while [[ "$(socket_count)" -le $sockets ]]; do | |
printf '.' | |
sleep 1 | |
done | |
echo ' done.' | |
for i in {0..5}; do (echo "time_wait sockets: $(socket_count)" && sleep 1); done | |
sockets=$(socket_count) | |
printf "Stoping slurp..." && (killall slurp) | |
while [ "$(socket_count)" -ge $sockets ]; do | |
printf '.' | |
sleep 1 | |
done | |
echo ' done.' | |
for i in {0..10}; do (echo "time_wait sockets: $(socket_count)" && sleep 1); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment