-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsysstat-start
executable file
·92 lines (87 loc) · 2.6 KB
/
sysstat-start
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
#!/bin/bash
exec >sysstat-start-stderrout.txt
exec 2>&1
echo "args: $@"
echo "pwd: `/bin/pwd`"
echo "hostname: `hostname`"
# defaults
subtools="mpstat,sar,iostat,pidstat"
interval=3
longopts="subtools:,interval:"
opts=$(getopt -q -o "" --longoptions "$longopts" -n "getopt.sh" -- "$@");
if [ $? -ne 0 ]; then
printf -- "\tUnrecognized option specified\n\n"
exit 1
fi
eval set -- "$opts";
while true; do
case "$1" in
--subtools)
shift;
subtools=$1
echo "subtools=$subtools"
shift;
;;
--interval)
shift;
interval=$1
echo "interval=$interval"
shift;
;;
--)
shift;
break
;;
*)
echo "Invalid option: $1"
exit 1
esac
done
# To be used by mpstat for post-processing
if [ -e /sys/devices/system/cpu/ ]; then
find /sys/devices/system/cpu/ | grep topology | cpio -pdumv --quiet . 2>/dev/null
else
echo "WARNING: could not find /sys/devices/system/cpu/"
fi
# To be used by sar for post-processing
if [ -e /sys/class/net ]; then
/bin/ls -1 /sys/class/net | while read netdev; do
echo "$netdev `readlink /sys/class/net/$netdev`" >>netdev-types.txt
done
fi
/bin/rm -f sysstat-pids.txt
for subtool in `echo $subtools | sed -e 's/,/ /g'`; do
case "$subtool" in
pidstat)
echo "Starting pidstat"
TZ=UTC S_TIME_FORMAT=ISO pidstat -p ALL $interval >pidstat-stdout.txt 2>pidstat-stderr.txt &
pidstat_pid=$!
echo "$pidstat_pid" >>sysstat-pids.txt
echo "pidstat pid is $pidstat_pid"
;;
mpstat)
echo "Starting mpstat"
TZ=UTC S_TIME_FORMAT=ISO mpstat -o JSON -P ALL $interval >mpstat.json 2>mpstat-stderr.txt &
mpstat_pid=$!
echo "$mpstat_pid" >>sysstat-pids.txt
echo "mpstat pid is $mpstat_pid"
;;
iostat)
echo "Starting iostat"
TZ=UTC S_TIME_FORMAT=ISO iostat -xtdkyN -o JSON -p ALL $interval >iostat.json 2>iostat-stderr.txt &
iostat_pid=$!
echo "$iostat_pid" >>sysstat-pids.txt
echo "iostat pid is $iostat_pid"
;;
sar)
echo "Starting sar"
TZ=UTC S_TIME_FORMAT=ISO sar -n ALL -B -q ALL -W -H -m ALL -w $interval >sar-stdout.txt 2>sar-stderr.txt &
sar_pid=$!
echo "$sar_pid" >>sysstat-pids.txt
echo "sar pid is $sar_pid"
;;
*)
echo "Invalid subtool: $subtool"
;;
esac
done