Repository navigation
Expand file tree
/
Copy pathbench
More file actions
executable file
·523 lines (477 loc) · 21.1 KB
/
Copy pathbench
File metadata and controls
executable file
·523 lines (477 loc) · 21.1 KB
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
#!/usr/bin/env bash
#
# getsysperf.com
# A simple benchmark script to test your Disk, Network and CPU performance
#
SYSPERF_VERSION="2.0.0"
# Everything below runs inside main(), which is only called on the very last line. If the
# download breaks off while the script is piped into bash ("curl ... | bash"), bash sees an
# incomplete function and runs nothing, instead of running the first half of the script.
main() {
#
#
# VALIDATION
#
#
# Check if at least Debian 10 or Ubuntu 1904 is used
if grep -qs "ubuntu" /etc/os-release; then
os="ubuntu"
os_version=$(grep 'VERSION_ID' /etc/os-release | cut -d '"' -f 2 | tr -d '.')
group_name="nogroup"
elif [[ -e /etc/debian_version ]]; then
os="debian"
os_version=$(grep -oE '[0-9]+' /etc/debian_version | head -1)
group_name="nogroup"
else
echo "Looks like you aren't running this installer on Debian or Ubuntu"
exit
fi
if [[ "$os" == "ubuntu" && "$os_version" -lt 1804 ]]; then
echo "Ubuntu 18.04 or higher is required to use this installer
This version of Ubuntu is too old and unsupported"
exit
fi
if [[ "$os" == "debian" && "$os_version" -lt 10 ]]; then
echo "Debian 10 or higher is required to use this installer
This version of Debian is too old and unsupported"
exit
fi
# Check if the required packages are installed. Root is only needed to install them.
if ! command -v wget >/dev/null || ! command -v fio >/dev/null || ! command -v curl >/dev/null || ! command -v jq >/dev/null || ! command -v ping >/dev/null || ! command -v sysbench >/dev/null; then
echo "Couldn't find [wget, fio, curl, jq, ping, sysbench]"
if [[ "$EUID" -ne 0 ]]; then
echo "Please install them first: apt install ca-certificates curl jq fio wget iputils-ping sysbench"
exit 1
fi
# Ask on the terminal: when run as "curl ... | bash", stdin is the script itself. Without
# a terminal (cron, CI) there is nobody to ask, so don't install anything unasked.
if ! { : < /dev/tty; } 2>/dev/null; then
echo "No terminal to ask for confirmation. Please install them first:"
echo "apt-get install -y ca-certificates curl jq fio wget iputils-ping sysbench"
exit 1
fi
# A failed read (Ctrl+D, closed terminal) is not a yes: only an actual Enter counts
if ! read -r -p "Install the missing packages with apt-get now? [Y/n] " install_answer < /dev/tty; then
echo
echo "No answer, not installing anything. To install them yourself:"
echo "apt-get install -y ca-certificates curl jq fio wget iputils-ping sysbench"
exit 1
fi
case "$install_answer" in
""|[Yy]|[Yy][Ee][Ss]) ;;
*)
echo "Not installing anything. To install them yourself:"
echo "apt-get install -y ca-certificates curl jq fio wget iputils-ping sysbench"
exit 1 ;;
esac
apt-get update && apt-get install -y ca-certificates curl jq fio wget iputils-ping sysbench || exit 1
fi
# The working directory goes into the current directory, so the I/O test measures that
# disk. That's only safe if no other user can rename anything on the path to it: in a
# directory that others can write to without the sticky bit (or that another user owns),
# they could swap our directory for their own and redirect root's writes, or replace the
# Geekbench binary before it runs. So every directory from / down to here must be owned
# by root or by us, and must not be group/world-writable unless it has the sticky bit.
here=$( pwd -P )
check_dir="$here"
while :; do
dir_mode=$( stat -c '%a' "$check_dir" ) || exit 1
dir_owner=$( stat -c '%u' "$check_dir" ) || exit 1
if { [ "$dir_owner" != 0 ] && [ "$dir_owner" != "$EUID" ]; } \
|| { (( 8#$dir_mode & 8#022 )) && ! (( 8#$dir_mode & 8#1000 )); }; then
printf 'Error: other users can modify %s, so it is not safe to run the benchmark in %s.\n' "$check_dir" "$here"
echo "Please run it from a directory only you (or root) can change, for example: cd ~"
exit 1
fi
[ "$check_dir" = / ] && break
check_dir=$( dirname "$check_dir" )
done
# Private working directory for the I/O test file and Geekbench, with an unpredictable
# name and mode 0700, so other local users can't pre-plant files or symlinks in it.
WORKDIR=$( mktemp -d "${here}/.sysperf.XXXXXXXX" ) || { echo "Error: cannot create a working directory in ${here}"; exit 1; }
trap 'spinner_stop; rm -rf -- "$WORKDIR"' EXIT
trap 'exit 130' INT TERM
# Progress spinner, so it's visible that a long step is still running. It is drawn on
# the terminal (/dev/tty) only, never on stdout, so "| tee log" output stays clean.
# Without a terminal (e.g. cron) it is skipped.
SPIN_PID=""
if { : > /dev/tty; } 2>/dev/null; then
exec 3> /dev/tty
SPIN_TTY=1
else
SPIN_TTY=0
fi
if [[ "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" =~ [Uu][Tt][Ff]-?8 ]]; then
SPIN_FRAMES=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
else
SPIN_FRAMES=('|' '/' '-' '\')
fi
spinner_start() {
[ "$SPIN_TTY" = 1 ] || return 0
spinner_stop
local label=$1
(
trap 'exit 0' TERM
# Short delay so the previous result line is printed (e.g. through tee) first
sleep 0.3
local i=0 start=$SECONDS
while :; do
printf '\r\033[K\033[0;36m%s\033[0m %s (%ss)' "${SPIN_FRAMES[i % ${#SPIN_FRAMES[@]}]}" "$label" "$(( SECONDS - start ))" >&3
i=$(( i + 1 ))
sleep 0.2
done
) &
SPIN_PID=$!
}
spinner_stop() {
[ -n "$SPIN_PID" ] || return 0
kill "$SPIN_PID" 2>/dev/null
wait "$SPIN_PID" 2>/dev/null
SPIN_PID=""
printf '\r\033[K' >&3
}
# Test IPv6 connectivity
ipv6=$( wget -qO- -t1 -T2 https://ipv6.icanhazip.com )
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;36m'
PLAIN='\033[0m'
#
#
# FUNCTIONS
#
#
# Strip control characters (e.g. terminal escape sequences) from untrusted text
sanitize() {
LC_ALL=C tr -cd '[:print:]'
}
get_netinfo() {
# ipinfo.io looks up the caller's own address over HTTPS, so no IP from another
# response is ever put into a URL. "org" looks like "AS3320 Deutsche Telekom AG".
local org
org=$( curl -fsS --proto '=https' --max-time 10 https://ipinfo.io/json 2>/dev/null | jq -r '.org // empty' 2>/dev/null | sanitize )
as="$org"
isp="${org#AS* }"
}
get_opsy() {
[ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
get_sys_type() {
local virt
virt=$( systemd-detect-virt 2>/dev/null )
case "$virt" in
none) sys_type="Baremetal" ;;
kvm) sys_type="KVM" ;;
lxc) sys_type="LXC" ;;
openvz) sys_type="OpenVZ" ;;
"") sys_type="Unknown" ;;
*) sys_type="$virt" ;;
esac
}
next() {
printf "%-5s\n" "-" | sed 's/\s/-/g'
}
speed_test() {
# Fetch the first 100 MB (range request, so 1 GB test files work too), at most 15s per
# host; the speed is averaged over what arrived. curl falls back from a dead IPv6
# address to IPv4 quickly (happy eyeballs).
spinner_start "Downloading from $2"
local result code bytes bps speed
result=$(curl -s -o /dev/null -r 0-104857599 --connect-timeout 5 --max-time 15 \
-w '%{http_code} %{size_download} %{speed_download}' "$1" 2>/dev/null)
spinner_stop
read -r code bytes bps <<< "$result"
if { [ "$code" = 200 ] || [ "$code" = 206 ]; } && [ "${bytes%.*}" -gt 1048576 ] 2>/dev/null; then
speed=$(awk -v b="$bps" 'BEGIN { if (b >= 1048576) printf "%.1f MB/s", b / 1048576; else printf "%.0f KB/s", b / 1024 }')
else
speed="failed"
fi
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "$2" "$speed"
}
speed_result() {
region 'Europe'
speed_test 'http://speedtest.fra1.de.leaseweb.net/100mb.bin' 'Frankfurt, Leaseweb'
speed_test 'https://nbg1-speed.hetzner.com/100MB.bin' 'Nuremberg, Hetzner'
speed_test 'http://speedtest.belwue.net/100M' 'Stuttgart, BelWue'
speed_test 'https://speedtest.init7.net/1GB.dd' 'Zurich, Init7'
speed_test 'http://speedtest.ams1.nl.leaseweb.net/100mb.bin' 'Amsterdam, Leaseweb'
speed_test 'http://speedtest.lon1.uk.leaseweb.net/100mb.bin' 'London, Leaseweb'
speed_test 'http://ping.online.net/100Mo.dat' 'Paris, Scaleway'
speed_test 'https://proof.ovh.net/files/1Gb.dat' 'Roubaix, OVH'
speed_test 'http://hel.icmp.hetzner.com/100MB.bin' 'Helsinki, Hetzner'
speed_test 'https://sto-se-ping.vultr.com/vultr.com.100MB.bin' 'Stockholm, Vultr'
speed_test 'https://waw-pl-ping.vultr.com/vultr.com.100MB.bin' 'Warsaw, Vultr'
speed_test 'https://mad-es-ping.vultr.com/vultr.com.100MB.bin' 'Madrid, Vultr'
region 'North America'
speed_test 'http://speedtest.nyc1.us.leaseweb.net/100mb.bin' 'New York, Leaseweb'
speed_test 'http://ash.icmp.hetzner.com/100MB.bin' 'Ashburn, Hetzner'
speed_test 'https://tor-ca-ping.vultr.com/vultr.com.100MB.bin' 'Toronto, Vultr'
speed_test 'https://il-us-ping.vultr.com/vultr.com.100MB.bin' 'Chicago, Vultr'
speed_test 'http://speedtest.dal13.us.leaseweb.net/100mb.bin' 'Dallas, Leaseweb'
speed_test 'http://speedtest.mia11.us.leaseweb.net/100mb.bin' 'Miami, Leaseweb'
speed_test 'https://mex-mx-ping.vultr.com/vultr.com.100MB.bin' 'Mexico City, Vultr'
speed_test 'http://speedtest.lax12.us.leaseweb.net/100mb.bin' 'Los Angeles, Leaseweb'
speed_test 'https://hil-speed.hetzner.com/100MB.bin' 'Hillsboro, Hetzner'
region 'South America'
speed_test 'https://sao-br-ping.vultr.com/vultr.com.100MB.bin' 'Sao Paulo, Vultr'
speed_test 'https://scl-cl-ping.vultr.com/vultr.com.100MB.bin' 'Santiago, Vultr'
region 'Africa'
speed_test 'https://jnb-za-ping.vultr.com/vultr.com.100MB.bin' 'Johannesburg, Vultr'
region 'Asia'
speed_test 'https://tlv-il-ping.vultr.com/vultr.com.100MB.bin' 'Tel Aviv, Vultr'
speed_test 'https://del-in-ping.vultr.com/vultr.com.100MB.bin' 'Delhi, Vultr'
speed_test 'https://bom-in-ping.vultr.com/vultr.com.100MB.bin' 'Mumbai, Vultr'
speed_test 'https://sin-speed.hetzner.com/100MB.bin' 'Singapore, Hetzner'
speed_test 'http://speedtest.hkg12.hk.leaseweb.net/100mb.bin' 'Hong Kong, Leaseweb'
speed_test 'http://speedtest.tyo11.jp.leaseweb.net/100mb.bin' 'Tokyo, Leaseweb'
speed_test 'https://sel-kor-ping.vultr.com/vultr.com.100MB.bin' 'Seoul, Vultr'
region 'Oceania'
speed_test 'http://speedtest.syd12.au.leaseweb.net/100mb.bin' 'Sydney, Leaseweb'
speed_test 'https://mel-au-ping.vultr.com/vultr.com.100MB.bin' 'Melbourne, Vultr'
region 'Global (nearest CDN node)'
speed_test 'http://cachefly.cachefly.net/100mb.test' 'CacheFly'
}
# Continent heading for the latency and speed tables
region() {
printf "${BLUE}%s${PLAIN}
" "$1"
}
ping_test() {
local nodename=$2
spinner_start "Pinging $2"
local output=$(ping -w 2 "$1" 2>/dev/null | grep rtt | cut -d'/' -f4 | awk '{ print $3 }')
# Some test hosts publish an IPv6 address that doesn't answer; retry over IPv4
[ -z "$output" ] && output=$(ping -4 -w 2 "$1" 2>/dev/null | grep rtt | cut -d'/' -f4 | awk '{ print $3 }')
spinner_stop
if [ -n "$output" ]; then output="$output ms"; else output="failed"; fi
printf "${YELLOW}%-32s${GREEN}%-24s${RED}%-14s${PLAIN}\n" "${nodename}" "${output}"
}
ping_result() {
region 'Europe'
ping_test 'speedtest.fra1.de.leaseweb.net' 'Frankfurt'
ping_test 'speedtest.lon1.uk.leaseweb.net' 'London'
region 'North America'
ping_test 'speedtest.nyc1.us.leaseweb.net' 'New York'
ping_test 'speedtest.lax12.us.leaseweb.net' 'Los Angeles'
region 'South America'
ping_test 'sao-br-ping.vultr.com' 'Sao Paulo'
ping_test 'scl-cl-ping.vultr.com' 'Santiago'
region 'Africa'
ping_test 'jnb-za-ping.vultr.com' 'Johannesburg'
region 'Asia'
ping_test 'bom-in-ping.vultr.com' 'Mumbai'
ping_test 'sin-speed.hetzner.com' 'Singapore'
ping_test 'speedtest.hkg12.hk.leaseweb.net' 'Hong Kong'
ping_test 'speedtest.tyo11.jp.leaseweb.net' 'Tokyo'
region 'Oceania'
ping_test 'speedtest.syd12.au.leaseweb.net' 'Sydney'
}
io_test() {
# Run rand read/write mixed 512kb fio test
local testfile="$WORKDIR/fio_iotest"
fio --name=rand_rw_512k --ioengine=libaio --rw=randrw --rwmixread=50 --bs=512k --iodepth=64 --numjobs=2 --size=2G --runtime=30 --gtod_reduce=1 --direct=1 --filename="$testfile" | grep "WRITE:" | awk '{print $3}' | sed 's/,//g' | sed 's/(//g' | sed 's/)//g'
rm -f -- "$testfile"
sleep 10
}
# CPU benchmark with sysbench (from the distribution's own packages). Always runs.
cpu_bench() {
local threads single multi
threads=$(nproc)
spinner_start "Running CPU benchmark (single core)"
single=$(sysbench cpu --cpu-max-prime=20000 --threads=1 --time=10 run 2>/dev/null | awk -F: '/events per second/ {gsub(/ /, "", $2); print $2}')
spinner_stop
spinner_start "Running CPU benchmark (${threads} threads)"
multi=$(sysbench cpu --cpu-max-prime=20000 --threads="$threads" --time=10 run 2>/dev/null | awk -F: '/events per second/ {gsub(/ /, "", $2); print $2}')
spinner_stop
echo "CPU benchmark (sysbench, events per second, higher is better)"
printf "Single Core : ${BLUE}%s${PLAIN}\n" "${single:-failed}"
printf "Multi Core : ${YELLOW}%s${PLAIN} (%s threads)\n" "${multi:-failed}" "$threads"
}
# Optional Geekbench 7 CPU benchmark, only downloaded and run when GEEKBENCH=7 (or 1) is set.
# It needs ~1.5 GB free disk while running (462 MB tarball + 963 MB extracted).
# Geekbench 6 is not offered: its free version shows no scores locally, only after the
# upload to the Geekbench Browser, and that upload failed in testing.
GB7_MIN_FREE_MB=1536
geekbench() {
case "${GEEKBENCH:-}" in
""|0) return 0 ;;
1|7) ;;
*)
printf "Geekbench : skipped (unknown GEEKBENCH value '%s', use GEEKBENCH=7)\n" "$GEEKBENCH"
return 0 ;;
esac
# Check if system has at least 2GB RAM in order to run Geekbench
local ram
ram=$(free -m | awk '/Mem/ {print $2}')
if [ "$ram" -lt 2048 ]; then
echo "Geekbench : skipped (${ram} MB RAM, at least 2 GB is required)"
return 0
fi
local suffix
case "$(uname -m)" in
x86_64) suffix="Linux" ;;
aarch64|arm64) suffix="LinuxARMPreview" ;;
*)
echo "Geekbench : skipped (no Geekbench build for $(uname -m))"
return 0 ;;
esac
local free_mb version="7.1.0"
free_mb=$(df -Pm "$WORKDIR" | awk 'NR==2 {print $4}')
if [ "$free_mb" -lt "$GB7_MIN_FREE_MB" ]; then
echo "Geekbench : skipped (only ${free_mb} MB free disk, Geekbench 7 needs 1.5 GB)"
return 0
fi
# SHA-256 of the official tarballs, downloaded over HTTPS from cdn.geekbench.com on 2026-11-09
local sha256
case "${version}-${suffix}" in
7.1.0-Linux) sha256="411b72a9c851b69e6f91d390649d419e2e625f475e3983880169651ca27a8672" ;;
7.1.0-LinuxARMPreview) sha256="bb6abc61a68a9b33fecf1f3c0b800050dd76e93666a13eaabfa52cbd26ad3319" ;;
esac
local major=${version%%.*}
local url="https://cdn.geekbench.com/Geekbench-${version}-${suffix}.tar.gz"
local tarball="$WORKDIR/geekbench.tar.gz"
local gbdir="$WORKDIR/geekbench"
local gbout="$WORKDIR/geekbench.out"
# TODO: disable the upload to the public Geekbench Browser (to be fixed with the next
# changes to the script). Geekbench only runs when GEEKBENCH is set, but then the free
# version always uploads: `geekbench7 --help` only lists --unlock EMAIL KEY, --cpu and
# --sysinfo, and Primate Labs requires Geekbench Pro for offline use. So it needs a
# user-supplied Pro license (--unlock). The scores are already read from the local
# output, so nothing else depends on the upload.
echo "Note: Geekbench uploads the result and basic system information to the public Geekbench Browser."
spinner_start "Downloading Geekbench ${version}"
curl -fsSL --proto '=https' --max-time 900 -o "$tarball" "$url"
local rc=$?
spinner_stop
if [ "$rc" -ne 0 ]; then
echo "Error: Geekbench download failed, skipping the CPU benchmark"
return 1
fi
if ! echo "$sha256 $tarball" | sha256sum -c --quiet - >/dev/null 2>&1; then
echo "Error: Geekbench download does not match the expected SHA-256 checksum, not running it"
rm -f -- "$tarball"
return 1
fi
mkdir -p "$gbdir"
spinner_start "Extracting Geekbench ${version}"
tar xzf "$tarball" --strip-components=1 -C "$gbdir"
rc=$?
spinner_stop
rm -f -- "$tarball"
if [ "$rc" -ne 0 ] || [ ! -x "$gbdir/geekbench${major}" ]; then
echo "Error: could not extract Geekbench, skipping the CPU benchmark"
rm -rf -- "$gbdir"
return 1
fi
spinner_start "Running Geekbench ${version} CPU benchmark, this takes a few minutes"
"$gbdir/geekbench${major}" > "$gbout" 2>/dev/null
spinner_stop
local result_url single multi
result_url=$(grep -oE 'https://browser\.geekbench\.com/v[0-9]+/cpu/[0-9]+' "$gbout" | head -1)
single=$(awk '/Single-Core Score/ {print $NF; exit}' "$gbout" | tr -cd '0-9')
multi=$(awk '/Multi-Core Score/ {print $NF; exit}' "$gbout" | tr -cd '0-9')
rm -rf -- "$gbdir" "$gbout"
if [ -z "$single" ] && [ -z "$result_url" ]; then
echo "Error: Geekbench did not report a result"
return 1
fi
echo -e "Geekbench v${version}"
echo -e "Single Core : ${BLUE}${single:-n/a}${PLAIN}"
echo -e "Multi Core : ${YELLOW}${multi:-n/a}${PLAIN}"
[ -n "$result_url" ] && echo -e "Full result : ${result_url}"
return 0
}
calc_disk() {
local total_size=0
local array=$@
for size in ${array[@]}
do
[ "${size}" == "0" ] && size_t=0 || size_t=`echo ${size:0:${#size}-1}`
[ "`echo ${size:(-1)}`" == "K" ] && size=0
[ "`echo ${size:(-1)}`" == "M" ] && size=$( awk -v s="$size_t" 'BEGIN{printf "%.1f", s / 1024}' )
[ "`echo ${size:(-1)}`" == "T" ] && size=$( awk -v s="$size_t" 'BEGIN{printf "%.1f", s * 1024}' )
[ "`echo ${size:(-1)}`" == "G" ] && size=${size_t}
total_size=$( awk -v t="$total_size" -v s="$size" 'BEGIN{printf "%.1f", t + s}' )
done
echo ${total_size}
}
cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
tram=$( free -m | awk '/Mem/ {print $2}' )
uram=$( free -m | awk '/Mem/ {print $3}' )
swap=$( free -m | awk '/Swap/ {print $2}' )
uswap=$( free -m | awk '/Swap/ {print $3}' )
up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days, %d hour %d min\n",a,b,c)}' /proc/uptime )
load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
opsy=$( get_opsy )
arch=$( uname -m )
lbit=$( getconf LONG_BIT )
kern=$( uname -r )
disk_size1=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem|udev|docker' | awk '{print $2}' ))
disk_size2=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem|udev|docker' | awk '{print $3}' ))
disk_total_size=$( calc_disk "${disk_size1[@]}" )
disk_used_size=$( calc_disk "${disk_size2[@]}" )
clear
next
echo -e "${RED}getsysperf.com${PLAIN} v${SYSPERF_VERSION} -- ${YELLOW}https://git.gillekyl.de/jay/sysperf${PLAIN}"
next
spinner_start "Collecting system information"
get_netinfo
get_sys_type
spinner_stop
printf "System type : ${BLUE}%s${PLAIN}\n" "$sys_type"
printf "CPU model : ${BLUE}%s${PLAIN}\n" "$cname"
printf "Number of cores : ${BLUE}%s${PLAIN}\n" "$cores"
printf "CPU frequency : ${BLUE}%s MHz${PLAIN}\n" "$freq"
printf "Total size of Disk : ${BLUE}%s GB (%s GB Used)${PLAIN}\n" "$disk_total_size" "$disk_used_size"
printf "Total amount of Mem : ${BLUE}%s MB (%s MB Used)${PLAIN}\n" "$tram" "$uram"
printf "Total amount of Swap : ${BLUE}%s MB (%s MB Used)${PLAIN}\n" "$swap" "$uswap"
printf "System uptime : ${BLUE}%s${PLAIN}\n" "$up"
printf "Load average : ${BLUE}%s${PLAIN}\n" "$load"
printf "OS : ${BLUE}%s${PLAIN}\n" "$opsy"
printf "Arch : ${BLUE}%s (%s Bit)${PLAIN}\n" "$arch" "$lbit"
printf "Kernel : ${BLUE}%s${PLAIN}\n" "$kern"
printf "ISP : ${BLUE}%s${PLAIN}\n" "$isp"
printf "ASN : ${BLUE}%s${PLAIN}\n" "$as"
if [[ "$ipv6" != "" ]]; then
echo -e "IPv6 Support : ${BLUE}Yes${PLAIN}"
else
echo -e "IPv6 Support : ${BLUE}No${PLAIN}"
fi
next
spinner_start "Running I/O test (1st run)"
io1=$( io_test )
spinner_stop
echo -e "I/O bandwidth (1st run) : ${YELLOW}$io1${PLAIN}"
spinner_start "Running I/O test (2nd run)"
io2=$( io_test )
spinner_stop
echo -e "I/O bandwidth (2nd run) : ${YELLOW}$io2${PLAIN}"
spinner_start "Running I/O test (3rd run)"
io3=$( io_test )
spinner_stop
echo -e "I/O bandwidth (3rd run) : ${YELLOW}$io3${PLAIN}"
rawio1=$( echo $io1 | sed 's/MB//g' | sed 's/s//g' | sed 's/.$//')
rawio2=$( echo $io2 | sed 's/MB//g' | sed 's/s//g' | sed 's/.$//')
rawio3=$( echo $io3 | sed 's/MB//g' | sed 's/s//g' | sed 's/.$//')
ioavg=$( awk -v a="$rawio1" -v b="$rawio2" -v c="$rawio3" 'BEGIN{printf "%.1f", (a + b + c) / 3}' )
echo -e "Average I/O bandwidth : ${YELLOW}$ioavg MB/s${PLAIN}"
next
printf "%-32s%-24s%-14s\n" "Location" "Latency"
ping_result
next
printf "%-32s%-24s%-14s\n" "Location" "Speed"
speed_result && next
cpu_bench
next
if [ -n "${GEEKBENCH:-}" ] && [ "$GEEKBENCH" != "0" ]; then
geekbench
next
fi
}
main "$@"