-
Notifications
You must be signed in to change notification settings - Fork 0
/
internet-diagnostics.sh
115 lines (86 loc) · 3.28 KB
/
internet-diagnostics.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env bash
# Colors
RESET="\033[0m"
BOLD="\033[1m"
BRAND="${BOLD}\033[94m"
SUCCESS="\033[92m"
INFO="\033[94m"
WARNING="\033[93m"
DANGER="\033[91m"
# Date & Time
dateTime=$(date +%Y-%m-%d_%H.%M.%S)
# Directory
directory="/var/tmp"
# File
file="${directory}/Internet Diagnostics_${dateTime}"
count=1
pingCount=100
# Header
header() {
echo -e "\n${BRAND} $@ ${RESET}\n"
}
# Chapter
chapter() {
echo -e "\n${BRAND} $((count)). $@ ${RESET}\n"
echo -e "\n $((count++)). $@ \n" >> "$file"
}
chapterTxt() {
echo -e "\n${BRAND} $((count++)). $@ ${RESET}\n" >> "${file}"
}
# Body
body() {
echo -e "${BRAND} $@ ${RESET}"
}
echo ""
header " "
header " Internet Diagnostics "
header " "
header " We are about to diagnose your internet! "
header " 🌎 🌍 🌏 "
header " "
body "Internet Diagnostics detects common problems with your internet connection. It"
body "can also monitor your internet connection for intermittent connectivity "
body "failures. "
body " "
body "Upon completing this assistant, a diagnostics report will be created in "
body "/var/tmp."
body " "
body "Internet Diagnostics may temporarily change your network settings when running"
body "diagnostics tests. "
body " "
body "Internet Diagnostics is running diagnostics tests. This may take several "
body "minutes to complete. "
body " "
echo ""
echo -ne " Optionally, enter any additional information about your wireless network"
echo -e " below."
echo -e " For example; wireless router is located in the upstairs bedroom clostet."
echo -ne " ${BOLD}"
read info
echo -ne "${RESET}"
echo "${info}" >> "${file}"
chapter "Router Test"
routerIp=$(netstat -nr | awk '$1 == "default" {print $2; exit}')
ping -a -c "${pingCount}" "${routerIp}" >> "${file}"
chapter "External Test"
externalIp=$(dig +short apple.com | awk '{print $1; exit}')
ping -a -c "${pingCount}" "${externalIp}" >> "${file}"
chapter "ISP Test"
echo -ne " Who is your ISP? ${BOLD}"
read isp
echo -ne "${RESET}"
ispIp=$(awk -v isp="${isp}" '$1 == isp {print $2}' isps)
if [ -z "${ispIp}" ]
then
echo -ne " What is ${isp}'s test IP address? ${BOLD}"
read ispIp
echo -ne "${RESET}"
echo "${isp} ${ispIp}" >> "${file}"
fi
ping -a -c "{$pingCount}" "{$ispIp}" >> "{$file}"
chapter "Route to Router Test"
ifconfig -a >> "${file}"
chapter "Route to External Test"
traceroute "${externalIp}" >> "${file}"
chapter "NetStat"
netstat -a >> "${file}"