Eclectic Media Git auto_bandwidth_test / 016f96b
Added test script f/ bandwidth test Ariana Giroux 6 months ago
1 changed file(s) with 43 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #! /bin/bash
1
2 tput setaf 3
3 echo "Checking for required modules..."
4 tput sgr0
5 if apt list --installed 2> /dev/null | grep iperf &> /dev/null; then
6 echo "Installing 'iperf' and 'jq'"
7 sudo apt-get install iperf jq -y &> /dev/null
8 if [[ "$?" != 0 ]]; then
9 echo "FAILED! NOT INSTALLED!" 2>&1
10 exit 1
11 fi
12 echo "Install complete..."
13 else
14 echo "Required modules are installed!"
15 fi
16
17
18 tput setaf 3
19 echo "Checking host server availability..."
20 tput sgr0
21 ping -c 1 eclecticmedia.space &> /dev/null
22 if [[ "$?" != 0 ]]; then
23 echo "The remote server is down! Contact the server admin!" 2>&1
24 exit 1
25 fi
26
27 tput setaf 3
28 echo "Getting host IP"
29 remote_ip=$(python -c 'import socket; x = socket.gethostbyname("eclecticmedia.space"); print(x)')
30 tput setaf 5
31 echo "$remote_ip"
32
33 tput setaf 3
34 echo "Attempting test, this may take some time."
35 iperf -c "$remote_ip" -p 8028 | grep "^\[ " > /tmp/iperf_out
36
37 echo "Test complete! Reporting test results!"
38 tput sgr0
39
40 jquery_string=$(jq -R -s -c 'split("\n")' < /tmp/iperf_out)
41 echo $jquery_string
42