diff options
author | Sakib Sajal <sakib.sajal@windriver.com> | 2021-07-09 16:53:44 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-07-10 22:42:22 +0100 |
commit | 7c5fd8006ff77f07052d9e44695a373a34b94e9a (patch) | |
tree | 95060853c3d0726d7d9bc5e30f89e08094a5301a /scripts | |
parent | 8ce9e8b268c3d6a8c5f22de9352656efd3e93cfb (diff) | |
download | poky-7c5fd8006ff77f07052d9e44695a373a34b94e9a.tar.gz |
oe-time-dd-test.sh: add options and refactor
Options:
-c | --count <amount> dd (transfer) <amount> KiB of data within specified timeout to detect latency.
Must enable -t option.
-t | --timeout <time> timeout in seconds for the <count> amount of data to be transferred.
-l | --log-only run the commands without performing the data transfer.
-h | --help show help
(From OE-Core rev: 302bc6c99226a4d050e4e454afc461a25e127632)
Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/oe-time-dd-test.sh | 95 |
1 files changed, 80 insertions, 15 deletions
diff --git a/scripts/oe-time-dd-test.sh b/scripts/oe-time-dd-test.sh index ccdd55e66e..df36c0b297 100755 --- a/scripts/oe-time-dd-test.sh +++ b/scripts/oe-time-dd-test.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/bash |
2 | # | 2 | # |
3 | # oe-time-dd-test records how much time it takes to | 3 | # oe-time-dd-test records how much time it takes to |
4 | # write <count> number of kilobytes to the filesystem. | 4 | # write <count> number of kilobytes to the filesystem. |
@@ -8,23 +8,25 @@ | |||
8 | # The purporse of this script is to find which part of | 8 | # The purporse of this script is to find which part of |
9 | # the build system puts stress on the filesystem io and | 9 | # the build system puts stress on the filesystem io and |
10 | # log all the processes. | 10 | # log all the processes. |
11 | |||
12 | usage() { | 11 | usage() { |
13 | echo "Usage: $0 <count>" | 12 | echo "$0 is used to detect i/o latency and runs commands to display host information." |
14 | } | 13 | echo "The following commands are run in order:" |
15 | 14 | echo "1) top -c -b -n1 -w 512" | |
16 | TIMEOUT=15 | 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" | ||
17 | 24 | ||
18 | if [ $# -ne 1 ]; then | 25 | } |
19 | usage | ||
20 | exit 1 | ||
21 | fi | ||
22 | 26 | ||
23 | uptime | 27 | run_cmds() { |
24 | timeout ${TIMEOUT} dd if=/dev/zero of=oe-time-dd-test.dat bs=1024 count=$1 conv=fsync | 28 | uptime |
25 | if [ $? -ne 0 ]; then | 29 | echo "start: top output" |
26 | echo "Timeout used: ${TIMEOUT}" | ||
27 | echo "start: top output" | ||
28 | top -c -b -n1 -w 512 | 30 | top -c -b -n1 -w 512 |
29 | echo "end: top output" | 31 | echo "end: top output" |
30 | echo "start: iostat" | 32 | echo "start: iostat" |
@@ -33,4 +35,67 @@ if [ $? -ne 0 ]; then | |||
33 | echo "start: cooker log" | 35 | echo "start: cooker log" |
34 | tail -30 tmp*/log/cooker/*/console-latest.log | 36 | tail -30 tmp*/log/cooker/*/console-latest.log |
35 | echo "end: cooker log" | 37 | echo "end: cooker log" |
38 | } | ||
39 | |||
40 | if [ $# -lt 1 ]; then | ||
41 | usage | ||
42 | exit 1 | ||
43 | fi | ||
44 | |||
45 | re_c='^[0-9]+$' | ||
46 | #re_t='^[0-9]+([.][0-9]+)?$' | ||
47 | |||
48 | while [[ $# -gt 0 ]]; do | ||
49 | key="$1" | ||
50 | |||
51 | case $key in | ||
52 | -c|--count) | ||
53 | COUNT=$2 | ||
54 | shift | ||
55 | shift | ||
56 | if ! [[ $COUNT =~ $re_c ]] || [[ $COUNT -le 0 ]] ; then | ||
57 | usage | ||
58 | exit 1 | ||
59 | fi | ||
60 | ;; | ||
61 | -t|--timeout) | ||
62 | TIMEOUT=$2 | ||
63 | shift | ||
64 | shift | ||
65 | if ! [[ $TIMEOUT =~ $re_c ]] || [[ $TIMEOUT -le 0 ]] ; then | ||
66 | usage | ||
67 | exit 1 | ||
68 | fi | ||
69 | ;; | ||
70 | -l|--log-only) | ||
71 | LOG_ONLY="true" | ||
72 | shift | ||
73 | shift | ||
74 | ;; | ||
75 | -h|--help) | ||
76 | usage | ||
77 | exit 0 | ||
78 | ;; | ||
79 | *) | ||
80 | usage | ||
81 | exit 1 | ||
82 | ;; | ||
83 | esac | ||
84 | done | ||
85 | |||
86 | |||
87 | if [ "$LOG_ONLY" = "true" ] ; then | ||
88 | run_cmds | ||
89 | exit | ||
90 | fi | ||
91 | |||
92 | if [ -z ${TIMEOUT+x} ] || [ -z ${COUNT+x} ] ; then | ||
93 | usage | ||
94 | exit 1 | ||
95 | fi | ||
96 | |||
97 | echo "Timeout used: ${TIMEOUT}" | ||
98 | timeout ${TIMEOUT} dd if=/dev/zero of=oe-time-dd-test.dat bs=1024 count=${COUNT} conv=fsync | ||
99 | if [ $? -ne 0 ]; then | ||
100 | run_cmds | ||
36 | fi | 101 | fi |