#! /usr/bin/env bash
#
# Copies $3/prof.log from the node $1, running on host $2, to the manager 

. `dirname $0`/broctl-config.sh

tag=$1
host=$2
path=$3

mkdir -p ${statsdir}/profiling

dstbase=${statsdir}/profiling/prof.$tag
tmp=$dstbase.$$.log.tmp

# Ignore errors.
scp $host:$path $tmp >/dev/null 2>&1

if [ -e $tmp ]; then
   # Rename the file to use the first non-zero timestamp in the filename. 
   ts=`awk '$1 > 0 {print $1; exit(0); }' <$tmp`
   if [ "$ts" != "" ]; then
       mv $tmp $dstbase.$ts.log
   fi
fi



