Skip to content

Instantly share code, notes, and snippets.

@todiadiyatmo
Created October 25, 2015 00:49
Show Gist options
  • Save todiadiyatmo/186e638c60b2e55d6345 to your computer and use it in GitHub Desktop.
Save todiadiyatmo/186e638c60b2e55d6345 to your computer and use it in GitHub Desktop.
speedbench
#!/bin/bash
#
# speedbench.sh v2.0 - extended VPS benchmark script
# based on freevps.us benchmark script (http://freevps.us/bench.sh)
# and speedtest-cli (https://github.com/sivel/speedtest-cli)
# credits goes to bench.sh and speedtest-cli respective author
#
depschk=1
if ! which python &>/dev/null;
then
echo
echo " > speedbench.sh requires python to run. Please install it first!"
echo " > apt-get install python or yum install python"
echo
depschk=0
fi
if [[ "$depschk" == "0" ]];
then
exit 1
else
wget -q -O speedtest-cli --no-check-certificate https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli
echo
echo "-- System information:"
echo
cname=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | xargs)
cores=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)
freq=$(awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | xargs)
tram=$(free -mto | grep Mem: | awk '{ print $2 " Mb" }')
swap=$(free -mto | grep Swap: | awk '{ print $2 " Mb" }')
ipv4=$(ifconfig | grep 'inet addr:'| grep -v '127.0.0' | wc -l)
ipv6=$(ifconfig | grep 'inet6 addr:'| grep -v '::1/128' | wc -l)
disksize=$(df -h | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $2 }')
uptime=$(uptime|awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }'| xargs)
echo "CPU model : $cname"
echo "Number of cores : $cores"
echo "CPU frequency : $freq MHz"
echo "Total amount of ram : $tram"
echo "Total amount of swap : $swap"
echo "Total storage space : $disksize"
echo "Usable IP addresses : $ipv4 IPv4 / $ipv6 IPv6"
echo "System uptime : $uptime"
echo "Disk I/O speed : $( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' )"
echo
echo "-- Testing network speed to the closest speed test server"
echo
closest=$(python speedtest-cli --byte)
srvclosest=$(echo "$closest" | grep Hosted | cut -d'[' -f1 | xargs)
dclosest=$(echo "$closest" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
uclosest=$(echo "$closest" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$srvclosest"
echo "D: "$dclosest" MB/s | U: "$uclosest" MB/s"
echo
echo "-- Testing network speed to other regions"
echo
test1=$(python speedtest-cli --server=1945 --bytes)
s1=$(echo "$test1" | grep Hosted | cut -d'[' -f1 | xargs)
d1=$(echo "$test1" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u1=$(echo "$test1" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s1"
echo "D: "$d1" MB/s | U: "$u1" MB/s"
echo
test2=$(python speedtest-cli --server=4041 --bytes)
s2=$(echo "$test2" | grep Hosted | cut -d'[' -f1 | xargs)
d2=$(echo "$test2" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u2=$(echo "$test2" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s2"
echo "D: "$d2" MB/s | U: "$u2" MB/s"
echo
test3=$(python speedtest-cli --server=4042 --bytes)
s3=$(echo "$test3" | grep Hosted | cut -d'[' -f1 | xargs)
d3=$(echo "$test3" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u3=$(echo "$test3" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s3"
echo "D: "$d3" MB/s | U: "$u3" MB/s"
echo
test4=$(python speedtest-cli --server=3587 --bytes)
s4=$(echo "$test4" | grep Hosted | cut -d'[' -f1 | xargs)
d4=$(echo "$test4" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u4=$(echo "$test4" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s4"
echo "D: "$d4" MB/s | U: "$u4" MB/s"
echo
test5=$(python speedtest-cli --server=367 --bytes)
s5=$(echo "$test5" | grep Hosted | cut -d'[' -f1 | xargs)
d5=$(echo "$test5" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u5=$(echo "$test5" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s5"
echo "D: "$d5" MB/s | U: "$u5" MB/s"
echo
test6=$(python speedtest-cli --server=6449 --bytes)
s6=$(echo "$test6" | grep Hosted | cut -d'[' -f1 | xargs)
d6=$(echo "$test6" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u6=$(echo "$test6" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s6"
echo "D: "$d6" MB/s | U: "$u6" MB/s"
echo
test7=$(python speedtest-cli --server=4153 --bytes)
s7=$(echo "$test7" | grep Hosted | cut -d'[' -f1 | xargs)
d7=$(echo "$test7" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u7=$(echo "$test7" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s7"
echo "D: "$d7" MB/s | U: "$u7" MB/s"
echo
test7=$(python speedtest-cli --server=1783 --bytes)
s7=$(echo "$test7" | grep Hosted | cut -d'[' -f1 | xargs)
d7=$(echo "$test7" | grep -n Download | cut -d':' -f3 | cut -c2-6 | xargs)
u7=$(echo "$test7" | grep -n Upload | cut -d':' -f3 | cut -c2-6 | xargs)
echo "$s7"
echo "D: "$d7" MB/s | U: "$u7" MB/s"
echo
rm -f speedtest-cli
fi
# eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment