fsstats-runner.bash 963 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#!/bin/bash
#
#  (C) 2010 by Argonne National Laboratory.
#      See COPYRIGHT in top-level directory.
#

# usage: fsstats-runner.bash <hostname> <path>

# make this configurable or something...
FSSTATS_PATH=/home/pcarns/working/parallel-fsstats

if [ "${#}" != 2 ]
then
    echo "Error: bad arguments"
    exit 1
fi
HOST=${1}
FS_PATH=${2}


# the output file name will be the path that was scanned, but with equals
# signs in place of the slashes
OUT_FILE=`echo $FS_PATH | sed -e 's/\//=/g'`
OUT_FILE="${OUT_FILE}.csv"

# launch remote command
ssh -oBatchMode=yes -n $HOST "${FSSTATS_PATH}/fsstats -o /tmp/pfsstats-$$.csv $FS_PATH >& /dev/null"
if [ "${?}" != 0 ]
then
    exit 1
fi

# retrieve output file
scp -oBatchMode=yes $HOST:/tmp/pfsstats-$$.csv $OUT_FILE >& /dev/null
if [ "${?}" != 0 ]
then
    exit 1
fi

# delete file on remote host
ssh -oBatchMode=yes -n $HOST "rm -f /tmp/pfsstats-$$.csv >& /dev/null"
if [ "${?}" != 0 ]
then
    exit 1
fi

exit 0