Skip to content
Closed

Pcp #183

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions agent/tool-scripts/pcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: t; sh-basic-offset: 8; sh-indentation: 8; sh-indent-for-case-alt: + -*-

script_path="`dirname $0`"
script_name="`basename $0`"
pbench_bin="`cd ${script_path}/..; /bin/pwd`"

# source the base script
. "$pbench_bin"/base

# Perftool scripts must provide the following functions
# 1) Install the tool
# 2) Start data collection
# 3) Stop data collection
# 4) post-process the data

# Defaults
tool="$script_name"
tool_package_name="pcp-gui" # this package should have appropriate deps for the remaining (90+!) pcp packages
tool_daemon="pmcd"
group="default"
dir="/tmp"
mode=""
interval="3"
iteration="1"
options="none"
tool_bin="/usr/bin/pmlogger"
pmlogger_conf="$pbench_bin/config/pmlogger.conf"

# TODO: implement a generic start_service function in $pbench_run/base
function start_pmcd {
if ! pgrep pmcd; then
if [ -x /usr/bin/systemctl ]; then
systemctl start pmcd
else if [-x /usr/bin/service ]; then
service pmcd start
else
error_log "$script_name: could not start pmcd service"
fi
fi
fi
if pgrep pmcd; then
debug_log "$script_name: service pmcd started"
return 0
else
error_log "$script_name: could not start pmcd service"
return 1
fi
}

# Process options and arguments
opts=$(getopt -q -o idp --longoptions "dir:,group:,iteration:,interval:,start,stop,install,postprocess" -n "getopt.sh" -- "$@");
if [ $? -ne 0 ]; then
printf "\n"
printf "$script_name: you specified an invalid option\n\n"
printf "The following options are available: \n\n"
printf -- "\t--install, install this perf tool\n"
printf "\n"
printf -- "\t--start|stop|postprocess start/stop/post-process the data collection\n"
printf -- "\t--iteration=int the iteration (required)\n"
printf -- "\t--group=str the perftool group (required)\n"
printf -- "\t--dir=str directory to store data collection (required)\n"
printf -- "\t--interval=int number of seconds between each data collection\n"
exit 1
fi
eval set -- "$opts";
while true; do
case "$1" in
--install)
mode="install"
shift;
;;
--start)
mode="start"
shift;
;;
--stop)
mode="stop"
shift;
;;
--postprocess)
mode="postprocess"
shift;
;;
-d|--dir)
shift;
if [ -n "$1" ]; then
dir="$1"
shift
fi
;;
-g|--group)
shift;
if [ -n "$1" ]; then
group="$1"
shift
fi
;;
-i|--iteration)
shift;
if [ -n "$1" ]; then
iteration="$1"
shift
fi
;;
--interval)
shift;
if [ -n "$1" ]; then
interval="$1"
shift
fi
;;
--)
shift;
break;
;;
esac
done

tool_dir="$dir/tools-$group"
tool_output_dir="$tool_dir/$tool" # all tools keep data in their tool specific dir
tool_cmd_file="$tool_output_dir/$tool.cmd"
tool_pid_file="$pbench_tmp/$group.$iteration.$tool.pid"
tool_stdout_file="$tool_output_dir/$tool-stdout.txt"
tool_stderr_file="$tool_output_dir/$tool-stderr.txt"
tool_cmd="$tool_bin -c pmlogger.conf -t ${interval} archive >$tool_stdout_file 2>$tool_stderr_file & echo \$! >$tool_pid_file"

