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