forked from jinqiangwang/fio-baseline
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions
More file actions
199 lines (176 loc) · 8.15 KB
/
functions
File metadata and controls
199 lines (176 loc) · 8.15 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
#!/bin/bash
#=======================================================#
# !!!Do Not Modify Codes Below!!!
#=======================================================#
function collect_test_config(){
local output_file=$1
local disks=($2)
local comp_ratio=$3
local runtime=$4
local ramp_time=$5
local skip_check=$6
local cpus_allowed_list=($7)
echo "[Config] disks=(${disks[@]})" >> $output_file
echo "[Config] comp_ratio=$comp_ratio" >> $output_file
echo "[Config] runtime=$runtime" >> $output_file
echo "[Config] ramp_time=$ramp_time" >> $output_file
echo "[Config] cpus_allowed_list=(${cpus_allowed_list[@]})" >> $output_file
echo "[Config] skip_check=$skip_check" >> $output_file
}
function collect_sys_info(){
sys_info_log=$1
hostnamectl >> ${sys_info_log}
echo "" >> ${sys_info_log}
nvme list >> ${sys_info_log}
echo "" >> ${sys_info_log}
lsblk >> ${sys_info_log}
echo "" >> ${sys_info_log}
df -lh >> ${sys_info_log}
echo "" >> ${sys_info_log}
free -h >> ${sys_info_log}
echo "" >> ${sys_info_log}
lscpu >> ${sys_info_log}
echo "" >> ${sys_info_log}
dmidecode >> ${sys_info_log}
echo "" >> ${sys_info_log}
}
function collect_drv_before_info()
{
disk=$1
drv_log=${drv_info}/${disk}_before.log
sfx-status /dev/$disk > $drv_log
echo "" >> $drv_log
nvme smart-log /dev/$disk >> $drv_log
echo "" >> $drv_log
sfx-nvme sfx smart-log-add /dev/$disk >> $drv_log
echo "" >> $drv_log
nvme id-ctrl /dev/$disk >> $drv_log
echo "" >> $drv_log
ctlid=$(echo $disk | grep -oP 'e\K\d+(?=n)')
address=$(cat /sys/class/nvme/nvme$ctlid/address)
lspci -s $address -vvv >> $drv_log
echo "" >> $drv_log
}
function collect_drv_after_info()
{
disk=$1
drv_log=${drv_info}/${disk}_after.log
sfx-status /dev/$disk > $drv_log
echo "" >> $drv_log
nvme smart-log /dev/$disk >> $drv_log
echo "" >> $drv_log
sfx-nvme sfx smart-log-add /dev/$disk >> $drv_log
echo "" >> $drv_log
nvme id-ctrl /dev/$disk >> $drv_log
echo "" >> $drv_log
ctlid=$(echo $disk | grep -oP 'e\K\d+(?=n)')
address=$(cat /sys/class/nvme/nvme$ctlid/address)
lspci -s $address -vvv >> $drv_log
echo "" >> $drv_log
}
function collect_fio_result()
{
local result_file=$1
local output_file=$2
local disk=$3
local comp=$4
local is_precondition=$5
if [ ! -s $output_file ];then
echo "Disk,Compress_Percentage,IO,BS,QD,Jobs,KIOPS,BandWidth,Unit,Latency,Unit,99% Latency,Unit,99.99% Latency,Unit" >> $output_file
fi
pattern=$(sed -n '1p' $result_file | grep -oP 'rw=\K[^,)]+')
bs=$(sed -n '1p' $result_file | grep -oP '(?<=\(T\) ).*?(?=-)')
qd=$(sed -n '1p' $result_file | grep -oP '(?<=iodepth=).*')
numjobs=$(cat $result_file | grep -oP 'Starting \K\d+(?= process)')
if [[ "$pattern" != "randrw" && "$pattern" != "rw" ]]; then
# read/write/randwrite/randread
iops_line_text=$(cat $result_file | grep -E 'write:|read:')
iops_line_num=$(cat $result_file | grep -En 'write:|read:' | cut -d: -f1)
lat_line_num=$((iops_line_num + 3))
lat_line_text=$(sed -n "${lat_line_num}p" $result_file)
iops=$(echo $iops_line_text | grep -oP 'IOPS=\K[\d\.]+(?=k)')
bw=$(echo $iops_line_text | sed -n 's/[^(]*(\([0-9.]\+\)\([^)]*\)).*/\1/p')
bw_unit=$(echo $iops_line_text | sed -n 's/[^(]*([0-9.]\+\([^)]*\)).*/\1/p')
unit=$(echo $lat_line_text | grep -oP 'lat \(\K[^)]+')
lat=$(echo $lat_line_text | grep -oP '(?<=avg=)\d+(?:\.\d+)?(?=,)')
qos_lat_line_num=$((iops_line_num + 8))
qos_lat_line_text=$(sed -n "${qos_lat_line_num}p" $result_file)
qos_99=$(echo $qos_lat_line_text | grep -oP '99\.0000000th=\[\s*\K\d+')
qos_9999=$(echo $qos_lat_line_text | grep -oP '99\.9900000th=\[\s*\K\d+')
qos_unit_line_num=$((iops_line_num + 4))
qos_unit_line_text=$(sed -n "${qos_unit_line_num}p" $result_file)
qos_unit=$(echo $qos_unit_line_text | sed 's/.*(\(.*\)):.*/\1/')
if [[ $is_precondition == "precondition" ]];then
pattern="${is_precondition}_${pattern}"
fi
echo "$disk,$comp,$pattern,$bs,$qd,$numjobs,$iops,$bw,$bw_unit,$lat,$unit,$qos_99,$qos_unit,$qos_9999,$qos_unit" >> $output_file
else
# rw/randrw
iops_line_text=$(cat $result_file | grep -E 'read:')
iops_line_num=$(cat $result_file | grep -En 'read:' | cut -d: -f1)
lat_line_num=$((iops_line_num + 3))
lat_line_text=$(sed -n "${lat_line_num}p" $result_file)
iops=$(echo $iops_line_text | grep -oP 'IOPS=\K[\d\.]+(?=k)')
bw=$(echo $iops_line_text | sed -n 's/[^(]*(\([0-9.]\+\)\([^)]*\)).*/\1/p')
bw_unit=$(echo $iops_line_text | sed -n 's/[^(]*([0-9.]\+\([^)]*\)).*/\1/p')
unit=$(echo $lat_line_text | grep -oP 'lat \(\K[^)]+')
lat=$(echo $lat_line_text | grep -oP '(?<=avg=)\d+(?:\.\d+)?(?=,)')
qos_lat_line_num=$((iops_line_num + 8))
qos_lat_line_text=$(sed -n "${qos_lat_line_num}p" $result_file)
qos_99=$(echo $qos_lat_line_text | grep -oP '99\.0000000th=\[\s*\K\d+')
qos_9999=$(echo $qos_lat_line_text | grep -oP '99\.9900000th=\[\s*\K\d+')
qos_unit_line_num=$((iops_line_num + 4))
qos_unit_line_text=$(sed -n "${qos_unit_line_num}p" $result_file)
qos_unit=$(echo $qos_unit_line_text | sed 's/.*(\(.*\)):.*/\1/')
echo "$disk,$comp,${pattern}_read,$bs,$qd,$numjobs,$iops,$bw,$bw_unit,$lat,$unit,$qos_99,$qos_unit,$qos_9999,$qos_unit" >> $output_file
iops_line_text=$(cat $result_file | grep -E 'write:')
iops_line_num=$(cat $result_file | grep -En 'write:' | cut -d: -f1)
lat_line_num=$((iops_line_num + 3))
lat_line_text=$(sed -n "${lat_line_num}p" $result_file)
iops=$(echo $iops_line_text | grep -oP 'IOPS=\K[\d\.]+(?=k)')
bw=$(echo $iops_line_text | sed -n 's/[^(]*(\([0-9.]\+\)\([^)]*\)).*/\1/p')
bw_unit=$(echo $iops_line_text | sed -n 's/[^(]*([0-9.]\+\([^)]*\)).*/\1/p')
unit=$(echo $lat_line_text | grep -oP 'lat \(\K[^)]+')
lat=$(echo $lat_line_text | grep -oP '(?<=avg=)\d+(?:\.\d+)?(?=,)')
qos_lat_line_num=$((iops_line_num + 8))
qos_lat_line_text=$(sed -n "${qos_lat_line_num}p" $result_file)
qos_99=$(echo $qos_lat_line_text | grep -oP '99\.0000000th=\[\s*\K\d+')
qos_9999=$(echo $qos_lat_line_text | grep -oP '99\.9900000th=\[\s*\K\d+')
qos_unit_line_num=$((iops_line_num + 4))
qos_unit_line_text=$(sed -n "${qos_unit_line_num}p" $result_file)
qos_unit=$(echo $qos_unit_line_text | sed 's/.*(\(.*\)):.*/\1/')
echo "$disk,$comp,${pattern}_write,$bs,$qd,$numjobs,$iops,$bw,$bw_unit,$lat,$unit,$qos_99,$qos_unit,$qos_9999,$qos_unit" >> $output_file
fi
}
function check_PCIe_status(){
local device="$1"
local controller
local bus_address
local lspci_output
local maxpayload_result
local lnksta_result
controller="${device%n*}"
local address=$(cat /sys/class/nvme/${controller}/address)
if [[ -z "$address" ]]; then
echo "Error: can not found pcie address at $address"
return 1
fi
lspci_output=$(lspci -s "$address" -vvv 2>/dev/null)
if [[ -z "$lspci_output" ]]; then
echo "Error: can not query pcie info for ${controller} $address"
return 1
fi
local value_error=0
maxpayload_result=$(grep "MaxReadReq" <<< "$lspci_output")
if ! grep -q "MaxPayload 512 bytes" <<< "$maxpayload_result"; then
echo "Warning: ${device}(${address}), maxPayload is not 512 bytes, may drop performance. Current: $(grep "MaxPayload" <<< "$maxpayload_result" | sed -e 's/^[[:space:]]*//')"
value_error=$((value_error+1))
fi
lnksta_result=$(grep "LnkSta:" <<< "$lspci_output" | head -1)
if ! grep -q "Speed 32GT/s, Width x4" <<< "$lnksta_result"; then
lnksta_result=$(echo "$lnksta_result" | sed -E 's/^[[:space:]]*//; s/, [^,]*$//; s/, *$//')
echo "Warning: ${device}(${address}), PCIe speed or width is not expected, Speed 32GT/s and Width x4 are expected, but actually $lnksta_result"
value_error=$((value_error+1))
fi
return $value_error
}