case "$mode" in
install)
# pcp package are not maintained by pbench
if check_install_rpm $tool_package_name; then
# if a user does not create their own pmlogger config, we create one
if [ ! -e $pmlogger_conf ]; then
if start_pmcd; then
if /usr/libexec/pcp/bin/pmlogconf -c -r $pmlogger_conf; then
debug_log "$script_name: created pmlogger config"
else
error_log "$script_name: could not create pmlogger config"
fi
else
error_log "$script_name: creating pmlogger config not possible because pmcd could not be started"
fi
fi
else
error_log "$script_name: installation of $tool_package_name failed"
exit 1
fi
;;
start)
if start_pmcd; then
mkdir -p "$tool_output_dir"
pushd "$tool_output_dir" >/dev/null
/bin/rm -f archive*
echo "$tool_cmd" >"$tool_cmd_file"
chmod +x "$tool_cmd_file"
# pmlogger config is kept with tool data for debug purposes
/bin/cp "$pmlogger_conf" "$tool_output_dir"
debug_log "$script_name: running $tool_cmd"
. $tool_cmd_file
popd >/dev/null
wait
else
error_log "$script_name: could not not run pmlogger because pmcd is not running"
fi
;;
stop)
pid=`cat "$tool_pid_file"`
debug_log "stopping $script_name"
kill $pid && /bin/rm "$tool_pid_file"
;;
postprocess)
debug_log "postprocessing $script_name"
$script_path/postprocess/$script_name-postprocess "$tool_output_dir" "$interval" >>"$tool_stdout_file" 2>>"$tool_stderr_file"
;;
esac
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.avactive
1457460327000,123.667
1457460330000,27.333
1457460333000,29.333
1457460336000,25.667
1457460339000,28.000
1457460342000,39.000
1457460345000,28.000
1457460348000,44.000
1457460351000,57.333
1457460354000,155.667
1457460357000,32.000
1457460360000,25.000
1457460363000,30.333
1457460366000,0.333
1457460369000,71.667
1457460372000,0.667
1457460375000,45.000
1457460378000,0.333
19 changes: 19 additions & 0 deletions agent/tool-scripts/postprocess/gold/pcp-0/csv/disk.all.blkread.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.blkread
1457460327000,0.000
1457460330000,0.000
1457460333000,0.000
1457460336000,0.000
1457460339000,0.000
1457460342000,0.000
1457460345000,0.000
1457460348000,0.000
1457460351000,0.000
1457460354000,0.000
1457460357000,0.000
1457460360000,0.000
1457460363000,0.000
1457460366000,0.000
1457460369000,0.000
1457460372000,0.000
1457460375000,0.000
1457460378000,0.000
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.blkwrite
1457460327000,1111.000
1457460330000,19.000
1457460333000,23.667
1457460336000,13.667
1457460339000,18.667
1457460342000,177.333
1457460345000,20.000
1457460348000,137.667
1457460351000,30.000
1457460354000,2967.667
1457460357000,109.333
1457460360000,14.000
1457460363000,45.000
1457460366000,3.000
1457460369000,106.000
1457460372000,11.333
1457460375000,63.667
1457460378000,0.333
19 changes: 19 additions & 0 deletions agent/tool-scripts/postprocess/gold/pcp-0/csv/disk.all.read.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.read
1457460327000,0.000
1457460330000,0.000
1457460333000,0.000
1457460336000,0.000
1457460339000,0.000
1457460342000,0.000
1457460345000,0.000
1457460348000,0.000
1457460351000,0.000
1457460354000,0.000
1457460357000,0.000
1457460360000,0.000
1457460363000,0.000
1457460366000,0.000
1457460369000,0.000
1457460372000,0.000
1457460375000,0.000
1457460378000,0.000
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.read_bytes
1457460327000,0.000
1457460330000,0.000
1457460333000,0.000
1457460336000,0.000
1457460339000,0.000
1457460342000,0.000
1457460345000,0.000
1457460348000,0.000
1457460351000,0.000
1457460354000,0.000
1457460357000,0.000
1457460360000,0.000
1457460363000,0.000
1457460366000,0.000
1457460369000,0.000
1457460372000,0.000
1457460375000,0.000
1457460378000,0.000
19 changes: 19 additions & 0 deletions agent/tool-scripts/postprocess/gold/pcp-0/csv/disk.all.total.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.total
1457460327000,53.000
1457460330000,1.667
1457460333000,1.333
1457460336000,1.000
1457460339000,1.333
1457460342000,3.667
1457460345000,1.333
1457460348000,4.333
1457460351000,2.667
1457460354000,45.000
1457460357000,5.000
1457460360000,1.000
1457460363000,1.333
1457460366000,0.333
1457460369000,10.333
1457460372000,0.333
1457460375000,3.000
1457460378000,0.000
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.total_bytes
1457460327000,555.667
1457460330000,9.333
1457460333000,12.000
1457460336000,6.667
1457460339000,9.333
1457460342000,88.667
1457460345000,10.000
1457460348000,68.667
1457460351000,15.333
1457460354000,1483.667
1457460357000,54.667
1457460360000,7.000
1457460363000,22.667
1457460366000,1.333
1457460369000,53.000
1457460372000,5.667
1457460375000,31.667
1457460378000,0.333
19 changes: 19 additions & 0 deletions agent/tool-scripts/postprocess/gold/pcp-0/csv/disk.all.write.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.write
1457460327000,53.000
1457460330000,1.667
1457460333000,1.333
1457460336000,1.000
1457460339000,1.333
1457460342000,3.667
1457460345000,1.333
1457460348000,4.333
1457460351000,2.667
1457460354000,45.000
1457460357000,5.000
1457460360000,1.000
1457460363000,1.333
1457460366000,0.333
1457460369000,10.333
1457460372000,0.333
1457460375000,3.000
1457460378000,0.000
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
timestamp_ms,disk.all.write_bytes
1457460327000,555.667
1457460330000,9.333
1457460333000,12.000
1457460336000,6.667
1457460339000,9.333
1457460342000,88.667
1457460345000,10.000
1457460348000,68.667
1457460351000,15.333
1457460354000,1483.667
1457460357000,54.667
1457460360000,7.000
1457460363000,22.667
1457460366000,1.333
1457460369000,53.000
1457460372000,5.667
1457460375000,31.667
1457460378000,0.333
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
timestamp_ms,event.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
timestamp_ms,event.missed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
timestamp_ms,filesys.blocksize["/dev/dm-2"],filesys.blocksize["/dev/sda3"],filesys.blocksize["/dev/dm-3"]
20 changes: 20 additions & 0 deletions agent/tool-scripts/postprocess/gold/pcp-0/csv/filesys.capacity.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
timestamp_ms,filesys.capacity["/dev/dm-2"],filesys.capacity["/dev/sda3"],filesys.capacity["/dev/dm-3"]
1457460324000,51475068.000,487652.000,177465896.000
1457460327000,51475068.000,487652.000,177465896.000
1457460330000,51475068.000,487652.000,177465896.000
1457460333000,51475068.000,487652.000,177465896.000
1457460336000,51475068.000,487652.000,177465896.000
1457460339000,51475068.000,487652.000,177465896.000
1457460342000,51475068.000,487652.000,177465896.000
1457460345000,51475068.000,487652.000,177465896.000
1457460348000,51475068.000,487652.000,177465896.000
1457460351000,51475068.000,487652.000,177465896.000
1457460354000,51475068.000,487652.000,177465896.000
1457460357000,51475068.000,487652.000,177465896.000
1457460360000,51475068.000,487652.000,177465896.000
1457460363000,51475068.000,487652.000,177465896.000
1457460366000,51475068.000,487652.000,177465896.000
1457460369000,51475068.000,487652.000,177465896.000
1457460372000,51475068.000,487652.000,177465896.000
1457460375000,51475068.000,487652.000,177465896.000
1457460378000,51475068.000,487652.000,177465896.000
Loading