blob: 386de83dcefa817028e90b48cfffcd76770fa1c4 [file] [log] [blame]
Andrew Geissler5f350902021-07-23 13:09:54 -04001#!/bin/bash
Andrew Geissler95ac1b82021-03-31 14:34:31 -05002#
3# oe-time-dd-test records how much time it takes to
4# write <count> number of kilobytes to the filesystem.
5# It also records the number of processes that are in
6# running (R), uninterruptible sleep (D) and interruptible
7# sleep (S) state from the output of "top" command.
8# The purporse of this script is to find which part of
9# the build system puts stress on the filesystem io and
10# log all the processes.
Andrew Geissler95ac1b82021-03-31 14:34:31 -050011usage() {
Andrew Geissler5f350902021-07-23 13:09:54 -040012 echo "$0 is used to detect i/o latency and runs commands to display host information."
13 echo "The following commands are run in order:"
14 echo "1) top -c -b -n1 -w 512"
15 echo "2) iostat -y -z -x 5 1"
16 echo "3) tail -30 tmp*/log/cooker/*/console-latest.log to gather cooker log."
17 echo " "
18 echo "Options:"
19 echo "-c | --count <amount> dd (transfer) <amount> KiB of data within specified timeout to detect latency."
20 echo " Must enable -t option."
21 echo "-t | --timeout <time> timeout in seconds for the <count> amount of data to be transferred."
22 echo "-l | --log-only run the commands without performing the data transfer."
23 echo "-h | --help show help"
24
Andrew Geissler95ac1b82021-03-31 14:34:31 -050025}
26
Andrew Geissler5f350902021-07-23 13:09:54 -040027run_cmds() {
28 echo "start: top output"
Andrew Geisslerc926e172021-05-07 16:11:35 -050029 top -c -b -n1 -w 512
Andrew Geissler09036742021-06-25 14:25:14 -050030 echo "end: top output"
31 echo "start: iostat"
32 iostat -y -z -x 5 1
33 echo "end: iostat"
34 echo "start: cooker log"
Andrew Geisslerc926e172021-05-07 16:11:35 -050035 tail -30 tmp*/log/cooker/*/console-latest.log
Andrew Geissler09036742021-06-25 14:25:14 -050036 echo "end: cooker log"
Andrew Geissler5f350902021-07-23 13:09:54 -040037}
38
39if [ $# -lt 1 ]; then
40 usage
41 exit 1
42fi
43
44re_c='^[0-9]+$'
45#re_t='^[0-9]+([.][0-9]+)?$'
46
47while [[ $# -gt 0 ]]; do
48 key="$1"
49
50 case $key in
51 -c|--count)
52 COUNT=$2
53 shift
54 shift
55 if ! [[ $COUNT =~ $re_c ]] || [[ $COUNT -le 0 ]] ; then
56 usage
57 exit 1
58 fi
59 ;;
60 -t|--timeout)
61 TIMEOUT=$2
62 shift
63 shift
64 if ! [[ $TIMEOUT =~ $re_c ]] || [[ $TIMEOUT -le 0 ]] ; then
65 usage
66 exit 1
67 fi
68 ;;
69 -l|--log-only)
70 LOG_ONLY="true"
71 shift
72 shift
73 ;;
74 -h|--help)
75 usage
76 exit 0
77 ;;
78 *)
79 usage
80 exit 1
81 ;;
82 esac
83done
84
85
86if [ "$LOG_ONLY" = "true" ] ; then
87 uptime
88 run_cmds
89 exit
90fi
91
92if [ -z ${TIMEOUT+x} ] || [ -z ${COUNT+x} ] ; then
93 usage
94 exit 1
95fi
96
97uptime
98echo "Timeout used: ${TIMEOUT}"
99timeout ${TIMEOUT} dd if=/dev/zero of=oe-time-dd-test.dat bs=1024 count=${COUNT} conv=fsync
100if [ $? -ne 0 ]; then
101 run_cmds
Andrew Geisslerc926e172021-05-07 16:11:35 -0500102fi