]> git.proxmox.com Git - mirror_zfs-debian.git/blame - scripts/zpios-profile/zpios-profile-disk.sh
Add FAILFAST support
[mirror_zfs-debian.git] / scripts / zpios-profile / zpios-profile-disk.sh
CommitLineData
302ef151
BB
1#!/bin/bash
2#
3# /proc/diskinfo <after skipping major/minor>
4# Field 1 -- device name
5# Field 2 -- # of reads issued
6# Field 3 -- # of reads merged
7# Field 4 -- # of sectors read
8# Field 5 -- # of milliseconds spent reading
9# Field 6 -- # of writes completed
10# Field 7 -- # of writes merged
11# Field 8 -- # of sectors written
12# Field 9 -- # of milliseconds spent writing
13# Field 10 -- # of I/Os currently in progress
14# Field 11 -- # of milliseconds spent doing I/Os
15# Field 12 -- weighted # of milliseconds spent doing I/Os
16
17PROG=zpios-profile-disk.sh
18
19RUN_PIDS=${0}
20RUN_LOG_DIR=${1}
21RUN_ID=${2}
22
23create_table() {
24 local FIELD=$1
25 local ROW_M=()
26 local ROW_N=()
27 local HEADER=1
28 local STEP=1
29
30 for DISK_FILE in `ls -r --sort=time --time=ctime ${RUN_LOG_DIR}/${RUN_ID}/disk-[0-9]*`; do
31 ROW_M=( ${ROW_N[@]} )
32 ROW_N=( `cat ${DISK_FILE} | grep sd | cut -c11- | cut -f${FIELD} -d' ' | tr "\n" "\t"` )
33
34 if [ $HEADER -eq 1 ]; then
35 echo -n "step, "
36 cat ${DISK_FILE} | grep sd | cut -c11- | cut -f1 -d' ' | tr "\n" ", "
37 echo "total"
38 HEADER=0
39 fi
40
41 if [ ${#ROW_M[@]} -eq 0 ]; then
42 continue
43 fi
44
45 if [ ${#ROW_M[@]} -ne ${#ROW_N[@]} ]; then
46 echo "Badly formatted profile data in ${DISK_FILE}"
47 break
48 fi
49
50 TOTAL=0
51 echo -n "${STEP}, "
52 for (( i=0; i<${#ROW_N[@]}; i++ )); do
53 DELTA=`echo "${ROW_N[${i}]}-${ROW_M[${i}]}" | bc`
54 let TOTAL=${TOTAL}+${DELTA}
55 echo -n "${DELTA}, "
56 done
57 echo "${TOTAL}, "
58
59 let STEP=${STEP}+1
60 done
61}
62
63create_table_mbs() {
64 local FIELD=$1
65 local TIME=$2
66 local ROW_M=()
67 local ROW_N=()
68 local HEADER=1
69 local STEP=1
70
71 for DISK_FILE in `ls -r --sort=time --time=ctime ${RUN_LOG_DIR}/${RUN_ID}/disk-[0-9]*`; do
72 ROW_M=( ${ROW_N[@]} )
73 ROW_N=( `cat ${DISK_FILE} | grep sd | cut -c11- | cut -f${FIELD} -d' ' | tr "\n" "\t"` )
74
75 if [ $HEADER -eq 1 ]; then
76 echo -n "step, "
77 cat ${DISK_FILE} | grep sd | cut -c11- | cut -f1 -d' ' | tr "\n" ", "
78 echo "total"
79 HEADER=0
80 fi
81
82 if [ ${#ROW_M[@]} -eq 0 ]; then
83 continue
84 fi
85
86 if [ ${#ROW_M[@]} -ne ${#ROW_N[@]} ]; then
87 echo "Badly formatted profile data in ${DISK_FILE}"
88 break
89 fi
90
91 TOTAL=0
92 echo -n "${STEP}, "
93 for (( i=0; i<${#ROW_N[@]}; i++ )); do
94 DELTA=`echo "${ROW_N[${i}]}-${ROW_M[${i}]}" | bc`
95 MBS=`echo "scale=2; ((${DELTA}*512)/${TIME})/(1024*1024)" | bc`
96 TOTAL=`echo "scale=2; ${TOTAL}+${MBS}" | bc`
97 echo -n "${MBS}, "
98 done
99 echo "${TOTAL}, "
100
101 let STEP=${STEP}+1
102 done
103}
104
105echo
106echo "Reads issued per device"
107create_table 2
108echo
109echo "Reads merged per device"
110create_table 3
111echo
112echo "Sectors read per device"
113create_table 4
114echo "MB/s per device"
115create_table_mbs 4 3
116
117echo
118echo "Writes issued per device"
119create_table 6
120echo
121echo "Writes merged per device"
122create_table 7
123echo
124echo "Sectors written per device"
125create_table 8
126echo "MB/s per device"
127create_table_mbs 8 3
128
129exit 0