-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunctions
More file actions
174 lines (148 loc) · 5.32 KB
/
functions
File metadata and controls
174 lines (148 loc) · 5.32 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
#/bin/bash -x
function collect_sfdv_info() {
drv_name=$1
echo "`sfx-status /dev/${drv_name}`"
echo ""
echo "`sfx-nvme smart-log /dev/${drv_name}`"
echo ""
echo "`sfx-nvme sfx smart-log-add /dev/${drv_name}`"
echo ""
echo "`grep . /sys/block/${drv_name}/queue/*`"
}
function collect_nvme_info() {
drv_name=$1
echo "`nvme smart-log /dev/${drv_name}`"
echo ""
echo "`nvme intel smart-log-add /dev/${drv_name}`"
echo ""
echo "`grep . /sys/block/${drv_name}/queue/*`"
}
function collect_drv_info() {
drv_name=$1
if [[ `ls ${drv_name} 2>/dev/null` ]] || [[ `ls /dev/${drv_name} 2>/dev/null` ]]
then
if [[ `echo ${drv_name} | grep /dev/` ]]
then
drv_name=${drv_name#/dev/}
fi
if [[ "${drv_name::4}" == "sfdv" ]]
then
collect_sfdv_info ${drv_name}
fi
if [[ "${drv_name::4}" == "nvme" ]]
then
collect_nvme_info ${drv_name}
fi
fi
}
function collect_sys_info() {
echo -e "[memory]"
echo "`free -m`"
echo -e "\n[lsblk]"
echo "`lsblk`"
echo -e "\n[df]"
echo "`df -h`"
echo -e "\n[filesystem]"
echo "`mount`"
echo -e "\n[cpu]"
echo "`lscpu`"
echo "`grep MHz /proc/cpuinfo`"
echo -e "\n[sfdv_param]"
echo "`grep . /sys/module/sfxv_bd_dev/parameters/* 2>/dev/null`"
echo -e "\n[lspci]"
echo "$(for dev in `lspci | grep -i 'Non-Volatile' | cut -d' ' -f1`; do lspci -s $dev -vvv; done)"
echo -e "\n[dmidecode]"
echo "`dmidecode`"
}
function iostat_to_csv() {
data_dir=$1
if [[ ! -d ${data_dir} ]]; then return 1; fi
iostat_ver=`iostat -V | grep -i version | cut -d" " -f3 | cut -d\. -f1`
if [[ ${iostat_ver} -lt 11 ]]
then
iofields="4-9,14"
cpufields="1-2,4"
else
iofields="2-5,12-14,16"
cpufields="1-2,4"
fi
for fiostat in `ls ${data_dir}/*.iostat`
do
barename=${fiostat/*\/}; barename=${barename/.iostat}
ts=${data_dir}/${barename}.ts
io_out=${data_dir}/${barename}.io
cpu_out=${data_dir}/${barename}.cpu
echo "timestamp" > ${ts}
grep -E "[0-9]+:[0-9]+:" ${fiostat} >> ${ts}
grep -m1 Device ${fiostat} | sed -r "s/\s+/,/g" | cut -d, -f ${iofields} > ${io_out}
grep -e sfd -e nvme ${fiostat} | sed -r "s/\s+/,/g" | cut -d, -f ${iofields} >> ${io_out}
grep -m1 avg-cpu ${fiostat} | sed -r "s/\s+/,/g" | cut -d, -f ${cpufields} > ${cpu_out}
grep -A1 avg-cpu ${fiostat} | grep -v \- | sed -r "s/\s+/,/g" | cut -d, -f ${cpufields} >> ${cpu_out}
paste -d, ${ts} ${io_out} ${cpu_out} > ${data_dir}/${barename}.csv
rm -f ${ts} ${io_out} ${cpu_out}
done
}
function fio_to_csv() {
data_dir=$1
disk=$2
if [[ ! -d ${data_dir} ]]; then return 1; fi
header=0
for f in `ls -tr ${data_dir}/${disk}*.fio`
do
disk_name=${f/*\/}; disk_name=${disk_name/_*}
io_pattern=${data_dir}/${disk_name}_io_pattern.csv
bw_iops_csv=${data_dir}/${disk_name}_bw_iops.csv
lat_csv=${data_dir}/${disk_name}_lat.csv
report=${data_dir}/${disk_name}_summary.csv
if [[ ${header} -eq 0 ]]
then
header=1
echo "pattern" > ${io_pattern}
echo "I/O,KIOPS,BW (MiB/s)" > ${bw_iops_csv}
echo "lat unit,min,max,avg,stdev" > ${lat_csv}
fi
grep -e pid= ${f} | sed -r -e "s/(randrw.*):.*\(.*/\1\n/g" -e "s/(.*):.*\(.*/\1/g" >> ${io_pattern}
grep -e BW= ${f} | sed -r -e "s/\s*(.*):\s*IOPS=([0-9\.k]+),\s*BW=([0-9\.]+MiB).*/\1,\2,\3/g" >> ${bw_iops_csv}
grep -e "\slat\s.*avg=" ${f} | sed -r -e "s/\s+(lat\s.*):\smin=\s*([0-9]+),\s+max=\s*([0-9]+),\s+avg=\s*([0-9\.]+),\sstdev=\s*([0-9\.]+).*/\1,\2,\3,\4,\5/g" >> ${lat_csv}
done
paste -d, ${io_pattern} ${bw_iops_csv} ${lat_csv} > ${report}
rm -f ${io_pattern} ${bw_iops_csv} ${lat_csv}
}
function consolidate_summary() {
data_dir=$1
out_dir=$2
if [[ ! -d ${data_dir} ]]; then return 1; fi
if [[ ! -d ${out_dir} ]]; then out_dir=${data_dir}; fi
header_collcted=0
headers=${data_dir}/headers.tmp
suffix=_summary.csv
for f in `ls ${data_dir}/*${suffix} | sort -V`
do
disk_name=${f/*\/}; disk_name=${disk_name/_*}
result=${data_dir}/${disk_name}.result
if [[ ${header_collcted} -eq 0 ]]
then
header_collcted=1
header_txt=`cat $f | cut -d, -f1,2`
echo "KIOPS" > ${headers}
echo "${header_txt}" >> ${headers}
echo "" >> ${headers}
echo "BW (MiB/s)" >> ${headers}
echo "${header_txt}" >> ${headers}
fi
echo "" > ${result}
echo ${disk_name} >> ${result}
cat $f | grep -v IOPS | cut -d, -f 3 >> ${result}
echo "" >> ${result}
echo "" >> ${result}
echo ${disk_name} >> ${result}
cat $f | grep -v BW | cut -d, -f 4 >> ${result}
result_list="${result_list} ${result}"
done
paste -d, ${headers} ${result_list} > ${out_dir}/result_summary.csv
rm ${headers} ${result_list}
}
function collect_temperature() {
dev_name=$1
echo `sfx-nvme smart-log ${dev_name} | grep -e sfdv -e temperature | sed -r -e "s/.*:(sfdv[0-9]+n1).*/\1/g" -e "s/.*: ([0-9]+) C.*/\1/g"` | sed -r "s/\s+/,/g"
}