Skip to content

Commit 3e0a772

Browse files
committed
Merge pull request #205 from ndokos/atheurer-pcp-new
Adds tool script for performance co-pilot.
2 parents a2f023a + 693a648 commit 3e0a772

File tree

199 files changed

+11152
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+11152
-15
lines changed

agent/tool-scripts/pcp

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#!/bin/bash
2+
# -*- mode: shell-script; indent-tabs-mode: t; sh-basic-offset: 8; sh-indentation: 8; sh-indent-for-case-alt: + -*-
3+
4+
script_path="`dirname $0`"
5+
script_name="`basename $0`"
6+
pbench_bin="`cd ${script_path}/..; /bin/pwd`"
7+
8+
# source the base script
9+
. "$pbench_bin"/base
10+
11+
# Perftool scripts must provide the following functions
12+
# 1) Install the tool
13+
# 2) Start data collection
14+
# 3) Stop data collection
15+
# 4) post-process the data
16+
17+
# Defaults
18+
tool="$script_name"
19+
tool_package_name="pcp-gui" # this package should have appropriate deps for the remaining (90+!) pcp packages
20+
tool_daemon="pmcd"
21+
group="default"
22+
dir="/tmp"
23+
mode=""
24+
interval="3"
25+
iteration="1"
26+
options="none"
27+
tool_bin="/usr/bin/pmlogger"
28+
pmlogger_conf="$pbench_bin/config/pmlogger.conf"
29+
30+
# TODO: implement a generic start_service function in $pbench_run/base
31+
function start_pmcd {
32+
if ! pgrep pmcd; then
33+
if [ -x /usr/bin/systemctl ]; then
34+
systemctl start pmcd
35+
else if [-x /usr/bin/service ]; then
36+
service pmcd start
37+
else
38+
error_log "$script_name: could not start pmcd service"
39+
fi
40+
fi
41+
fi
42+
if pgrep pmcd; then
43+
debug_log "$script_name: service pmcd started"
44+
return 0
45+
else
46+
error_log "$script_name: could not start pmcd service"
47+
return 1
48+
fi
49+
}
50+
51+
# Process options and arguments
52+
opts=$(getopt -q -o idp --longoptions "dir:,group:,iteration:,interval:,start,stop,install,postprocess" -n "getopt.sh" -- "$@");
53+
if [ $? -ne 0 ]; then
54+
printf "\n"
55+
printf "$script_name: you specified an invalid option\n\n"
56+
printf "The following options are available: \n\n"
57+
printf -- "\t--install, install this perf tool\n"
58+
printf "\n"
59+
printf -- "\t--start|stop|postprocess start/stop/post-process the data collection\n"
60+
printf -- "\t--iteration=int the iteration (required)\n"
61+
printf -- "\t--group=str the perftool group (required)\n"
62+
printf -- "\t--dir=str directory to store data collection (required)\n"
63+
printf -- "\t--interval=int number of seconds between each data collection\n"
64+
exit 1
65+
fi
66+
eval set -- "$opts";
67+
while true; do
68+
case "$1" in
69+
--install)
70+
mode="install"
71+
shift;
72+
;;
73+
--start)
74+
mode="start"
75+
shift;
76+
;;
77+
--stop)
78+
mode="stop"
79+
shift;
80+
;;
81+
--postprocess)
82+
mode="postprocess"
83+
shift;
84+
;;
85+
-d|--dir)
86+
shift;
87+
if [ -n "$1" ]; then
88+
dir="$1"
89+
shift
90+
fi
91+
;;
92+
-g|--group)
93+
shift;
94+
if [ -n "$1" ]; then
95+
group="$1"
96+
shift
97+
fi
98+
;;
99+
-i|--iteration)
100+
shift;
101+
if [ -n "$1" ]; then
102+
iteration="$1"
103+
shift
104+
fi
105+
;;
106+
--interval)
107+
shift;
108+
if [ -n "$1" ]; then
109+
interval="$1"
110+
shift
111+
fi
112+
;;
113+
--)
114+
shift;
115+
break;
116+
;;
117+
esac
118+
done
119+
120+
tool_dir="$dir/tools-$group"
121+
tool_output_dir="$tool_dir/$tool" # all tools keep data in their tool specific dir
122+
tool_cmd_file="$tool_output_dir/$tool.cmd"
123+
tool_pid_file="$pbench_tmp/$group.$iteration.$tool.pid"
124+
tool_stdout_file="$tool_output_dir/$tool-stdout.txt"
125+
tool_stderr_file="$tool_output_dir/$tool-stderr.txt"
126+
tool_cmd="$tool_bin -c pmlogger.conf -t ${interval} archive >$tool_stdout_file 2>$tool_stderr_file & echo \$! >$tool_pid_file"
127+
128+
case "$mode" in
129+
install)
130+
# pcp package are not maintained by pbench
131+
if check_install_rpm $tool_package_name; then
132+
# if a user does not create their own pmlogger config, we create one
133+
if [ ! -e $pmlogger_conf ]; then
134+
if start_pmcd; then
135+
if /usr/libexec/pcp/bin/pmlogconf -c -r $pmlogger_conf; then
136+
debug_log "$script_name: created pmlogger config"
137+
else
138+
error_log "$script_name: could not create pmlogger config"
139+
fi
140+
else
141+
error_log "$script_name: creating pmlogger config not possible because pmcd could not be started"
142+
fi
143+
fi
144+
else
145+
error_log "$script_name: installation of $tool_package_name failed"
146+
exit 1
147+
fi
148+
;;
149+
start)
150+
if start_pmcd; then
151+
mkdir -p "$tool_output_dir"
152+
pushd "$tool_output_dir" >/dev/null
153+
/bin/rm -f archive*
154+
echo "$tool_cmd" >"$tool_cmd_file"
155+
chmod +x "$tool_cmd_file"
156+
# pmlogger config is kept with tool data for debug purposes
157+
/bin/cp "$pmlogger_conf" "$tool_output_dir"
158+
debug_log "$script_name: running $tool_cmd"
159+
. $tool_cmd_file
160+
popd >/dev/null
161+
wait
162+
else
163+
error_log "$script_name: could not not run pmlogger because pmcd is not running"
164+
fi
165+
;;
166+
stop)
167+
pid=`cat "$tool_pid_file"`
168+
debug_log "stopping $script_name"
169+
kill $pid && /bin/rm "$tool_pid_file"
170+
;;
171+
postprocess)
172+
debug_log "postprocessing $script_name"
173+
$script_path/postprocess/$script_name-postprocess "$tool_output_dir" "$interval" >>"$tool_stdout_file" 2>>"$tool_stderr_file"
174+
;;
175+
esac
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
timestamp_ms,disk.all.avactive
2+
1457460323000,54.000
3+
1457460324000,53.000
4+
1457460325000,123.000
5+
1457460326000,124.000
6+
1457460327000,124.000
7+
1457460328000,29.000
8+
1457460329000,27.000
9+
1457460330000,26.000
10+
1457460331000,30.000
11+
1457460332000,29.000
12+
1457460333000,29.000
13+
1457460334000,26.000
14+
1457460335000,26.000
15+
1457460336000,25.000
16+
1457460337000,28.000
17+
1457460338000,28.000
18+
1457460339000,28.000
19+
1457460340000,39.000
20+
1457460341000,39.000
21+
1457460342000,39.000
22+
1457460343000,28.000
23+
1457460344000,28.000
24+
1457460345000,28.000
25+
1457460346000,44.000
26+
1457460347000,44.000
27+
1457460348000,44.000
28+
1457460349000,57.000
29+
1457460350000,57.000
30+
1457460351000,58.000
31+
1457460352000,154.000
32+
1457460353000,156.000
33+
1457460354000,157.000
34+
1457460355000,34.000
35+
1457460356000,31.000
36+
1457460357000,31.000
37+
1457460358000,25.000
38+
1457460359000,25.000
39+
1457460360000,25.000
40+
1457460361000,31.000
41+
1457460362000,30.000
42+
1457460363000,30.000
43+
1457460364000,1.000
44+
1457460365000,0.000
45+
1457460366000,0.000
46+
1457460367000,71.000
47+
1457460368000,72.000
48+
1457460369000,72.000
49+
1457460370000,2.000
50+
1457460371000,0.000
51+
1457460372000,0.000
52+
1457460373000,44.000
53+
1457460374000,46.000
54+
1457460375000,45.000
55+
1457460376000,1.000
56+
1457460377000,0.000
57+
1457460378000,0.000
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
timestamp_ms,disk.all.blkread
2+
1457460323000,0.000
3+
1457460324000,0.000
4+
1457460325000,0.000
5+
1457460326000,0.000
6+
1457460327000,0.000
7+
1457460328000,0.000
8+
1457460329000,0.000
9+
1457460330000,0.000
10+
1457460331000,0.000
11+
1457460332000,0.000
12+
1457460333000,0.000
13+
1457460334000,0.000
14+
1457460335000,0.000
15+
1457460336000,0.000
16+
1457460337000,0.000
17+
1457460338000,0.000
18+
1457460339000,0.000
19+
1457460340000,0.000
20+
1457460341000,0.000
21+
1457460342000,0.000
22+
1457460343000,0.000
23+
1457460344000,0.000
24+
1457460345000,0.000
25+
1457460346000,0.000
26+
1457460347000,0.000
27+
1457460348000,0.000
28+
1457460349000,0.000
29+
1457460350000,0.000
30+
1457460351000,0.000
31+
1457460352000,0.000
32+
1457460353000,0.000
33+
1457460354000,0.000
34+
1457460355000,0.000
35+
1457460356000,0.000
36+
1457460357000,0.000
37+
1457460358000,0.000
38+
1457460359000,0.000
39+
1457460360000,0.000
40+
1457460361000,0.000
41+
1457460362000,0.000
42+
1457460363000,0.000
43+
1457460364000,0.000
44+
1457460365000,0.000
45+
1457460366000,0.000
46+
1457460367000,0.000
47+
1457460368000,0.000
48+
1457460369000,0.000
49+
1457460370000,0.000
50+
1457460371000,0.000
51+
1457460372000,0.000
52+
1457460373000,0.000
53+
1457460374000,0.000
54+
1457460375000,0.000
55+
1457460376000,0.000
56+
1457460377000,0.000
57+
1457460378000,0.000
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
timestamp_ms,disk.all.blkwrite
2+
1457460323000,269.000
3+
1457460324000,269.000
4+
1457460325000,1099.000
5+
1457460326000,1117.000
6+
1457460327000,1117.000
7+
1457460328000,35.000
8+
1457460329000,11.000
9+
1457460330000,11.000
10+
1457460331000,23.000
11+
1457460332000,24.000
12+
1457460333000,24.000
13+
1457460334000,14.000
14+
1457460335000,13.000
15+
1457460336000,14.000
16+
1457460337000,18.000
17+
1457460338000,19.000
18+
1457460339000,19.000
19+
1457460340000,175.000
20+
1457460341000,178.000
21+
1457460342000,179.000
22+
1457460343000,22.000
23+
1457460344000,19.000
24+
1457460345000,19.000
25+
1457460346000,136.000
26+
1457460347000,138.000
27+
1457460348000,139.000
28+
1457460349000,32.000
29+
1457460350000,29.000
30+
1457460351000,29.000
31+
1457460352000,2925.000
32+
1457460353000,2989.000
33+
1457460354000,2989.000
34+
1457460355000,152.000
35+
1457460356000,88.000
36+
1457460357000,88.000
37+
1457460358000,15.000
38+
1457460359000,13.000
39+
1457460360000,14.000
40+
1457460361000,44.000
41+
1457460362000,46.000
42+
1457460363000,45.000
43+
1457460364000,4.000
44+
1457460365000,2.000
45+
1457460366000,3.000
46+
1457460367000,104.000
47+
1457460368000,107.000
48+
1457460369000,107.000
49+
1457460370000,12.000
50+
1457460371000,11.000
51+
1457460372000,11.000
52+
1457460373000,63.000
53+
1457460374000,64.000
54+
1457460375000,64.000
55+
1457460376000,1.000
56+
1457460377000,0.000
57+
1457460378000,0.000

0 commit comments

Comments
 (0)