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