diff --git a/scripts/disuseprofiler b/scripts/disuseprofiler index 1d13767..65deeeb 100755 --- a/scripts/disuseprofiler +++ b/scripts/disuseprofiler @@ -4,7 +4,6 @@ # issued, the default set of profilers (readprofile, sar, lockmeter) are used. # # reqparam value command - the name of the command to start/stop/install the profiler -# TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../etc/autobench.conf || . $AUTODIR/scripts/functions @@ -14,31 +13,19 @@ if [ $# -lt 1 ]; then exit 1 fi -# call this script recursively when more than one argument -# is given to it. -if [ $# -gt 1 ]; then - for i in $*; do - "$0" "$i"; - done; - exit; -fi; - - -# Remove it from the list of profilers -if [ -e $TMPDIR/profilers ]; then - cat $TMPDIR/profilers | grep -v ^$1 > $TMPDIR/profilers.new - rm $TMPDIR/profilers - mv $TMPDIR/profilers.new $TMPDIR/profilers -fi - - -# Remove it to the start & stop profilers script -cat $AUTODIR/run/startprofilers | grep -v "# $1$" > $TMPDIR/startprofilers.new 2>/dev/null -rm $AUTODIR/run/startprofilers 2>/dev/null -mv $TMPDIR/startprofilers.new $AUTODIR/run/startprofilers -chmod a+x $AUTODIR/run/startprofilers - -cat $AUTODIR/run/stopprofilers | grep -v "# $1$" > $TMPDIR/stopprofilers.new 2>/dev/nul -rm $AUTODIR/run/stopprofilers 2>/dev/nul -mv $TMPDIR/stopprofilers.new $AUTODIR/run/stopprofilers -chmod a+x $AUTODIR/run/stopprofilers +for prof in $@; do + # Remove it from the list of profilers. + if [ -e $TMPDIR/profilers ]; then + grep -v ^$prof $TMPDIR/profilers > $TMPDIR/profilers.new 2> /dev/null + mv -f $TMPDIR/profilers.new $TMPDIR/profilers + fi + + # Remove it from the start & stop profilers script. + grep -v "# $prof$" $AUTODIR/run/startprofilers > $TMPDIR/startprofilers.new 2> /dev/null + mv -f $TMPDIR/startprofilers.new $AUTODIR/run/startprofilers + chmod a+x $AUTODIR/run/startprofilers + + grep -v "# $prof$" $AUTODIR/run/stopprofilers > $TMPDIR/stopprofilers.new 2> /dev/nul + mv -f $TMPDIR/stopprofilers.new $AUTODIR/run/stopprofilers + chmod a+x $AUTODIR/run/stopprofilers +done diff --git a/scripts/getsysinfo b/scripts/getsysinfo index 8315e33..3fb204d 100755 --- a/scripts/getsysinfo +++ b/scripts/getsysinfo @@ -264,3 +264,17 @@ then $AUTODIR/scripts/helpers/proc-interrupts-diff $2/proc/interrupts.before$RUN_SUFFIX $2/proc/interrupts.$1$RUN_SUFFIX > $2/proc/interrupts.diff$RUN_SUFFIX fi fi + +# BTRFS-specific info. +if [ $1 == 'before' ] +then + if [ -d "/hks/users/corry/git/btrfs-unstable" ]; then + pushd /hks/users/corry/git/btrfs-unstable > /dev/null + cg-log -M -v -r `cg-object-id -p $(cg-object-id)`..`cg-object-id` > $2/config/btrfs_changeset$RUN_SUFFIX + popd > /dev/null + fi + if which mkfs.btrfs > /dev/null 2>&1; then + mkfs.btrfs > $2/config/btrfs_mkfs$RUN_SUFFIX 2>&1 + fi +fi + diff --git a/scripts/profilers/blktrace b/scripts/profilers/blktrace index 5f6cd36..75e199a 100755 --- a/scripts/profilers/blktrace +++ b/scripts/profilers/blktrace @@ -1,67 +1,72 @@ #!/bin/bash # This is the script to start and stop the blktrace profiler. # -# reqparam value start|stop|report|postprocess|install Which action you'd like to perform -# reqparam value "device list" -# optparam value Suffix - an optional string to append to the name of the log file -# +# USAGE: +# blktrace [SUFFIX=log file suffix] +# command = start|stop|print-start|print-stop|report|postprocess|install TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../../etc/autobench.conf || . $AUTODIR/scripts/functions if [ $# -lt 1 ]; then - echo "You must specify start, stop, report, postprocess, or install" - exit 1 + echo "You must specify start, stop, report, postprocess, or install" + echo "USAGE: `basename $0` [SUFFIX=log file suffix]" + echo " command = start|stop|print-start|print-stop|report|postprocess|install" + exit 1 fi +DEVICES="" +SUFFIX="" + CMD="`echo $1 | tr -t A-Z a-z`" +shift + +for arg; do + export $arg +done -if [ $# -eq 3 ]; then - SUFFIX=".$3" +if [ -z "$DEVICES" ]; then + exit 1 +fi +DEVICES=`echo $DEVICES | sed -e 's/,/ /g'` + +if ! mount | grep -q "^debugfs"; then + mount -t debugfs debugfs /sys/kernel/debug fi case $CMD in - install) - mount -t debugfs debugfs /sys/kernel/debug/ - if [ ! -e /autobench/sources/blktrace/blktrace ]; then +install) + if [ ! -e $AUTODIR/sources/blktrace/blktrace ]; then $AUTODIR/scripts/profilers/install/blktrace fi - ;; - start) - profiler_log 'starting blktrace' - mkdir $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX - pushd $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX - $AUTODIR/sources/blktrace/blktrace -d $2 & - popd - ;; - - print-start) - echo "profiler_log 'starting blktrace'" - echo 'mkdir $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX' - echo 'pushd $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX' - echo '$AUTODIR/sources/blktrace/blktrace -d '$2' &' - echo 'popd' - ;; + ;; - stop) - profiler_log 'stopping blktrace' - #stop vm-stat - # Full path is specified here so that we don't kill ourselves - killall blktrace - ;; +print-start) + echo 'profiler_log "starting blktrace"' + echo 'mkdir $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX' + echo 'pushd $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX > /dev/null' + echo '$AUTODIR/sources/blktrace/blktrace ' $DEVICES '&' + echo 'popd > /dev/null' + ;; - print-stop) - echo "profiler_log 'stopping blktrace'" - echo 'killall blktrace' - ;; +print-stop) + echo 'profiler_log "stopping blktrace"' + echo 'killall blktrace' + ;; - report) - ;; +report) + ;; - postprocess) - ;; +postprocess) + profiler_log 'post-processing blktrace' + pushd $LOGDIR/analysis/blktrace.$RUN_NUMBER$SUFFIX > /dev/null + for dev in $DEVICES; do + $AUTODIR/sources/blktrace/blkparse -o $dev.blkparse.out `basename $dev` + done + popd > /dev/null + ;; - *) - echo "The first argument must be start, stop, report, postprocess, or install" - ;; +*) + echo "The first argument must be start, stop, report, postprocess, or install" + ;; esac diff --git a/scripts/profilers/install/oprofile b/scripts/profilers/install/oprofile index 034fb8b..3895e3a 100755 --- a/scripts/profilers/install/oprofile +++ b/scripts/profilers/install/oprofile @@ -1,6 +1,5 @@ #!/bin/bash -# This is the script to install the oprofile userspace utilities -# +# Install the oprofile userspace utilities. TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../../../etc/autobench.conf || . $AUTODIR/scripts/functions @@ -9,389 +8,55 @@ TMP_AUTODIR=`dirname $0` # The oprofile directory in $AUTODIR/sources should match the name below # This is very important, because the matching oprofile wrapper script needs to use the # same $OP_VERSION to call the bins, like "$AUTODIR/sources/$OP_VERSION/install/some-biin -OP_VERSION="oprofile-0.9.4-autobench" -# the tar file should also match the name plus .tar.gz -OP_TARFILE=${OP_VERSION}.tar.gz -WEB_LOCATION="http://unc.dl.sourceforge.net/sourceforge/oprofile/$OP_TARFILE" - - -# Do NOT use distro-pkg or distro-sw in this install script, or any -# install script which is commonly used in autobench. Unless you want -# to maintain a repository for every single distro we use and have used, -# on every platform we use or have used, do not do this in common scripts!!! -# -Andrew - -################################################################################ -function exit_err { - echo "There was an error in the previous step. Please correct the problem" - echo "and rerun the script, or complete the steps in the client README" - echo "manually." - exit 2 -} -################################################################################ -function kernel_check { - kernel_version=`uname -r` - - # Used only on RedHat to insatll kernel debug info since Redhat - # likes to be an immense PITA. Only do this if we actually running - # on the distro kernel. - - # we assume if "autoken" is not in the kernel version, this must be a distro kernel - if ! echo $kernel_version | grep autokern >/dev/null; then - if [ -e "/etc/redhat-release" -a ! -f "/boot/vmlinux-$kernel_version" ]; then - vmlinux_path="/usr/lib/debug/lib/modules/$kernel_version/vmlinux" - if [ ! -f "$vmlinux_path" ]; then - echo "Trying to get vmlinux for RedHat with distro-pkg" - distro-pkg kernel-debuginfo - if [ ! -f "$vmlinux_path" ]; then - echo "distro-pkg did not work" - else - echo "symlinking /boot/vmlinux-$kenel_version > $vmlinux_path" - ln -sf "$vmlinux_path" "/boot/vmlinux-$kernel_version" - fi - fi - fi - fi -} - -################################################################################ -# check and install gettext if not found -function gettext_check { - package=gettext-0.17 - tarfile=${package}.tar.gz - echo "Checking for gettext..." - if [ ! -f /usr/lib/libgettextpo.so.0 -a \ - ! -f /usr/lib64/libgettextpo.so.0 ]; then - echo " not found..." - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - /bin/rm -rf $package - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - pushd $package >/dev/null - echo " configuring..." - if ! ./configure --prefix=/usr >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - else - ldconfig - popd >/dev/null - popd >/dev/null - echo " done" - fi - else - echo " found" - fi -} - -################################################################################ -# check and install libiberty if not found in autobench sources -function iberty_check { - package=binutils-2.18 - tarfile=${package}.tar.bz2 - echo "Checking for libiberty in autobench..." - if [ ! -f $AUTODIR/sources/$package/dist/lib/libiberty.a ]; then - echo " not found..." - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - /bin/rm -rf $package - if ! tar jxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - pushd $package >/dev/null - echo " configuring..." - if ! ./configure --prefix=`pwd`/dist >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - fi - popd >/dev/null - popd >/dev/null - echo " done" - else - echo " found" - fi - - # make sure we specify to use this new bintuils directory - oprofile_config_opts="$oprofile_config_opts --with-binutils=$AUTODIR/sources/$package/dist" -} -################################################################################ -# check and install popt if not found -function popt_check { - echo "Checking for popt..." - if [ ! -f /usr/lib/libpopt.a ]; then - echo " not found..." - tarfile=popt-1.10.4.tar.gz - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - dst_dir=`tar ztf $tarfile | head -n 1` - pushd $dst_dir >/dev/null - echo " configuring..." - if ! ./configure --prefix=`pwd`/dist CFLAGS=-m32 LDFLAGS=-m32 >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - else - # for some insane reason, popt will always "install" libraries - # in lib64, even if they are 32-bit. Make sure we move the libs - # to the right place - pushd dist >/dev/null - if [ -d lib64 ]; then - /bin/cp lib64/* /usr/lib - else - /bin/cp lib/* /usr/lib - fi - /bin/cp include/* /usr/include - popd >/dev/null - popd >/dev/null - popd >/dev/null - echo " done" - fi - else - echo " found" - fi -} -################################################################################ -# check and install popt-64-bit if not found -function popt64_check { - - # don't bother if we are 32-bit - uname -m | grep i686 >/dev/null && return - - # don't bother if we are ppc64 - uname -m | grep ppc64 >/dev/null && return - - echo "Checking for popt64..." - if [ ! -f /usr/lib64/libpopt.a ]; then - echo " not found..." - tarfile=popt-1.10.4.tar.gz - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - dst_dir=`tar ztf $tarfile | head -n 1` - pushd $dst_dir >/dev/null - echo " configuring..." - if ! ./configure --prefix=`pwd`/dist CFLAGS=-m64 LDFLAGS=-m64 >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - exit_err - else - pushd dist >/dev/null - /bin/cp lib64/* /usr/lib64 - /bin/cp include/* /usr/include - popd >/dev/null - popd >/dev/null - popd >/dev/null - echo " done" - fi - else - echo " found" - fi -} -################################################################################ -# check and install oprofile if not found -function oprofile_check { - echo "Checking for oprofile..." - if [ ! -f $AUTODIR/sources/$OP_VERSION/dist/bin/opcontrol ]; then - echo " not found..." - tarfile=${OP_VERSION}.tar.gz - pushd $AUTODIR/sources > /dev/null - - echo " fetching..." - if ! wget --quiet -O $tarfile $SOURCES_REPO/$tarfile >/dev/null 2>wget.err; then - echo " failed" - cat wget.err - popd > /dev/null - exit_err - fi - echo " untarring..." - if ! tar zxf $tarfile >/dev/null 2>tar.err; then - echo " failed" - cat tar.err - popd > /dev/null - exit_err - fi - - dst_dir=`tar ztf $tarfile | head -n 1` - pushd $dst_dir >/dev/null - mkdir -p src - mv * src 2>/dev/null - pushd src >/dev/null - echo " configuring..." - if ! ./configure --prefix=$AUTODIR/sources/$OP_VERSION/dist --with-kernel-support $oprofile_config_opts >/dev/null 2>config.err; then - echo " failed" - cat config.err - popd > /dev/null - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " building..." - make clean >/dev/null - if ! make -j8 >/dev/null 2>make.err; then - echo " failed\n" - cat make.err - popd > /dev/null - popd > /dev/null - popd > /dev/null - exit_err - fi - echo " installing..." - if ! make install >/dev/null 2>install.err; then - echo " failed\n" - cat install.err - popd > /dev/null - popd > /dev/null - popd > /dev/null - exit_err - else - popd >/dev/null - popd >/dev/null - popd > /dev/null - echo " done" - fi - else - echo " found" - fi -} - -kernel_check -gettext_check -iberty_check -popt_check -popt64_check -oprofile_check - -oprofileversion=`$AUTODIR/sources/$OP_VERSION/dist/bin/opcontrol --version` +version="0.9.4-autobench" +OP_VERSION="oprofile-$version" + +kernel_version=`uname -r` + +# If we're running on RedHat, install the kernel debug info since Redhat likes +# to be an immense PITA. We assume if "autokern" is not in the kernel version, +# this must be a distro kernel. +if ! echo $kernel_version | grep autokern >/dev/null && + [ -e "/etc/redhat-release" -a ! -f "/boot/vmlinux-$kernel_version" ]; then + vmlinux_path="/usr/lib/debug/lib/modules/$kernel_version/vmlinux" + if [ ! -f "$vmlinux_path" ]; then + log "Trying to get vmlinux for RedHat with distro-pkg" + distro-pkg kernel-debuginfo + if [ ! -f "$vmlinux_path" ]; then + log "distro-pkg did not work" + else + log "symlinking /boot/vmlinux-$kenel_version > $vmlinux_path" + ln -sf "$vmlinux_path" "/boot/vmlinux-$kernel_version" + fi + fi +fi + +# Binutils needs to be built with -fPIC. +export CFLAGS="-g -O2 -fPIC" +$AUTODIR/utilities/install/binutils +if [ $? -ne 0 ]; then + log "ERROR installing binutils, which is required for oprofile." + exit 1 +fi +unset CFLAGS + +$AUTODIR/utilities/install/gettext +if [ $? -ne 0 ]; then + log "ERROR installing gettext, which is required for oprofile." + exit 1 +fi + +$AUTODIR/utilities/install/popt +if [ $? -ne 0 ]; then + log "ERROR installing popt, which is required for oprofile." + exit 1 +fi + +$AUTODIR/utilities/install/install-package package=oprofile version=$version 'configure_opts=--with-binutils='$AUTODIR'/sources/binutils/dist --with-kernel-support' +if [ $? -ne 0 ]; then + exit 1 +fi + +oprofileversion=`$AUTODIR/sources/oprofile/dist/bin/opcontrol --version` log "$oprofileversion" diff --git a/scripts/profilers/tools/foreign_profilers b/scripts/profilers/tools/foreign_profilers index 974d1a7..6a4fe13 100755 --- a/scripts/profilers/tools/foreign_profilers +++ b/scripts/profilers/tools/foreign_profilers @@ -1,5 +1,5 @@ #!/bin/bash -# $1 -- mode (start of stop) +# $1 -- mode (start or stop) # $2 -- comma separate list of Autobench instances to run [start|stop]profilers in # the instances can be local or remote, masters or slaves diff --git a/scripts/profilers/tools/postprocess-iostat b/scripts/profilers/tools/postprocess-iostat index e37dfff..1eb6e7a 100755 --- a/scripts/profilers/tools/postprocess-iostat +++ b/scripts/profilers/tools/postprocess-iostat @@ -150,7 +150,7 @@ my $dm_util_plot_files = ""; my $dm_device_count = 0; -foreach $key (keys %devices) { +foreach $key (sort keys %devices) { $x = $devices{$key}; open($device_rkb_file_handles[$x], ">$output_directory/plot-files/$key.rkb.plot"); @@ -280,7 +280,7 @@ while () { } } -foreach $key (keys %devices) { +foreach $key (sort keys %devices) { $x = $devices{$key}; close $device_rrqm_file_handles[$x]; diff --git a/scripts/useprofiler b/scripts/useprofiler index a360813..68a810b 100755 --- a/scripts/useprofiler +++ b/scripts/useprofiler @@ -3,62 +3,54 @@ # runs the important section). If no use/disuseprofiler command are issued, # the default set of profilers (readprofile, schedstat, sar) are used. # -# reqparam value command - the name of the command to start/stop/install the profiler -# optparam value repeat arguments - any additional arguments to the profiler (not including a logfile suffix) -# +# USAGE: +# useprofiler [profiler-script-argument]+ TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../etc/autobench.conf || . $AUTODIR/scripts/functions if [ $# -lt 1 ]; then - echo "You must specify a command to execute the profiler" - exit 1 + echo "USAGE: `basename $0` [profiler-script-argument]+" + exit 1 fi -# Add it to the list of profilers +profiler=$1 +shift + +# Add it to the list of profilers. Remove +# any previous instances of this profiler. if [ -e $TMPDIR/profilers ]; then - cat $TMPDIR/profilers | grep -v ^$1 > $TMPDIR/profilers.new - rm $TMPDIR/profilers - mv $TMPDIR/profilers.new $TMPDIR/profilers -else - disuseprofiler readcg - disuseprofiler sar - disuseprofiler schedstat - disuseprofiler readprofile + grep -v "^$profiler" $TMPDIR/profilers > $TMPDIR/profilers.new + mv -f $TMPDIR/profilers.new $TMPDIR/profilers fi -# if this is a remoteprofiler, add this line in a little later -# we need just one line in here, with all remote hostnames -if [ $1 != "remoteprofiler" ]; then - echo "$@" >> $TMPDIR/profilers +if [ $profiler != "remoteprofiler" ]; then + echo "$profiler $@" >> $TMPDIR/profilers fi -# save the profiler specified -profiler=$1 -shift - -# Make sure the profiler is installed and ready for use +# Make sure the profiler is installed and ready for use. $profiler install "$@" + # STARTPROFILERS ############################################################### +# Update the 'startprofilers' script. -# remove previous instances of the profiler -cat $AUTODIR/run/startprofilers | grep -v "# $profiler$" > $TMPDIR/startprofilers.new 2>/dev/null -rm $AUTODIR/run/startprofilers 2>/dev/null -mv $TMPDIR/startprofilers.new $AUTODIR/run/startprofilers +# Remove previous instances of the profiler +grep -v "# $profiler$" $AUTODIR/run/startprofilers > $TMPDIR/startprofilers.new 2> /dev/null +mv -f $TMPDIR/startprofilers.new $AUTODIR/run/startprofilers -# get the print-start output -# if this is a remote profiler, this will also create (through remoteprofiler call) a startremoteprofiler.hostname script +# Get the print-start output. If this is a remote profiler, this will also +# create (through remoteprofiler call) a startremoteprofiler.hostname script. ADD=`$profiler print-start "$@"` -# If this is a remoteprofiler and we specified many hosts, we get more than one line -# for the $ADD variable. Consolidate it down to one line and combine the hostnames -# in one arg +# If this is a remoteprofiler and we specified multiple hosts, we get more than +# one line for the $ADD variable. Consolidate it down to one line and combine +# the hostnames in one arg. -if [ "$profiler" = "remoteprofiler" ]; then - pushd $AUTODIR/run >/dev/null - filelist=`/bin/ls startremoteprofilers.*` - popd >/dev/null +if [ $profiler = "remoteprofiler" ]; then + pushd $AUTODIR/run > /dev/null + filelist=`ls startremoteprofilers.*` + popd > /dev/null hosts=`echo $filelist | sed -e 's/startremoteprofilers.//g'` hostlist="" for host in $hosts; do @@ -68,35 +60,36 @@ if [ "$profiler" = "remoteprofiler" ]; then hostlist="$hostlist,$host" fi done -ADD="$AUTODIR/scripts/profilers/remoteprofiler start $hostlist" - -# now that we have the hostlist for remoteprofilers, add the remoteprofiler line in profilers file -echo "remoteprofiler $hostlist" >>$TMPDIR/profilers + ADD="$AUTODIR/scripts/profilers/remoteprofiler start $hostlist" + # Now that we have the hostlist for remoteprofilers, add + # the remoteprofiler line in profilers file. + echo "remoteprofiler $hostlist" >> $TMPDIR/profilers fi -# add the print-start output and append the profiler key +# Add the print-start output and append the profiler key. echo "$ADD" | sed -e "s/$/ # $profiler/" >> $AUTODIR/run/startprofilers -# make sure startprofilers is executable +# Make sure startprofilers is executable. chmod a+x $AUTODIR/run/startprofilers + # STOPPROFILERS ################################################################ +# Update the 'stopprofilers' script. -# remove previous instances of the profiler -cat $AUTODIR/run/stopprofilers | grep -v "# $profiler$" > $TMPDIR/stopprofilers.new 2>/dev/null -rm $AUTODIR/run/stopprofilers 2>/dev/null -mv $TMPDIR/stopprofilers.new $AUTODIR/run/stopprofilers +# Remove previous instances of the profiler. +grep -v "# $profiler$" $AUTODIR/run/stopprofilers > $TMPDIR/stopprofilers.new 2> /dev/null +mv -f $TMPDIR/stopprofilers.new $AUTODIR/run/stopprofilers -# get the print-stop output +# Get the print-stop output. ADD=`$profiler print-stop "$@"` if [ "$profiler" = "remoteprofiler" ]; then -ADD="$AUTODIR/scripts/profilers/remoteprofiler stop $hostlist" + ADD="$AUTODIR/scripts/profilers/remoteprofiler stop $hostlist" fi -# add the print-stop output and append the profiler key +# Add the print-stop output and append the profiler key. echo "$ADD" | sed -e "s/$/ # $profiler/" >> $AUTODIR/run/stopprofilers -# make sure stopprofilers is executable +# Make sure stopprofilers is executable. chmod a+x $AUTODIR/run/stopprofilers