From: brian Date: Tue, 7 Aug 2007 17:51:05 +0000 (+0000) Subject: b=11171 X-Git-Tag: v1_7_91~79 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3e9d99b9bb21276b9abcd376eb9a404429a5e369 b=11171 i=cliffw,jitendra Create a more portable way of remote shelling: - set $DSH variable to either rsh or ssh (default) The location of the results can be set with rslt_loc which defaults to /tmp. Eliminate the "scp brutal hack" needed for non-shared filesystems. A related work item could be to do a test to see if $rslt_loc is actually shared between the nodes and not use remote_shell if it is indeed shared. Specifically invoke gawk in obdfilter-survey where it uses gnu awk extensions --- diff --git a/lustre-iokit/obdfilter-survey/libecho b/lustre-iokit/obdfilter-survey/libecho index 3beeecf..4815445 100644 --- a/lustre-iokit/obdfilter-survey/libecho +++ b/lustre-iokit/obdfilter-survey/libecho @@ -30,6 +30,33 @@ declare -a vmstatpids declare -a do_unload_echo +DSH=${DSH:-"ssh"} + +dsh () { + local node="$1" + local user="$2" + shift 2 + local command="$@" + + local here=$(pwd) + + command="cd $here; export PATH=/sbin:/usr/sbin:\$PATH; $command" + + case $DSH in + ssh) + if [ -n "$user" ]; then + user="$user@" + fi + $DSH $user$node "$command" + ;; + rsh) + if [ -n "$user" ]; then + user="-l $user" + fi + $DSH $user $node "$command" + ;; + esac +} # This function executes the command sent through parameters to host # parameters # 1. hostname @@ -53,11 +80,17 @@ custom_remote_shell () { remote_shell () { host=$1 shift - cmds="$*" + cmds="$@" if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then eval "$cmds" else - custom_remote_shell $host "$cmds" + # split $host into $host and $user + local user="" + if [[ $host == *@* ]]; then + user=${host%@*} + host=${host#*@} + fi + dsh $host "$user" "$cmds" fi } diff --git a/lustre-iokit/obdfilter-survey/obdfilter-survey b/lustre-iokit/obdfilter-survey/obdfilter-survey index 2d85b8f..b2abaeb 100755 --- a/lustre-iokit/obdfilter-survey/obdfilter-survey +++ b/lustre-iokit/obdfilter-survey/obdfilter-survey @@ -99,7 +99,7 @@ destroy_objects () { get_stats () { local rfile=$1 - awk < $rfile \ + gawk < $rfile \ '/^Selected device [0-9]+$/ {n = 0; next}\ /error/ {n = -1; exit}\ /^[0-9]+\/[0-9]+ Total: [0-9]+\.[0-9]+\/second$/ {n++; v=strtonum($3); \ @@ -175,7 +175,8 @@ fi # result file prefix (date/time + hostname makes unique) # NB ensure path to it exists -rslt=${rslt:-"/tmp/obdfilter_survey_`date +%F@%R`_`uname -n`"} +rslt_loc=${rslt_loc:-"/tmp"} +rslt=${rslt:-"$rslt_loc/obdfilter_survey_`date +%F@%R`_`uname -n`"} # what tests to run (first must be write) tests_str=${tests_str:-""} @@ -263,7 +264,7 @@ if [ $case == "network" ]; then echo "Specify the server NID" exit 1; fi - osc_names_string=`ssh root@"$server_nid" lctl dl` + osc_names_string=`dsh $server_nid root "lctl dl"` count=0; for name in $osc_names_str; do count=$((count+1)) @@ -275,7 +276,7 @@ if [ $case == "network" ]; then fi # Now do the server setup setup_srv_obd $server_nid "ost_testfs" - op_string=`ssh root@"$server_nid" lctl dl` + op_string=`dsh $server_nid root "lctl dl"` obdecho=0 ost=0 @@ -481,9 +482,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do t0=`date +%s.%N` pidcount=0 for host in ${unique_hosts[@]}; do - # brutal hack to deal with a non-shared /tmp - scp -q ${cmdsf}_${host} ${host}:/tmp > /dev/null - remote_shell $host bash ${cmdsf}_${host} & + remote_shell $host bash < ${cmdsf}_${host} & pidarray[$pidcount]=$! pidcount=$((pidcount+1)) done @@ -509,8 +508,7 @@ for ((rsz = $rszlo; rsz <= $rszhi; rsz*=2)); do tmpfi="${tmpf}_$idx" echo "=============> $test $client_name" >> $workf host="${host_names[$idx]}" - scp -q ${host}:$tmpfi $tmpfi > /dev/null - cat $tmpfi >> $workf + remote_shell $host cat $tmpfi >> $workf get_stats $tmpfi >> $tmpf rm $tmpfi done