Created
October 19, 2018 17:19
-
-
Save fabioneves/e2242d3eafb052b4fd30516774a43704 to your computer and use it in GitHub Desktop.
Little script to test download of different locations with various statistics
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 | |
# | |
# Description: Auto test download from different locations to measure speed | |
# | |
# Colors | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[0;33m' | |
BLUE='\033[0;94m' | |
MAGENTA='\033[0;35m' | |
CYAN='\033[0;36m' | |
LMAGENTA='\033[0;95m' | |
LCYAN='\033[0;96m' | |
PLAIN='\033[0m' | |
download() { | |
local output=$(curl -m 30 -w '%{remote_ip}\t%{time_namelookup}\t%{time_starttransfer}\t%{speed_download}\t%{time_total}\n' -o /dev/null -s $1) | |
local ipaddress=$(echo $output | awk '{print $1}' | sed 's/*//') | |
local dnslookup=$(echo $output | awk '{print $2}' | sed 's/*//') | |
local ttfb=$(echo $output | awk '{print $3}' | sed 's/*//') | |
local speedtest=$(echo $output | awk '{print $4}' | sed 's/\..*//') | |
local totaltime=$(echo $output | awk '{print $5}' | sed 's/*//') | |
# convert B/s to MB/s | |
speedtest=$((speedtest / 1024)) | |
speedtest=$(bc <<< "scale=2; ${speedtest} / 1024") | |
# print result | |
local desc=$2 | |
printf "${LCYAN}%-30s${GREEN}%-20s${BLUE}%-20s${MAGENTA}%-20s${RED}%-20s${LMAGENTA}%-20s${PLAIN}\n" "${desc}" "${ipaddress}" "${dnslookup}s" "${ttfb}s" "${speedtest} MB/s" "${totaltime}s" | |
} | |
wordpress_sv() { | |
download 'https://www.minervanett.no/wp-content/uploads/2018/10/UiO_006-980x500.jpg' 'Image from minervanett.no' | |
download 'http://wp.front.no/10mb.test' '10MB file' | |
download 'http://wp.front.no/100mb.test' '100MB file' | |
} | |
new_devz() { | |
download 'https://www.hivolda.no/sites/default/files/styles/banner_media_wide/public/2018-09/20180831_kvistaddalen_ms_kyrrebuxrud_012.jpg?itok=V8fPGErB' 'Image from hivolda.devz.no' | |
download 'https://hivolda.devz.no/sites/default/files/10mb.test' '10MB file' | |
download 'https://hivolda.devz.no/sites/default/files/100mb.test' '100MB file' | |
} | |
flamingo() { | |
download 'https://www.hivolda.no/sites/default/files/styles/banner_media_wide/public/2018-09/20180831_kvistaddalen_ms_kyrrebuxrud_012.jpg?itok=jGJVvd33' 'Image from hivolda.no (PHP)' | |
download 'https://www.hivolda.no/sites/default/files/10mb.test' '10MB file' | |
download 'https://www.hivolda.no/sites/default/files/100mb.test' '100MB file' | |
} | |
clear | |
echo "WordPress server (wp.front.no)" | |
echo "------------------------------------------------------------------------------------------------------------------------" | |
printf "%-30s%-20s%-20s%-20s%-20s%-20s\n" "Description" "IPv4 address" "DNS Lookup" "TTFB" "Download Speed" "Total time" | |
wordpress_sv | |
echo "" | |
echo "New dev server (dev.frontkom.no)" | |
echo "------------------------------------------------------------------------------------------------------------------------" | |
printf "%-30s%-20s%-20s%-20s%-20s%-20s\n" "Description" "IPv4 address" "DNS Lookup" "TTFB" "Download Speed" "Total time" | |
new_devz | |
echo "" | |
echo "Flamingo Oslo Server (flamingo.front.no)" | |
echo "------------------------------------------------------------------------------------------------------------------------" | |
printf "%-30s%-20s%-20s%-20s%-20s%-20s\n" "Description" "IPv4 address" "DNS Lookup" "TTFB" "Download Speed" "Total time" | |
flamingo | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment