@@ -62,76 +62,28 @@ function usage {
6262}
6363
6464function metadata_log_tools {
65- log=$1
65+ local log=$1
6666
67- if [ -d $pbench_run /tools-$group ] ; then
68- metadata_log_tools_dir $log
69- else
70- metadata_log_tools_file $log
71- fi
72- }
73-
74- function metadata_log_tools_file {
75- # This is provided for backwards compatibility.
76- # v0.35 introduced the tools-<group> directory: if that
77- # directory exists, we assume that it is authoritative.
78- # If it does not, we fall back to the tools.<group> file.
79-
80- # Get the remotes from the local tools.$group file
81- # then get the remote tools.$group files for each remote
82-
83- remotes=" $( grep @ $pbench_run /tools.$group | sed ' s/.*@//
67+ # get the remotes from the local tools-$group directory
68+ # then get the remote tools-$group dirs for each remote
69+ local remotes=" $( /bin/ls $pbench_run /tools-$group / 2> /dev/null | grep @ | sed ' s/.*@//
8470s/:[^:]*$//' | tr ' \n' ' ' ) "
85-
86- # check if the local tools.$group file includes any local tools
87- local=0
88- if grep -v @ $pbench_run /tools.$group > /dev/null 2>&1 ; then
89- local=1
90- fi
9171
92- # if yes ...
93- if [ $local == 1 ] ; then
94- cat >> $log << EOF
95- [tools]
96- hosts: $hostname $remotes
97-
98- [tools/$hostname ]
99- $( cat $pbench_run /tools.$group )
100-
101- EOF
102- else
103- # just remotes
104- if [ ! -z " $remotes " ] ; then
105- cat >> $log << EOF
106- [tools]
107- hosts: $remotes
108-
109- EOF
110- fi
111- fi
112-
72+ # the remotes may have different names than what the controller uses,
73+ # so go ask them - the names of the remotes in the metadata log have to
74+ # agree with the names of the remotes used when postprocessing the tool
75+ # results, otherwise the indexing will fail.
76+ local rems=" "
11377 for remote in $remotes ; do
114- cat >> $log << EOF
115- [tools/$remote ]
116- $( ssh $ssh_opts $remote cat $pbench_run /tools.$group )
117-
118- EOF
78+ # if the ssh fails, just leave the name alone
79+ rem=$( ssh $ssh_opts -n $remote hostname -s 2> /dev/null || echo $remote )
80+ rems=" $rems $rem "
11981 done
120- }
121-
122- function metadata_log_tools_dir {
123- # we have a tools-<group> dir.
124-
125- log=$1
126- # get the remotes from the local tools-$group directory
127- # then get the remote tools-$group dirs for each remote
128-
129- remotes=" $( ls $pbench_run /tools-$group / | grep @ | sed ' s/.*@//
130- s/:[^:]*$//' | tr ' \n' ' ' ) "
82+ remotes=$rems
13183
13284 # check if the local tools-$group directory includes any local tools
13385 local=0
134- if /bin/ls $pbench_run /tools-$group | grep -q -v " ^remote@" ; then
86+ if /bin/ls $pbench_run /tools-$group 2> /dev/null | grep -q -v " ^remote@" ; then
13587 local=1
13688 fi
13789
@@ -140,10 +92,11 @@ s/:[^:]*$//' | tr '\n' ' ')"
14092 cat >> $log << EOF
14193[tools]
14294hosts: $hostname $remotes
95+ group: $group
14396
14497[tools/$hostname ]
14598EOF
146- for tool in $( /bin/ls $pbench_run /tools-$group ) ; do
99+ for tool in $( /bin/ls $pbench_run /tools-$group 2> /dev/null ) ; do
147100 # add the options with a space in front, effectively making them continuation
148101 # lines as far the python config module is concerned.
149102 echo $tool : $( cat $pbench_run /tools-$group /$tool | sed ' s/^/ /' )
155108 cat >> $log << EOF
156109[tools]
157110hosts: $remotes
111+ group: $group
158112
159113EOF
160114 fi
@@ -172,12 +126,13 @@ EOF
172126}
173127
174128function metadata_log_start {
175- dir=$1
176- ts=$2
177- log=$dir /metadata.log
129+ local dir=$1
130+ local group=$2
131+ local ts=$3
132+ local log=$dir /metadata.log
178133
179134 if [ -z " $ts " ] ; then
180- ts=$( date --utc ' +%F_%H:%M:%S.%N ' )
135+ ts=$( timestamp )
181136 fi
182137 cat > $log << EOF
183138[pbench]
@@ -188,7 +143,7 @@ date: $date
188143rpm-version: $( yum list installed pbench-agent 2> /dev/null | tail -n 1 | awk ' {print $2}' )
189144
190145EOF
191- metadata_log_tools $log
146+ metadata_log_tools $log $group
192147 cat >> $log << EOF
193148[run]
194149controller: $full_hostname
@@ -197,21 +152,22 @@ EOF
197152}
198153
199154function metadata_log_end {
200- dir=$1
201- int=$2
202- log=$dir /metadata.log
155+ local dir=$1
156+ local group=$2
157+ local int=$3
158+ local log=$dir /metadata.log
203159
204160 if [ ! -f $log ] ; then
205161 # Somehow, metadata_log_start was never called !?!?
206162 # Call it explicitly.
207163 # Manufacture a start_run timestamp and pass it
208164 # explicitly. The manufactured stamp is the date that
209165 # the base file calculates (now in UTC).
210- start_ts=$date
211- metadata_log_start $dir $start_ts
166+ local start_ts=$( timestamp )
167+ metadata_log_start $dir $group $ start_ts
212168 fi
213169 if ! grep -q end_run $log ; then
214- echo " end_run: $( date --utc ' +%F_%H:%M:%S.%N ' ) " >> $log
170+ echo " end_run: $( timestamp ) " >> $log
215171 fi
216172 if [ " $int " == " int" ] ; then
217173 echo " run_interrupted: true" >> $log
@@ -221,13 +177,17 @@ function metadata_log_end {
221177mkdir -p $dir
222178case $1 in
223179 beg)
224- metadata_log_start $dir
180+ metadata_log_start $dir $group
225181 ;;
226182 end)
227- metadata_log_end $dir
183+ metadata_log_end $dir $group
184+ name=$( basename $dir )
185+ if [ -f $pbench_tmp /$name .iterations ] ; then
186+ pbench-add-metalog-option $pbench_tmp /$name .iterations $dir /metadata.log iterations
187+ fi
228188 ;;
229189 int)
230- metadata_log_end $dir int
190+ metadata_log_end $dir $group int
231191 ;;
232192 * )
233193 usage
0 commit comments