-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.info.sh
227 lines (224 loc) · 12.7 KB
/
server.info.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
sysinfo () {
# Removing existing bench.log
rm -rf $HOME/bench.log
# Reading out system information...
# Reading CPU model
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Reading amount of CPU cores
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
# Reading CPU frequency in MHz
freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Reading total memory in MB
tram=$( free -m | awk 'NR==2 {print $2}' )
# Reading Swap in MB
vram=$( free -m | awk 'NR==4 {print $2}' )
# Reading system uptime
up=$( uptime | awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; print }' | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Reading operating system and version (simple, didn't filter the strings at the end...)
opsy=$( cat /etc/issue.net | awk 'NR==1 {print}' ) # Operating System & Version
arch=$( uname -m ) # Architecture
lbit=$( getconf LONG_BIT ) # Architecture in Bit
hn=$( hostname ) # Hostname
kern=$( uname -r )
# Date of benchmark
bdates=$( date )
echo "Benchmark started on $bdates" | tee -a $HOME/bench.log
echo "Full benchmark log: $HOME/bench.log" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# Output of results
echo "System Info" | tee -a $HOME/bench.log
echo "-----------" | tee -a $HOME/bench.log
echo "Processor : $cname" | tee -a $HOME/bench.log
echo "CPU Cores : $cores" | tee -a $HOME/bench.log
echo "Frequency : $freq MHz" | tee -a $HOME/bench.log
echo "Memory : $tram MB" | tee -a $HOME/bench.log
echo "Swap : $vram MB" | tee -a $HOME/bench.log
echo "Uptime : $up" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
echo "OS : $opsy" | tee -a $HOME/bench.log
echo "Arch : $arch ($lbit Bit)" | tee -a $HOME/bench.log
echo "Kernel : $kern" | tee -a $HOME/bench.log
echo "Hostname : $hn" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
}
speedtest4 () {
ipiv=$( wget -qO- ipv4.icanhazip.com ) # Getting IPv4
# Speed test via wget for IPv4 only with 10x 100 MB files. 1 GB bandwidth will be used!
echo "Speedtest (IPv4 only)" | tee -a $HOME/bench.log
echo "---------------------" | tee -a $HOME/bench.log
echo "Your public IPv4 is $ipiv" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# Cachefly CDN speed test
echo "Location Provider Speed" | tee -a $HOME/bench.log
cachefly=$( wget -4 -O /dev/null http://cachefly.cachefly.net/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "CDN Cachefly $cachefly" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# United States speed test
coloatatl=$( wget -4 -O /dev/null http://speed.atl.coloat.com/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Atlanta, GA, US Coloat $coloatatl " | tee -a $HOME/bench.log
sldltx=$( wget -4 -O /dev/null http://speedtest.dal05.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Dallas, TX, US Softlayer $sldltx " | tee -a $HOME/bench.log
slwa=$( wget -4 -O /dev/null http://speedtest.sea01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Seattle, WA, US Softlayer $slwa " | tee -a $HOME/bench.log
slsjc=$( wget -4 -O /dev/null http://speedtest.sjc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "San Jose, CA, US Softlayer $slsjc " | tee -a $HOME/bench.log
slwdc=$( wget -4 -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Washington, DC, US Softlayer $slwdc " | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# Asia speed test
linodejp=$( wget -4 -O /dev/null http://speedtest.tokyo.linode.com/100MB-tokyo.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Tokyo, Japan Linode $linodejp " | tee -a $HOME/bench.log
slsg=$( wget -4 -O /dev/null http://speedtest.sng01.softlayer.com/downloads/test100.zip 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Singapore Softlayer $slsg " | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# Europe speed test
i3d=$( wget -4 -O /dev/null http://mirror.i3d.net/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Rotterdam, Netherlands id3.net $i3d" | tee -a $HOME/bench.log
leaseweb=$( wget -4 -O /dev/null http://mirror.leaseweb.com/speedtest/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Haarlem, Netherlands Leaseweb $leaseweb " | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
}
speedtest6 () {
ipvii=$( wget -qO- ipv6.icanhazip.com ) # Getting IPv6
# Speed test via wget for IPv6 only with 10x 100 MB files. 1 GB bandwidth will be used! No CDN - Cachefly not IPv6 ready...
echo "Speedtest (IPv6 only)" | tee -a $HOME/bench.log
echo "---------------------" | tee -a $HOME/bench.log
echo "Your public IPv6 is $ipvii" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
echo "Location Provider Speed" | tee -a $HOME/bench.log
# United States speed test
v6atl=$( wget -6 -O /dev/null http://speedtest.atlanta.linode.com/100MB-atlanta.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Atlanta, GA, US Linode $v6atl" | tee -a $HOME/bench.log
v6dal=$( wget -6 -O /dev/null http://speedtest.dallas.linode.com/100MB-dallas.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Dallas, TX, US Linode $v6dal" | tee -a $HOME/bench.log
v6new=$( wget -6 -O /dev/null http://speedtest.newark.linode.com/100MB-newark.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Newark, NJ, US Linode $v6new" | tee -a $HOME/bench.log
v6fre=$( wget -6 -O /dev/null http://speedtest.fremont.linode.com/100MB-fremont.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Fremont, CA, US Linode $v6fre" | tee -a $HOME/bench.log
v6chi=$( wget -6 -O /dev/null http://testfile.chi.steadfast.net/data.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Chicago, IL, US Steadfast $v6chi" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# Asia speed test
v6tok=$( wget -6 -O /dev/null http://speedtest.tokyo.linode.com/100MB-tokyo.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Tokyo, Japan Linode $v6tok" | tee -a $HOME/bench.log
v6sin=$( wget -6 -O /dev/null http://speedtest.singapore.linode.com/100MB-singapore.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Singapore Linode $v6sin" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
# Europe speed test
v6fra=$( wget -6 -O /dev/null http://speedtest.frankfurt.linode.com/100MB-frankfurt.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Frankfurt, Germany Linode $v6fra" | tee -a $HOME/bench.log
v6lon=$( wget -6 -O /dev/null http://speedtest.london.linode.com/100MB-london.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "London, UK Linode $v6lon" | tee -a $HOME/bench.log
v6har=$( wget -6 -O /dev/null http://mirror.nl.leaseweb.net/speedtest/100mb.bin 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )
echo "Haarlem, Netherlands Leaseweb $v6har" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
}
iotest () {
echo "Disk Speed" | tee -a $HOME/bench.log
echo "----------" | tee -a $HOME/bench.log
# Measuring disk speed with DD
io=$( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
io2=$( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
io3=$( ( dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync && rm -f test_$$ ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Calculating avg I/O (better approach with awk for non int values)
ioraw=$( echo $io | awk 'NR==1 {print $1}' )
ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )
ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )
ioall=$( awk 'BEGIN{print '$ioraw' + '$ioraw2' + '$ioraw3'}' )
ioavg=$( awk 'BEGIN{print '$ioall'/3}' )
# Output of DD result
echo "I/O (1st run) : $io" | tee -a $HOME/bench.log
echo "I/O (2nd run) : $io2" | tee -a $HOME/bench.log
echo "I/O (3rd run) : $io3" | tee -a $HOME/bench.log
echo "Average I/O : $ioavg MB/s" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
}
gbench () {
# Improved version of my code by thirthy_speed https://freevps.us/thread-16943-post-191398.html#pid191398
echo "" | tee -a $HOME/bench.log
echo "System Benchmark (Experimental)" | tee -a $HOME/bench.log
echo "-------------------------------" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
echo "Note: The benchmark might not always work (eg: missing dependencies)." | tee -a $HOME/bench.log
echo "Failures are highly possible. We're using Geekbench for this test." | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
gb_page=http://www.primatelabs.com/geekbench/download/linux/
gb_dl=$(wget -qO - $gb_page | \
sed -n 's/.*\(https\?:[^:]*\.tar\.gz\).*/\1/p')
gb_noext=${gb_dl##*/}
gb_noext=${gb_noext%.tar.gz}
gb_name=${gb_noext//-/ }
echo "File is located at $gb_dl" | tee -a $HOME/bench.log
echo "Downloading and extracting $gb_name" | tee -a $HOME/bench.log
wget -qO - "$gb_dl" | tar xzv 2>&1 >/dev/null
echo "" | tee -a $HOME/bench.log
echo "Starting $gb_name" | tee -a $HOME/bench.log
echo "The system benchmark may take a while." | tee -a $HOME/bench.log
echo "Don't close your terminal/SSH session!" | tee -a $HOME/bench.log
echo "All output is redirected into a result file." | tee -a $HOME/bench.log
echo "" >> $HOME/bench.log
echo "--- Geekbench Results ---" >> $HOME/bench.log
sleep 2
$HOME/dist/$gb_noext/geekbench_x86_32 >> $HOME/bench.log
echo "--- Geekbench Results End ---" >> $HOME/bench.log
echo "" >> $HOME/bench.log
echo "Finished. Removing Geekbench files" | tee -a $HOME/bench.log
sleep 1
rm -rf $HOME/dist/
echo "" | tee -a $HOME/bench.log
gbl=$(sed -n '/following link/,/following link/ {/following link\|^$/b; p}' $HOME/bench.log | sed 's/^[ \t]*//;s/[ \t]*$//' )
echo "Benchmark Results: $gbl" | tee -a $HOME/bench.log
echo "Full report available at $HOME/bench.log" | tee -a $HOME/bench.log
echo "" | tee -a $HOME/bench.log
}
hlp () {
echo ""
echo "(C) Bench.sh 2 by Hidden Refuge <me at hiddenrefuge got eu dot org>"
echo ""
echo "Usage: bench.sh <option>"
echo ""
echo "Available options:"
echo "No option : System information, IPv4 only speedtest and disk speed & IOPing benchmark will be run."
echo "-sys : Displays system information such as CPU, amount CPU cores, RAM and more."
echo "-io : Runs a disk speed test and a IOPing benchmark and displays the results."
echo "-iops : Runs a extended IOPing test for latency, reading and et cetera."
echo "-6 : Normal benchmark but with a IPv6 only speedtest (run when you have IPv6)."
echo "-46 : Normal benchmark with IPv4 and IPv6 speedtest."
echo "-64 : Same as above."
echo "-b : Normal benchmark with IPv4 only speedtest, I/O test and Geekbench system benchmark."
echo "-b6 : Normal benchmark with IPv6 only speedtest, I/O test and Geekbench system benchmark."
echo "-b46 : Normal benchmark with IPv4 and IPv6 speedtest, I/O test and Geekbench system benchmark."
echo "-b64 : Same as above."
echo "-h : This help page."
echo ""
echo "The Geekbench system benchmark is experimental. So beware of failure!"
echo ""
}
case $1 in
'-sys')
sysinfo;;
'-io')
iotest;;
'-6' )
sysinfo; speedtest6; iotest;;
'-46' )
sysinfo; speedtest4; speedtest6; iotest;;
'-64' )
sysinfo; speedtest4; speedtest6; iotest;;
'-b' )
sysinfo; speedtest4; iotest; gbench;;
'-b6' )
sysinfo; speedtest6; iotest; gbench;;
'-b46' )
sysinfo; speedtest4; speedtest6; iotest; gbench;;
'-b64' )
sysinfo; speedtest4; speedtest6; iotest; gbench;;
'-h' )
hlp;;
*)
sysinfo; speedtest4; iotest;;
esac