blob: 386de83dcefa817028e90b48cfffcd76770fa1c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/bin/bash
#
# oe-time-dd-test records how much time it takes to
# write <count> number of kilobytes to the filesystem.
# It also records the number of processes that are in
# running (R), uninterruptible sleep (D) and interruptible
# sleep (S) state from the output of "top" command.
# 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 "$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"
}
run_cmds() {
echo "start: top output"
top -c -b -n1 -w 512
echo "end: top output"
echo "start: iostat"
iostat -y -z -x 5 1
echo "end: iostat"
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
uptime
run_cmds
exit
fi
if [ -z ${TIMEOUT+x} ] || [ -z ${COUNT+x} ] ; then
usage
exit 1
fi
uptime
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
|