Changeset 19198
- Timestamp:
- 08/31/18 17:16:24 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Sourcefile.sh
r18784 r19198 173 173 } 174 174 175 # get the db-setup from the sql.rc176 function getdbsetup()177 {178 db=`grep Database $sqlrc | grep -v '#' | sed -e 's/Database: //' -e 's/ //g'`179 pw="--password="`grep Password $sqlrc | grep -v '#' | sed -e 's/Password: //' -e 's/ //g'`180 us=`grep User $sqlrc | grep -v '#' | sed -e 's/User: //' -e 's/ //g'`181 ho=`grep URL $sqlrc | grep -v '#' | sed -e 's/ //g' -e 's/URL:mysql:\/\///'`182 if [ "$sqlpw" != "" ]183 then184 sqlpwfile="--defaults-file=$sqlpw"185 pw=""186 fi187 # echo "setup: "188 # echo " db: "$db189 # echo " pw: "$pw190 # echo " us: "$us191 # echo " ho: "$ho192 }193 194 175 # function to send a mysql query 195 176 function sendquery() 196 177 { 197 getdbsetup178 #getdbsetup 198 179 printprocesslog "DEBUG sendquery QUERY: "$query 199 val=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db-e " $query " 2>&1`180 val=`mysql --defaults-file=$sqlrc -s -e " $query " 2>&1` 200 181 checkmysql=`echo $?` 201 182 if [ $checkmysql -gt 0 ] 202 183 then 203 printprocesslog "ERROR could not query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) "184 printprocesslog "ERROR could not query DB (program: $program, function sendquery, mysqlsetup $sqlrc) " 204 185 printprocesslog "MYSQLERROR [returncode: "$checkmysql"] "$val 205 186 error=`echo $val | grep -E -o 'ERROR [1-9]{1,4}' | grep -E -o '[1-9]{1,4}'` 206 187 # here possible reaction to mysql error 207 if [ $error -eq 1213 ] 188 if [ $error -eq 1213 ] || [ $error -eq 1205 ] 208 189 then 209 printprocesslog "WARN Deadlock found. Should resend query."190 #printprocesslog "WARN Deadlock found. Should resend query." 210 191 printprocesslog "DEBUG sendquery QUERY: [2nd try] "$query 211 val=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db-e " $query " 2>&1`192 val=`mysql --defaults-file=$sqlrc -s -e " $query " 2>&1` 212 193 checkmysql2=`echo $?` 213 194 if [ $checkmysql2 -gt 0 ] 214 195 then 215 printprocesslog "ERROR could not query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) [2nd try]"196 printprocesslog "ERROR could not query DB (program: $program, function sendquery, mysqlsetup $sqlrc) [2nd try]" 216 197 printprocesslog "MYSQLERROR [returncode: "$checkmysql"] "$val" [2nd try]" 217 198 error2=`echo $val | grep -E -o 'ERROR [1-9]{1,4}' | grep -E -o '[1-9]{1,4}'` … … 233 214 if [ "$warning" != "" ] 234 215 then 235 printprocesslog "WARN possible problem to query DB "$db" on host "$ho" with user "$us" (program: $program, function sendquery) "216 printprocesslog "WARN possible problem to query DB (program: $program, function sendquery, mysqlsetup $sqlrc) " 236 217 printprocesslog "MYSQLWARN [returncode: "$checkmysql"] "$val 237 218 val= … … 256 237 function getstepinfo() 257 238 { 258 getdbsetup239 #getdbsetup 259 240 needs=( `getfromsetup $step "Needs"` ) 260 241 noderestricted=`getfromsetup $step "NodeRestricted"` … … 283 264 for otherstep in ${othersteps[@]} 284 265 do 266 #printprocesslog "DEBUG "$otherstep 285 267 if ! [ "$otherstep" = "$maintable" ] 286 268 then 287 query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") " 269 # joins for needed steps 270 if [ "$1" = "get" ] 271 then 272 query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") " 273 fi 274 # joins for influenced steps 275 if [ "$1" = "set" ] 276 then 277 query=$query" "`getfromsetup $otherstep "SpecialJoin2"` 278 query=$query" LEFT JOIN "$otherstep"Status USING("`getfromsetup $otherstep "Primaries"`") " 279 fi 288 280 fi 289 281 done … … 297 289 query=$query" FROM " 298 290 othersteps=${needs[@]} 299 getalljoins 291 getalljoins "get" 300 292 # add condition 301 293 query=$query" WHERE " … … 392 384 # execute query 393 385 #numproc=`sendquery `#cannot be done with sendquery, because of row counting 394 if ! numproc=`mysql $sqlpwfile -s -u $us $pw --host=$ho $db -e " $query " | wc -l` 395 then 396 printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus)" 397 echo `date +%F\ %T`" ERROR could not query number of processes from db (program: $program, function getstatus)" 386 printprocesslog "DEBUG send query "$query 387 if ! numproc=`mysql --default-file=$sqlrc -s -e " $query " | wc -l` 388 then 389 printprocesslog "ERROR could not query number of processes from db (program: $program, function getstatus, mysqlsetup $sqlrc)" 390 echo `date +%F\ %T`" ERROR could not query number of processes from db (program: $program, function getstatus, mysqlsetup $sqlrc)" 398 391 continue 399 392 fi … … 429 422 ;; 430 423 stop) case $check in 431 ok) printprocesslog "DEBU Bsetstatus stop - ok"424 ok) printprocesslog "DEBUG setstatus stop - ok" 432 425 starttime=noreset 433 426 stoptime="Now()" … … 470 463 # get query 471 464 query=" UPDATE " 472 getalljoins 465 getalljoins "set" 473 466 # set the status values according to the new status of the step 474 467 query=$query" SET " … … 668 661 printprocesslog "ERROR "$1" not found." 669 662 else 670 printprocesslog "WARN "$1" not found. "663 printprocesslog "WARN "$1" not found. ("$filenight" - "$checknight")" 671 664 fi 672 665 else … … 675 668 if [ $filenight -le $checknight ] 676 669 then 677 printprocesslog "WARN "$1" not found. "670 printprocesslog "WARN "$1" not found. ("$filenight" - "$checknight")" 678 671 else 679 672 printprocesslog "INFO "$1" not found."
Note:
See TracChangeset
for help on using the changeset viewer.