Skip to content

Instantly share code, notes, and snippets.

@maxguru
Last active April 22, 2019 01:35
Show Gist options
  • Save maxguru/8b219146722623ff233c421328465bd1 to your computer and use it in GitHub Desktop.
Save maxguru/8b219146722623ff233c421328465bd1 to your computer and use it in GitHub Desktop.
Script for testing latency to VPS providers listed in vps.txt file
#!/bin/bash
while true; do
echo > pingresults.txt
date
cat vps.txt | while read LINE
do
IP=`echo $LINE | cut -d '#' -f 1`
DC=`echo $LINE | cut -d '#' -f 2`
echo "Pinging $IP..."
#PING=`ping -c 4 -i 0 "$IP" | tail -1 | awk '{print $4}' | cut -d '/' -f 2`
PING=`hping3 -c 1 -S -p 80 "$IP" 2>/dev/null | tail -1 | awk -F'rtt=' '{print $2}'`
echo "$PING , $DC , $IP" >> pingresults.txt
done
cat pingresults.txt | sort -t, -nk1
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment