-
Notifications
You must be signed in to change notification settings - Fork 0
/
script
162 lines (156 loc) · 7.84 KB
/
script
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
#!/bin/bash
# Author: Imad Daou - www.imaddaou.com
# This script was possible by the help of:
# http://www.servermom.org/quick-test-server-performance/
# https://wiki.mikejung.biz/Benchmarking
# https://dotlayer.com/how-to-use-ncdu-ncurses-disk-usage-%e2%80%8ato-easily-obtain-disk-usage-information-in-linux/
# https://dotlayer.com/how-to-use-fio-to-measure-disk-performance-in-linux/
#
# In order to use colored titles, run dpkg-reconfigure dash and choose No to use Bash instead
#
#---------------------------------------------------------------------
# Function: PreInstallCheck
# Do some pre-install checks
#---------------------------------------------------------------------
# Check if user is root
if [ $(id -u) != "0" ]; then
echo -e "\x1B[01;31m# Error: You must be root to run this script, please run sudo -s to switch to root. \x1B[0m"
exit 1
fi
#---------------------------------------------------------------------
# Function: InstallBasics
# Install basic packages
#---------------------------------------------------------------------
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# Installing Dependencies \x1B[0m"
apt update > /dev/null 2>&1 && apt install -y fio python-pip lsb-release > /dev/null 2>&1
pip install speedtest-cli
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# Date \x1B[0m"
date
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# Hostname \x1B[0m"
hostname
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# OS Installed \x1B[0m"
lsb_release -a
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# Number CPUs/Cores\x1B[0m"
lscpu
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# Memory Installed \x1B[0m"
free -mh
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# Partition Layout \x1B[0m"
df -Thl
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# Disk Layout \x1B[0m"
lsblk
echo "--------------------------------------------------------------------"
sleep 2
echo -e "\x1B[01;92m# Net Test1 \x1B[0m"
speedtest-cli
sleep 2
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# Net Test2 \x1B[0m"
speedtest-cli
echo
sleep 2
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# Net Test3 \x1B[0m"
speedtest-cli
echo
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# dd Test \x1B[0m"
echo "I/O Latency Test"
time dd if=/dev/zero of=testfile2 bs=512 count=1000 oflag=dsync
echo
echo "I/O Throughput Test"
time dd if=/dev/zero of=testfile1 bs=64k count=16k conv=fdatasync
echo
echo "I/O Reading Test"
time dd if=testfile1 of=/dev/null bs=1G count=1
rm -f testfile* 2>&1
echo
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# I/O Latency Test with avg \x1B[0m"
io=$( ( dd if=/dev/zero of=test_$$ bs=512 count=1000 oflag=dsync ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
sleep 2
io2=$( ( dd if=/dev/zero of=test_$$ bs=512 count=1000 oflag=dsync ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
sleep 2
io3=$( ( dd if=/dev/zero of=test_$$ bs=512 count=1000 oflag=dsync ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Calculating avg I/O
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 Latency (1st run) : $io"
echo "I/O Latency (2nd run) : $io2"
echo "I/O Latency (3rd run) : $io3"
echo "Average I/O Latency : $ioavg"
echo
rm -f test* 2>&1
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# I/O Throughput Test with avg\x1B[0m"
io=$( ( dd if=/dev/zero of=tesst_$$ bs=64k count=16k conv=fdatasync ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
sleep 2
io2=$( ( dd if=/dev/zero of=tesst_$$ bs=64k count=16k conv=fdatasync ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
sleep 2
io3=$( ( dd if=/dev/zero of=tesst_$$ bs=64k count=16k conv=fdatasync ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Calculating avg I/O
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 Throughput (1st run) : $io"
echo "I/O Throughput (2nd run) : $io2"
echo "I/O Throughput (3rd run) : $io3"
echo "Average I/O Throughput : $ioavg"
echo
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# I/O Reading Test with avg\x1B[0m"
#echo "# Flushing cache"
#sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
io=$( ( dd if=tesst_$$ of=/dev/null bs=1G count=1 ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
sleep 2
io2=$( ( dd if=tesst_$$ of=/dev/null bs=1G count=1 ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
sleep 2
io3=$( ( dd if=tesst_$$ of=/dev/null bs=1G count=1 ) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' )
# Calculating avg I/O
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 Reading (1st run) : $io"
echo "I/O Reading (2nd run) : $io2"
echo "I/O Reading (3rd run) : $io3"
echo "Average I/O Reading : $ioavg"
rm -f tesst* 2>&1
echo "--------------------------------------------------------------------"
echo -e "\x1B[01;92m# FIO Random Read Performance Test \x1B[0m"
sleep 2
fio --fallocate=none --name=randread --ioengine=libaio --iodepth=16 --rw=randread --bs=4k --direct=0 --size=1G --numjobs=4 --runtime=240 --group_reporting
echo "--------------------------------------------------------------------"
rm randread*
sleep 2
echo -e "\x1B[01;92m# FIO Random Write Performance Test \x1B[0m"
fio --fallocate=none --name=randwrite --ioengine=libaio --iodepth=1 --rw=randwrite --bs=4k --direct=0 --size=1G --numjobs=2 --runtime=240 --group_reporting
echo "--------------------------------------------------------------------"
rm randwrite*
sleep 2
echo -e "\x1B[01;92m# FIO Read/Write Performance Test \x1B[0m"
fio --fallocate=none --randrepeat=1 --ioengine=libaio --direct=0 --gtod_reduce=1 --name=test --filename=random_read_write.fio --bs=4k --iodepth=64 --size=1G --readwrite=randrw --rwmixread=75 --group_reporting
rm random_read_write.fio
echo "--------------------------------------------------------------------"