summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSakib Sajal <sakib.sajal@windriver.com>2021-07-09 16:53:44 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-07-10 22:40:12 +0100
commit302bc6c99226a4d050e4e454afc461a25e127632 (patch)
tree8a115107e62074b46715b40265b4c4f3070f8051 /scripts
parent1a0fb3c0794f4e66086e567a297b4d9379c6b8f3 (diff)
downloadopenembedded-core-contrib-302bc6c99226a4d050e4e454afc461a25e127632.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 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-xscripts/oe-time-dd-test.sh95
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 @@
-#!/bin/sh
+#!/bin/bash
#
# oe-time-dd-test records how much time it takes to
# write <count> number of kilobytes to the filesystem.
@@ -8,23 +8,25 @@
# The purporse of this script is to find which part of
# the build system puts stress on the filesystem io and
# log all the processes.
-
usage() {
- echo "Usage: $0 <count>"
-}
-
-TIMEOUT=15
+ echo "$0 is used to detect i/o latency and runs commands to display host information."
+ echo "The following commands are run in order:"
+ echo "1) top -c -b -n1 -w 512"
+ echo "2) iostat -y -z -x 5 1"
+ echo "3) tail -30 tmp*/log/cooker/*/console-latest.log to gather cooker log."
+ echo " "
+ echo "Options:"
+ echo "-c | --count <amount> dd (transfer) <amount> KiB of data within specified timeout to detect latency."
+ echo " Must enable -t option."
+ echo "-t | --timeout <time> timeout in seconds for the <count> amount of data to be transferred."
+ echo "-l | --log-only run the commands without performing the data transfer."
+ echo "-h | --help show help"
-if [ $# -ne 1 ]; then
- usage
- exit 1
-fi
+}
-uptime
-timeout ${TIMEOUT} dd if=/dev/zero of=oe-time-dd-test.dat bs=1024 count=$1 conv=fsync
-if [ $? -ne 0 ]; then
- echo "Timeout used: ${TIMEOUT}"
- echo "start: top output"
+run_cmds() {
+ uptime
+ echo "start: top output"
top -c -b -n1 -w 512
echo "end: top output"
echo "start: iostat"
@@ -33,4 +35,67 @@ if [ $? -ne 0 ]; then
echo "start: cooker log"
tail -30 tmp*/log/cooker/*/console-latest.log
echo "end: cooker log"
+}
+
+if [ $# -lt 1 ]; then
+ usage
+ exit 1
+fi
+
+re_c='^[0-9]+$'
+#re_t='^[0-9]+([.][0-9]+)?$'
+
+while [[ $# -gt 0 ]]; do
+ key="$1"
+
+ case $key in
+ -c|--count)
+ COUNT=$2
+ shift
+ shift
+ if ! [[ $COUNT =~ $re_c ]] || [[ $COUNT -le 0 ]] ; then
+ usage
+ exit 1
+ fi
+ ;;
+ -t|--timeout)
+ TIMEOUT=$2
+ shift
+ shift
+ if ! [[ $TIMEOUT =~ $re_c ]] || [[ $TIMEOUT -le 0 ]] ; then
+ usage
+ exit 1
+ fi
+ ;;
+ -l|--log-only)
+ LOG_ONLY="true"
+ shift
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+
+if [ "$LOG_ONLY" = "true" ] ; then
+ run_cmds
+ exit
+fi
+
+if [ -z ${TIMEOUT+x} ] || [ -z ${COUNT+x} ] ; then
+ usage
+ exit 1
+fi
+
+echo "Timeout used: ${TIMEOUT}"
+timeout ${TIMEOUT} dd if=/dev/zero of=oe-time-dd-test.dat bs=1024 count=${COUNT} conv=fsync
+if [ $? -ne 0 ]; then
+ run_cmds
fi