diff --git a/scripts/benchmarks/ffsb b/scripts/benchmarks/ffsb index b2e05ec..9ff6925 100755 --- a/scripts/benchmarks/ffsb +++ b/scripts/benchmarks/ffsb @@ -1,152 +1,76 @@ #!/bin/bash # -# $1 is name of profile which must exist in the $AUTODIR/sources/ffsb directory -# $2 ... are any key=value pairs of valid profile entries or numdevs=n wher n is -# the number of devices to rn on -# Other key assumption is that FS(s) to benchmark are already mounted on /mnt/tmp1 ../mnt/tmpn +# $1: Filename of the profile. Will look in $AUTODIR/sources/ffsb/ and on GSA +# if the file is not found. +# $2 - $n: Any key=value pairs to override entries in the profile. TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../../etc/autobench.conf || . $AUTODIR/scripts/functions -# Process the arguments ###################################################### -if [ $# -lt 1 ]; then - echo "You must specify the profile to run " - exit 1 -fi +FFSB_DIR="$AUTODIR/sources/ffsb" +profile=$1 +shift -# Install support files ###################################################### -if [ ! \( -d $AUTODIR/sources/ffsb -a -x $AUTODIR/sources/ffsb/ffsb \) ]; -then - $AUTODIR/scripts/benchmarks/install/ffsb || exit 2 +if [ -z "$profile" ]; then + echo "USAGE: `basename $0` [options]+" + exit 1 fi -doprofilers install - -pushd $AUTODIR/sources/ffsb - - -numfs=1 -unset profile -unset location - -i=0 -for arg in $@ -do - echo "arg $i is $arg" - equal=$(expr index $arg "=") - if [ "$equal" -eq "0" ] ; then # this arg should be the profile - if [ ! -s "$arg" ]; then - wget -O $arg http://ausgsa.austin.ibm.com/projects/l/ltcperformance/benchmarks/ffsb/resources/profiles/$arg - if [ ! -s "$arg" ]; then - echo "Error retrieving profile, aborting" - popd - exit 1; - fi - fi - - let i=i+1 - profile=$arg - #sed -e "s/location=.*/location=\/mnt\/tmp${i}/" $base > $LOGDIR/benchmark/profile${i} - cp $profile $LOGDIR/benchmark/profile - continue - elif [ "$equal" != "0" ]; then #if there is an "=" in the arg - key=${arg%%=*} #strip off everything after the = - echo debug key is $key +# Make sure the benchmark is installed. +if [ ! -x $FFSB_DIR/ffsb ]; then + $AUTODIR/scripts/benchmarks/install/ffsb + if [ $? -ne 0 ]; then + echo "ERROR installing ffsb" + exit 1 + fi +fi - #make sure profile has been set - if [ -z "$profile" ]; then - log "Error profile must be the first argument to ffsb" - popd - exit 1; +# Get the profile for the test. If the full path to the file isn't +# given, check in $FFSB_DIR. If it's not there, check on GSA. +if [ ! -f $profile ]; then + pushd $FFSB_DIR > /dev/null + if [ ! -f $profile ]; then + wget -O $profile http://ausgsa.ibm.com/projects/l/ltcperformance/benchmarks/ffsb/resources/profiles/$profile + if [ $? -ne 0 -o ! -f $profile ]; then + echo "ERROR: Unable to retrieve profile $profile." + popd > /dev/null + exit 1 fi + fi + popd > /dev/null + profile="$FFSB_DIR/$profile" +fi +echo "Using profile $profile" +cp $profile $LOGDIR/benchmark/profile - if [ $key == "numfs" ]; then - numfs_requested=${arg##*=} - echo numfs_requested is $numfs_requested - - # if I detect more than one "location=" in the file, abort - NUMLOC=$(grep "location=" $LOGDIR/benchmark/profile | wc -l) - if [ $NUMLOC -gt 1 ] ; then - log "more than one filesystem clause detected in profile, aborting" - popd - exit 1 - fi - - numfs=$numfs_requested - - # change the num_filesystems= parameter - perl -p -i -e "s/num_filesystems=.*/num_filesystems=${numfs}/" $LOGDIR/benchmark/profile - - # make sure that the first location clause is "/mnt/tmp0" - perl -p -i -e "s/location=.*/location=\/mnt\/tmp0/" $LOGDIR/benchmark/profile - - # this is going to be a major hackjob because we have to insert the new filesystem - # clauses inbetween the filesystem0 clause and the first threadgroup :-) - - unset FS_STRING - # first build up a temp file with all the new fs clauses, then slice up the profile and rebuild it - rm -f $LOGDIR/benchmark/tmpfile - for (( j=1 ; j< $numfs ; j++)) - do - echo "[filesystem${j}]" >> $LOGDIR/benchmark/tmpfile - echo " location=/mnt/tmp${j}" >> $LOGDIR/benchmark/tmpfile - echo "[end${j}" >> $LOGDIR/benchmark/tmpfile - echo "" >> $LOGDIR/benchmark/tmpfile - done - - #cut out everything before the end of of filesystem0 into "top" - rm -f $LOGDIR/benchmark/top - grep -m 1 -B 100 'end0' $LOGDIR/benchmark/profile >> $LOGDIR/benchmark/top - - #cut out everything below threadgroup0 into "bottom" - rm -f $LOGDIR/benchmark/bottom - grep -A 100 'threadgroup0' $LOGDIR/benchmark/profile >> $LOGDIR/benchmark/bottom - - cat $LOGDIR/benchmark/top > $LOGDIR/benchmark/profile - cat $LOGDIR/benchmark/tmpfile >> $LOGDIR/benchmark/profile - cat $LOGDIR/benchmark/bottom >> $LOGDIR/benchmark/profile - - rm -f $LOGDIR/benchmark/top $LOGDIR/benchmark/tmpfile $LOGDIR/benchmark/bottom - - continue - fi +for arg in $@; do + echo "Importing argument : $arg" - #echo debug sed args $key $arg $profile - # do in-place editing of the profile - perl -p -i -e "s/${key}=.*/${arg}/" $LOGDIR/benchmark/profile + key=${arg%=*} + value=${arg#*=} + # If this argument's key matches one in the profile, + # update the profile with the new value. + if [ -n "$key" -a -n "$value" ]; then + sed -i -e "s/\b${key}=.*/${arg}/" $LOGDIR/benchmark/profile fi done -if [ $numfs -gt 1 ]; then - for ((j=0; j< $numfs; j++)) - do - mp="/mnt/tmp${j}" - fst=`mount | grep $mp` - fst=${fst##*type} - echo $fst - fst=${fst%%(*} - echo fstype is $fst - echo "fstype for /mnt/tmp${j} is $fst" >> $LOGDIR/benchmark/fstype.$RUN_NUMBER - if [ "$fst" == "" ]; then - log "No filesystem mounted to run test on, aborting!" - exit - fi - done -fi +doprofilers install watchfor "Starting Actual Benchmark" startprofilers -watchfor "Results" 'stopprofilers; doprofilers report ; doprofilers postprocess' +watchfor "Results" stopprofilers if [ -n "$GLOBAL_BARRIER_START" ]; then - barrier $GLOBAL_BARRIER_START + barrier $GLOBAL_BARRIER_START fi -$AUTODIR/sources/ffsb/ffsb $LOGDIR/benchmark/profile | tee $LOGDIR/benchmark/ffsbout.$RUN_NUMBER-1 #& +$FFSB_DIR/ffsb $LOGDIR/benchmark/profile | tee $LOGDIR/benchmark/ffsbout.$RUN_NUMBER if [ -n "$GLOBAL_BARRIER_STOP" ]; then - barrier $GLOBAL_BARRIER_STOP + barrier $GLOBAL_BARRIER_STOP fi -popd +doprofilers report +doprofilers postprocess diff --git a/scripts/benchmarks/install/ffsb b/scripts/benchmarks/install/ffsb index 2b9b626..6c473ba 100755 --- a/scripts/benchmarks/install/ffsb +++ b/scripts/benchmarks/install/ffsb @@ -1,72 +1,92 @@ #!/bin/bash # This is the script to install the ffsb program -# TMP_AUTODIR=`dirname $0` . $TMP_AUTODIR/../../../etc/autobench.conf || . $AUTODIR/scripts/functions -WEB_LOCATION="ftp://ausgsa.austin.ibm.com/projects/l/ltcperformance/2003benchmarks/ffsb/resources/ffsb-5.2.1.tar.gz" +ffsb_file="ffsb-5.2.1.tar.gz" -wget -q -O $AUTODIR/sources/ffsb-5.2.1.tar.gz $SERVER_REPO/sources/ffsb-5.2.1.tar.gz -if [ $? -ne 0 ]; then - # Didn't find it on the repo, try the web location - echo "Fetching from the network" - wget -q -O $AUTODIR/sources/ffsb-5.2.1.tar.gz $WEB_LOCATION - if [ $? -ne 0 ]; then - # Couldn't get the source -- complain - echo "WARNING: could not download the source for ffsbnew" - exit 1 - fi -fi +# Import command-line arguments. +for arg; do + echo "Importing CLI variable : ${arg}" + export ${arg}; +done -# Uncompress it pushd $AUTODIR/sources > /dev/null -rm -rf ffsbnew 2> /dev/null -DST_DIR=$(tar ztf ffsb-5.2.1.tar.gz | head -n 1 ) -tar zxf ffsb-5.2.1.tar.gz -ln -sf $DST_DIR ffsb +# If the source tarball doesn't exist, look for it on HKS. +if [ ! -f "$ffsb_file" ]; then + # Download the source tarball. + wget -O $ffsb_file $SERVER_REPO/sources/$ffsb_file + if [ $? -ne 0 ]; then + echo "ERROR: could not download the source tarball $ffsb_file from $SERVER_REPO/sources/." + exit 1 + fi +fi -# build it... -popd > /dev/null -pushd $AUTODIR/sources/ffsb > /dev/null -export CFLAGS=-D_GNU_SOURCE $CFLAGS +# Extract the tarball. +DST_DIR=$(tar ztf $ffsb_file | head -n 1) +rm -f ffsb +rm -rf $DST_DIR +tar xzf $ffsb_file +ln -s $DST_DIR ffsb -./configure -make -if [ $? -ne 0 ]; then - echo "ERROR: unable to make ffsb" - popd > /dev/null - exit 1 -fi +# Build ffsb. +pushd ffsb > /dev/null +export CFLAGS="-D_GNU_SOURCE $CFLAGS" -# if we are on a power box, then build a 64bit version -if [ "$(uname -p)" -ne "ppc64" ]; then - popd > /dev/null; - exit 0; +./configure 2>&1 | tee LOG.configure +if [ $? -ne 0 ]; then + echo "ERROR: unable to configure ffsb." + popd > /dev/null + popd > /dev/null + exit 1 fi -mv ffsb ffsb32 -export CFLAGS="-m64 $CFLAGS" -make clean -./configure -make +make 2>&1 | tee LOG.make if [ $? -ne 0 ]; then - echo "ERROR: unable to make ffsb64 bit" - popd > /dev/null - exit 1 + echo "ERROR: unable to make ffsb." + popd > /dev/null + popd > /dev/null + exit 1 fi -mv ffsb ffsb64 -ln -s ffsb64 ffsb -popd > /dev/null - - +# If we are on a power box, then build a 64bit version +if [ "$(uname -p)" != "ppc64" ]; then + popd > /dev/null + popd > /dev/null + exit 0; +fi +popd > /dev/null +cp -a $DST_DIR ${DST_DIR}-32 +mv $DST_DIR ${DST_DIR}-64 +ln -sf ${DST_DIR}-64 ffsb64 +ln -sf ${DST_DIR}-32 ffsb32 +ln -sf ffsb64 ffsb +pushd ffsd > /dev/null +export CFLAGS="-m64 $CFLAGS" +make clean +./configure 2>&1 | tee LOG.configure +if [ $? -ne 0 ]; then + echo "ERROR: unable to configure 64-bit ffsb." + popd > /dev/null + popd > /dev/null + exit 1 +fi +make 2>&1 | tee LOG.make +if [ $? -ne 0 ]; then + echo "ERROR: unable to make 64-bit ffsb." + popd > /dev/null + popd > /dev/null + exit 1 +fi +popd > /dev/null +popd > /dev/null 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/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/foreign-profiler b/scripts/profilers/foreign-profiler index aafe1b9..5e22f6c 100755 --- a/scripts/profilers/foreign-profiler +++ b/scripts/profilers/foreign-profiler @@ -1,7 +1,7 @@ #!/bin/bash # This is the script to run startprofilers or stopprofilers on a remote host. # -# reqparam value print-start|print-stop|report|postprocess +# reqparam value print-start|print-stop # reqparam value remote host name | IP address # diff --git a/scripts/profilers/install/oprofile b/scripts/profilers/install/oprofile index ada04df..274baa1 100755 --- a/scripts/profilers/install/oprofile +++ b/scripts/profilers/install/oprofile @@ -9,7 +9,7 @@ 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" +OP_VERSION="oprofile-0.9.3" # 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" diff --git a/scripts/profilers/oprofile b/scripts/profilers/oprofile index 49e36d2..1b8521b 100755 --- a/scripts/profilers/oprofile +++ b/scripts/profilers/oprofile @@ -21,7 +21,7 @@ if [ $# -eq 2 ]; then export SUFFIX fi -OP_VERSION="oprofile-0.9.4" +OP_VERSION="oprofile-0.9.3" OPCTL="$AUTODIR/sources/$OP_VERSION/dist/bin/opcontrol" OPRPT="$AUTODIR/sources/$OP_VERSION/dist/bin/opreport" OPANNT="$AUTODIR/sources/$OP_VERSION/dist/bin/opannotate" 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 3b22a50..8fe1356 100755 --- a/scripts/profilers/tools/postprocess-iostat +++ b/scripts/profilers/tools/postprocess-iostat @@ -126,7 +126,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"); @@ -256,7 +256,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