Changeset 9585 for trunk/MagicSoft/Mars/datacenter
- Timestamp:
- 06/11/10 17:36:11 (15 years ago)
- Location:
- trunk/MagicSoft/Mars/datacenter/scripts
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
r9539 r9585 37 37 function nextscript() 38 38 { 39 echo `date +%F\ %T`" sleeping \$$1 = $ sleeptimeseconds... " >> $jmscriptlog 2>&139 echo `date +%F\ %T`" sleeping \$$1 = $2 seconds... " >> $jmscriptlog 2>&1 40 40 sleep $2 41 41 echo "" >> $jmscriptlog 2>&1 … … 88 88 89 89 # check if there's something to do 90 column=${scriptscolname[$i]}90 step=${scriptscolname[$i]} 91 91 getstepinfo 92 92 if [ "$noderestricted" = "yes" ] … … 126 126 127 127 # check number of processes to be done 128 echo `date +%F\ %T`" Database: $numproc ${scripts[$i]} still to be done (incl. idle jobs) [DB/ table/column $db/$table/$column]" >> $jmscriptlog 2>&1128 echo `date +%F\ %T`" Database: $numproc ${scripts[$i]} still to be done (incl. idle jobs) [DB/step $db/$step]" >> $jmscriptlog 2>&1 129 129 if [ "$numproc" = "0" ] 130 130 then -
trunk/MagicSoft/Mars/datacenter/scripts/runcorsika
r9355 r9585 18 18 # 19 19 # 20 # Author(s): Daniela Dorner 05/2007 <mailto:d orner@astro.uni-wuerzburg.de>21 # 22 # Copyright: MAGIC Software Development, 2000-20 0820 # Author(s): Daniela Dorner 05/2007 <mailto:daniela.dorner@unige.ch> 21 # 22 # Copyright: MAGIC Software Development, 2000-2010 23 23 # 24 24 # … … 31 31 printprocesslog "INFO starting $0" 32 32 program=corsika 33 column=fCorsikaFileAvail 33 step=Corsika 34 34 35 35 set -C … … 41 41 { 42 42 # Run number 43 echo "RUNNR "$ corsikarunno43 echo "RUNNR "$file 44 44 # Starting event number 45 45 echo "EVTNR 1" … … 60 60 echo "FIXCHI "$startalt 61 61 # Observation level, magnetic field, atmosphere 62 echo "OBSLEV 2200.E2"62 echo "OBSLEV "$obslev".E2" 63 63 # From www.noaa.gov/geomagmodels roughly for January 2009. (was 29.5 and 23.0) 64 64 # MAGNET BX BZ (BX is the horizontal component (muT) to the x-direction of 65 65 # the detector, BZ is the vertical component (muT) downwards) 66 echo "MAGNET 30.3 24.1"66 echo "MAGNET "$magnet 67 67 # Rotation angle between array x-direction and magnetic north direction 68 68 # positive if array x-direction points to the west 69 echo "ARRANG -7.0"69 echo "ARRANG "$magnetrot 70 70 # Atmosphere (model, true/false for atmospheric refraction of cer-photons) 71 71 # Atmosphere read from atmprof11.dat 72 72 # My current understanding is that only refraction (bending of light 73 73 # but no absorption of photons is taken into account) setting T. 74 echo "ATMOSPHERE 11 T" 74 echo "ATMOSPHERE "$atm" T" 75 76 # Current boundaries in reflector program 77 # echo "ATMLAY 400000 1000000 4000000 10000000" 78 79 # Boundaries as determined by CORSIKA 80 # Until we can read the result from the corsika fit we fix the 81 # values which come out of the fit. This is not ideal but forces 82 # things to be consistent. Be careful is using a different model - 83 # the fit might not be ideal. 84 echo "ATMLAY 775000 1650000 5000000 10500000" 85 75 86 # Other parameters 76 87 echo "RADNKG 200.E2" … … 82 93 # Enable muon multiple scattering 83 94 echo "MUMULT T" 84 # Cherenkov telescope options 85 echo "CWAVLG 290. 600." 86 echo "CSCAT "$reuse" 0. "$impactmax 95 # Wavelength range (was originally 600) 96 echo "CWAVLG "$wavelengths 97 # MMCS 98 echo "CSCAT 1 0. "$impactmax 99 # CORSIKA 100 # echo "CSCAT "$reuse" "$impactmax" 0." 87 101 echo "CERSIZ 1." 102 # Write Cherenkov photons to cer-file 88 103 echo "CERFIL T" 104 # Number of telescopes 89 105 echo "CERTEL 1" 90 echo " 0. 0. 0. 0. 0. "$diameter" 1700." 106 # MMCS 107 echo " 0. 0. 0. 0. 0. "$diameter" "$diameter 108 # CORSIKA (x, y, z, r) 109 # echo "TELESCOPE 0. 0. 0. "$diameter 110 # This keyword has no relevance but allows to store the 111 # maximum simulated impact parameter. The "magic" is that 112 # ceres interpretes the third and fourth argument as 113 # maximum simulated impact if they are identical and 114 # the other four arguments are 1 115 # echo "CERARY 1 1 "$diameter" "$diameter" 1 1" 91 116 # How the longitudinal shower development is sampled 92 117 # echo "LONGI T 10. T F" … … 103 128 # Output path 104 129 echo "DIRECT "$outpath 105 # User and host (for convinience) 130 # DIRECT /dev/null 131 # TELFIL filename 132 # TELFIL | gzip 133 # TELESCOPE X Y Z R 134 # User and host (for convenience) 106 135 echo "USER "`whoami` 107 136 echo "HOST "`hostname` … … 114 143 gettodo "1" 115 144 run=${primaries[0]} 116 # get corsika runno 117 query="SELECT fCorsikaRunNumber FROM MCRunData where fMCRunNumber="$run 118 # to be changed later again, when additional tables are available 119 #corsikarunno=`sendquery` 120 corsikarunno=$run 145 file=${primaries[1]} 121 146 122 147 # lock sequ 123 lockfile=$lockpath/lock-$ table-$column-$corsikarunno.txt148 lockfile=$lockpath/lock-$step-$run.$file.txt 124 149 checklock 125 150 126 printprocesslog "INFO starting $program for run $run "151 printprocesslog "INFO starting $program for run $run and file $file" 127 152 128 153 setstatus "start" 129 154 130 printprocesslog "INFO run $program for run $run "131 printprocesslog "INFO create input card ..."155 printprocesslog "INFO run $program for run $run and file $file" 156 printprocesslog "INFO create input card for run $run and file $file" 132 157 133 158 # get values for inputcard 134 query="SELECT fParticleTypeKEY FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno159 query="SELECT fParticleTypeKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 135 160 primparticle=`sendquery` 136 query="SELECT fEnergyMin, fEnergyMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno161 query="SELECT fEnergyMin, fEnergyMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 137 162 erange=`sendquery` 138 query="SELECT fNumEvents FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno163 query="SELECT fNumEvents FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 139 164 numevts=`sendquery` 140 query="SELECT fEnergySlope FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno165 query="SELECT fEnergySlope FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 141 166 slope=`sendquery` 142 query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno167 query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 143 168 zdrange=`sendquery` 144 169 # Change from the MARS definition (Az=90 -> East) to Corsika (Az=90 -> West) 145 query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno170 query="SELECT 180-fAzimuthMin, 180-fAzimuthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 146 171 azrange=`sendquery` 147 query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno 148 date=`sendquery` 149 outpath=$mcpath"/"$program"/"$date 150 query="SELECT fCorsikaSeed FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno 172 query="SELECT fCorsikaSeed1 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 151 173 seed1=`sendquery` 152 query="SELECT fCorsikaSeed +1 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno174 query="SELECT fCorsikaSeed2 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 153 175 seed2=`sendquery` 154 query="SELECT fCorsikaSeed +2 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno176 query="SELECT fCorsikaSeed3 FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 155 177 seed3=`sendquery` 156 query="SELECT fImpactMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno178 query="SELECT fImpactMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 157 179 impactmax=`sendquery` 158 query="SELECT fViewConeMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno180 query="SELECT fViewConeMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 159 181 viewconemax=`sendquery` 160 query="SELECT fNumReUseShower FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno 161 reuse=`sendquery` 162 query="SELECT fStartingAltitude FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno 182 query="SELECT fStartingAltitude FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 163 183 startalt=`sendquery` 164 query="SELECT fMirrorDiameter FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno184 query="SELECT fMirrorDiameter FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 165 185 diameter=`sendquery` 166 167 logfile=$outpath/$program"-"`printf %06d $corsikarunno`".log" 186 query="SELECT fAtmosphericModelKEY FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 187 atm=`sendquery` 188 query="SELECT fObsLevel FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file" 189 obslev=`sendquery` 190 query="SELECT fMagnetBX, fMagnetBZ FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file" 191 magnet=`sendquery` 192 query="SELECT fMagnetRotation FROM CorsikaInfo LEFT JOIN Observatory USING(fObservatoryKEY) WHERE fRunNumber=$run AND fFileNumber=$file" 193 magnetrot=`sendquery` 194 query="SELECT fWavelengthMin, fWavelengthMax FROM CorsikaInfo WHERE fRunNumber=$run AND fFileNumber=$file" 195 wavelengths=`sendquery` 196 197 outpath=$mcpath"/"$program"/"`printf %08d $run | cut -c 0-4`/`printf %08d $run | cut -c 5-8` 168 198 makedir $outpath 199 logfile=$outpath/cer000`printf %06d $file | cut -c 4-6`".log" 169 200 170 201 cd $corsikapath 171 202 172 echo "INPUTCARD:" >| $logfile 2>&1 173 printinputcard >> $logfile 2>&1 174 echo "" >> $logfile 2>&1 175 echo "" >> $logfile 2>&1 176 printinputcard | ./cc6501p-linux >> $logfile 2>&1 177 178 rm -f $outpath/dat`printf %06d $corsikarunno` 203 printinputcard | ./cc6501p-linux >| $logfile 2>&1 179 204 180 205 check1=$? 181 182 206 case $check1 in 183 0) printprocesslog "INFO $program finished successfully for corsika run number $corsikarunno(check1=$check1)"207 0) printprocesslog "INFO $program finished successfully for run $run file $file (check1=$check1)" 184 208 ;; 185 *) printprocesslog "ERROR $program failed for corsika run number $corsikarunno(check1=$check1)"209 *) printprocesslog "ERROR $program failed for run $run file $file (check1=$check1)" 186 210 com=$Fcorsika 187 211 check=$check1 … … 189 213 esac 190 214 215 # removing empty datnnnnnn file 216 rm -f $outpath/dat`printf %06d $file` 217 191 218 setstatus "stop" 192 219 -
trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
r9543 r9585 20 20 # Author(s): Daniela Dorner 05/2005 <mailto:dorner@astro.uni-wuerzburg.de> 21 21 # 22 # Copyright: MAGIC Software Development, 2000-20 0722 # Copyright: MAGIC Software Development, 2000-2010 23 23 # 24 24 # … … 209 209 } 210 210 211 function resetstatusvalues() 212 { 213 statustime=NULL 214 starttime=NULL 215 returncode=NULL 216 programid=NULL 217 failedtime=NULL 218 } 219 211 # print the current status values 220 212 function printstatusvalues() 221 213 { 222 214 echo "the current values are:" 223 echo " statustime=$statustime"224 215 echo " starttime=$starttime" 216 echo " stoptime=$stoptime" 225 217 echo " returncode=$returncode" 226 echo " programid=$programid"227 echo " failedtime=$failedtime"228 218 echo "-- check: -$check-" 229 219 echo "" 230 220 } 231 221 232 # function evaluating the statusvalues 233 function evalstatus() 234 { 235 case $@ in 236 start) printprocesslog "INFO setstatus start" 237 starttime="Now()" 238 ;; 239 stop) case $check in 240 ok) printprocesslog "INFO setstatus stop - ok" 241 statustime="Now()" 242 ;; 243 no) printprocesslog "INFO setstatus stop - nothing new" 244 check="ok" 245 ;; 246 *) printprocesslog "INFO setstatus stop - failed" 247 starttime=noreset 248 if [ "$check" == "" ] 249 then 250 returncode=1 251 else 252 returncode=$check 253 fi 254 programid=$com 255 failedtime="Now()" 256 check="ok" 257 ;; 258 esac 259 ;; 260 *) printprocesslog "ERROR function evalstatus got wrong variable" 261 finish 262 ;; 263 esac 264 } 265 222 # get the db-setup from the sql.rc 266 223 function getdbsetup() 267 224 { … … 277 234 } 278 235 236 # function to get the needed information from the dependencies-file steps.rc 279 237 function getstepinfo() 280 238 { 281 239 getdbsetup 282 table=`grep "$column:" $steps | sed -e "s/[.]$column://" -e 's/#//' -e 's/ //g'` 283 coltab=`grep "$column:" $steps | sed -e 's/://' -e 's/#//' -e 's/ //g'` 284 needs=`grep "$coltab[.]Needs:" $steps | sed -e "s/$coltab[.]Needs://"` 285 noderestricted=`grep "$coltab[.]NodeRestricted:" $steps | sed -e "s/$coltab[.]NodeRestricted://" -e 's/ //g'` 286 influences=`grep "$coltab[.]Influences:" $steps | sed -e "s/$coltab[.]Influences://"` 287 prims=( `grep "$table[.]Primary:" $steps | sed -e "s/$table[.]Primary://"` ) 288 # echo " column $column - table $table - coltab $coltab" 240 needs=`grep "$step[.]Needs:" $steps | sed -e "s/$step[.]Needs://"` 241 noderestricted=`grep "$step[.]NodeRestricted:" $steps | sed -e "s/$step[.]NodeRestricted://" -e 's/ //g'` 242 prims=( `grep "$step[.]Primaries:" $steps | sed -e "s/$step[.]Primaries://"` ) 289 243 # echo " needs: $needs" 290 # echo " influences: $influences"291 244 # echo " noderestricted: $noderestricted" 292 245 # echo " prims: ${prims[@]}" 293 246 } 294 247 248 # function to get the primaries of a step from the dependencies-file steps.rc 249 function getprimary() 250 { 251 getdbsetup 252 grep $@"[.]Primaries:" $steps | sed -e "s/$@[.]Primaries://" 253 } 254 255 # function to get the join of a step from the dependencies-file steps.rc 256 function getjoin() 257 { 258 getdbsetup 259 grep $@"[.]Join:" $steps | sed -e "s/$@[.]Join://" 260 } 261 262 # function to create the middle part of a query 263 # which is identical for the functions getstatus() and gettodo() 264 function middlepartofquery() 265 { 266 # add from which table the information is queried 267 query=$query" FROM "$step"Status " 268 # add the joins to the tables in which the status of the preceding steps is stored 269 for need in $needs 270 do 271 needprims=( `getprimary $need` ) 272 if [ "`echo ${needprims[@]}`" == "`echo ${prims[@]}`" ] 273 then 274 query=$query" LEFT JOIN "$need"Status USING (${prims[@]}) " 275 fi 276 done 277 # add condition 278 query=$query" WHERE " 279 # add condition for the status of the peceding steps 280 counter=0 281 for need in $needs 282 do 283 if [ $counter -gt 0 ] 284 then 285 query=$query" AND " 286 fi 287 needprims=( `getprimary $need` ) 288 # in case the primaries of the tables agree 289 # only the condition is given 290 # for tables with differing primaries a special query 291 # is needed 292 if [ "`echo ${needprims[@]}`" == "`echo ${prims[@]}`" ] 293 then 294 query=$query" NOT ISNULL("$need"Status.fStartTime) AND " 295 query=$query" NOT ISNULL("$need"Status.fStopTime) AND " 296 query=$query" ISNULL("$need"Status.fReturnCode) " 297 else 298 query=$query" (SELECT COUNT(*) FROM "$need"Status " 299 query=$query" "`getjoin $need`" " 300 query=$query" WHERE "$step"Status."`echo ${prims[0]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[0]} | sed -e 's/,//g'` 301 for (( j=1 ; j < ${#prims[@]} ; j++ )) 302 do 303 query=$query" AND "$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'` 304 done 305 query=$query") = (SELECT COUNT(*) FROM "$need"Status " 306 query=$query" "`getjoin $need`" " 307 query=$query" WHERE "$step"Status."`echo ${prims[0]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[0]} | sed -e 's/,//g'` 308 for (( j=1 ; j < ${#prims[@]} ; j++ )) 309 do 310 query=$query" AND "$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'`"="$step"Status."`echo ${prims[$j]} | sed -e 's/,//g'` 311 done 312 query=$query" AND NOT ISNULL(fStartTime) " 313 query=$query" AND NOT ISNULL(fStopTime) " 314 query=$query" AND ISNULL(fReturnCode)) " 315 fi 316 counter=`echo $counter + 1 | bc -l` 317 done 318 # add condition for the status of the step itself 319 query=$query" AND ISNULL("$step"Status.fStartTime) " 320 query=$query" AND ISNULL("$step"Status.fStopTime) " 321 query=$query" AND ISNULL("$step"Status.fReturnCode) " 322 } 323 295 324 # function to get todolist 325 # returns the next or the list of next steps 296 326 function gettodo() 297 327 { 328 # reset the variable for the number of the next step 298 329 process= 299 330 printprocesslog "INFO getting todo..." 300 331 getstepinfo 301 332 # get query 302 query=" SELECT " ${prims[0]}303 for (( i=1 ; i < ${#prims[@]} ; i++ ))333 query=" SELECT "`echo ${prims[0]} | sed -e 's/,//g'` 334 for (( j=1 ; j < ${#prims[@]} ; j++ )) 304 335 do 305 query=$query", ${prims[$i]}"336 query=$query", "`echo ${prims[$j]} | sed -e 's/,//g'` 306 337 done 307 query=$query" FROM $table WHERE " 308 if ! echo $needs | grep '#' > /dev/null 309 then 310 for need in $needs 311 do 312 query=$query" NOT ISNULL($need) AND" 313 done 314 fi 315 query=$query" ISNULL($column) " 338 # get middle par of query 339 middlepartofquery 340 # add requirement for production host in case it is needed 316 341 if [ "$2 " != " " ] 317 342 then 318 343 query=$query" AND fProductionHostKEY=$2 " 319 344 fi 320 query=$query" AND ISNULL(fStartTime) AND ISNULL(fFailedTime) AND ISNULL(fProgramId) AND ISNULL(fReturnCode) " 321 query=$query" ORDER BY fPriority desc " 345 # order by priority to the the number of the next step to be done 346 query=$query" ORDER BY "$step"Status.fPriority desc " 347 # add limitation in case only one or a limited number of 348 # processes should be executed 322 349 if [ "$1 " != " " ] 323 350 then 324 351 query=$query" limit 0, $1 " 325 352 fi 326 # echo " QUERY: "$query 353 # print query 354 echo " gettodo QUERY: "$query 327 355 printprocesslog "INFO gettodo QUERY: "$query 356 # execute query 328 357 if ! process=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "` 329 358 then … … 331 360 finish 332 361 fi 333 362 # get numbers of next step from mysql result 334 363 if [ "$process" = "" ] 335 364 then … … 342 371 } 343 372 344 345 373 # function to get the number of processes which still have to be done 346 374 function getstatus() 347 375 { 376 # reset the variable for the number of steps to be done 348 377 numproc= 349 378 getstepinfo 350 379 # get query 351 query=" SELECT COUNT(*) FROM $table WHERE " 352 if ! echo $needs | grep '#' > /dev/null 353 then 354 for need in $needs 355 do 356 query=$query" NOT ISNULL($need) AND" 357 done 358 fi 359 query=$query" ISNULL($column) " 380 query=" SELECT COUNT(*), 1 " # the 1 is just for grouping 381 # get middle part of query 382 middlepartofquery 383 # add requirement for production host in case it is needed 360 384 if [ "$1 " != " " ] 361 385 then 362 386 query=$query" AND fProductionHostKEY=$1 " 363 387 fi 364 query=$query" AND ISNULL(fStartTime) AND ISNULL(fFailedTime) AND ISNULL(fProgramId) AND ISNULL(fReturnCode) " 365 query=$query" GROUP BY $column " 366 # echo "QUERY: "$query 388 # group by an 'artifical' column to get the number of lines 389 query=$query" GROUP BY 2 " 390 # printing query 391 echo " getstatus QUERY: "$query 367 392 printprocesslog "INFO getstatus QUERY: "$query 368 if ! numproc=`mysql -s -u $us --password=$pw --host=$ho $db -e " $query "` 393 # execute query 394 if ! numprocs=( `mysql -s -u $us --password=$pw --host=$ho $db -e " $query "` ) 369 395 then 370 396 printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus)" … … 372 398 continue 373 399 fi 374 if [ "$numproc" = "" ] 400 # get number of processes from mysql result 401 if [ "${numprocs[1]}" = "" ] 375 402 then 376 403 numproc=0 404 else 405 numproc=${numprocs[0]} 377 406 fi 378 407 } … … 381 410 function setstatus() 382 411 { 383 if [ "$column" = "no" ] 412 # remark: 413 # this function does not include the 'Default' flag 414 # for resetting steps 415 416 # for dowebplots (there are steps which have no entry in the DB) 417 if [ "$step" = "no" ] 384 418 then 385 419 return 386 420 fi 387 resetstatusvalues 388 evalstatus $@ 421 422 # reset status values 423 starttime=NULL 424 stoptime=NULL 425 returncode=NULL 426 # evaluate the status values 427 case $@ in 428 start) printprocesslog "INFO setstatus start" 429 starttime="Now()" 430 ;; 431 stop) case $check in 432 ok) printprocesslog "INFO setstatus stop - ok" 433 starttime=noreset 434 stoptime="Now()" 435 ;; 436 no) printprocesslog "INFO setstatus stop - nothing new" 437 check="ok" 438 ;; 439 *) printprocesslog "INFO setstatus stop - failed" 440 starttime=noreset 441 stoptime="Now()" 442 if [ "$check" == "" ] 443 then 444 returncode=1 445 else 446 returncode=$check 447 fi 448 check="ok" 449 ;; 450 esac 451 ;; 452 *) printprocesslog "ERROR function setstatus got wrong variable" 453 finish 454 ;; 455 esac 456 # get 389 457 getstepinfo 458 459 # get the influences from the steps.rc by evaluating the needs of all steps 460 influences=`grep $step $rc | grep "Needs" | grep -v "$step[.]Needs" | cut -d'.' -f1` 461 390 462 # get query 391 reset=`grep "$coltab[.]Reset:" $steps | sed -e "s/$coltab[.]Reset://" -e 's/ //g'` 392 if [ "$reset" = "no" ] 393 then 394 printprocesslog "ERROR You cannot reset $column for ${primaries[$s+$s]}" 395 finish 396 fi 397 query=" update $table set $column=$statustime" 398 if ! echo $influences | grep '#' > /dev/null 399 then 400 for influence in $influences 401 do 402 query=$query", $influence=NULL" 403 done 404 fi 463 query=" UPDATE "$step"Status " 464 # add joins to the influenced tables 465 for influence in $influences 466 do 467 query=$query" LEFT JOIN $influence USING("`getprimary $influence`") " 468 specialjoin=`getjoin $influence` 469 if ! [ "$specialjoin" = "" ] 470 then 471 query=$query$specialjoin 472 fi 473 done 474 # set the status values according to the new status of the step 475 query=$query" SET " 405 476 if ! [ "$starttime" = "noreset" ] 406 477 then 407 query=$query", fStartTime=$starttime" 408 fi 409 query=$query", fFailedTime=$failedtime, fProgramId=$programid, fReturnCode=$returncode " 410 query=$query" where " 478 query=$query" "$step"Status.fStartTime=$starttime, " 479 fi 480 query=$query" "$step"Status.fStopTime=$stoptime, "$step"Status.fReturnCode=$returncode " 481 # set also the status values of the influenced steps 482 for influence in $influences 483 do 484 query=$query", "$influence"Status.fStartTime=NULL " 485 query=$query", "$influence"Status.fStopTime=NULL " 486 query=$query", "$influence"Status.fReturnCode=NULL " 487 done 488 # give the condition for which step the status values have to be set 489 query=$query" WHERE " 411 490 if [ "$s" = "" ] 412 491 then 413 492 s=0 414 493 fi 415 query=$query" ${prims[0]}='${primaries[$s*${#prims[@]}]}'"416 for (( i=1 ; i < ${#prims[@]} ; i++ ))494 query=$query" "`echo ${prims[0]} | sed -e 's/,//g'`"='${primaries[$s*${#prims[@]}]}'" 495 for (( j=1 ; j < ${#prims[@]} ; j++ )) 417 496 do 418 query=$query" AND ${prims[$i]}='${primaries[$s*${#prims[@]}+$i]}' "497 query=$query" AND "`echo ${prims[$j]} | sed -e 's/,//g'`"='${primaries[$s*${#prims[@]}+$j]}' " 419 498 done 420 # echo " QUERY: "$query 499 # print query 500 echo " setstatus QUERY: "$query 421 501 printprocesslog "INFO setstatus QUERY: "$query 502 # execute query 422 503 if ! mysql -s -u $us --password=$pw --host=$ho $db -e " $query " 423 504 then … … 425 506 finish 426 507 fi 427 428 508 } 429 509
Note:
See TracChangeset
for help on using the changeset viewer.