Changeset 35
- Timestamp:
- Apr 8, 2018, 4:41:57 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cleanup.php
r32 r35 44 44 write_log( "$me: debug db=$db; requestID=$requestID" ); 45 45 46 $us3_link = mysql _connect( $dbhost, $user, $passwd);46 $us3_link = mysqli_connect( $dbhost, $user, $passwd, $db ); 47 47 48 48 if ( ! $us3_link ) 49 49 { 50 write_log( "$me: could not connect: $dbhost, $user, $passwd " );50 write_log( "$me: could not connect: $dbhost, $user, $passwd, $db" ); 51 51 mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB" ); 52 return( -1 );53 }54 55 $result = mysql_select_db( $db, $us3_link );56 57 if ( ! $result )58 {59 write_log( "$me: could not select DB $db" );60 mail_to_user( "fail", "Internal Error $requestID\n$could not select DB $db" );61 52 return( -1 ); 62 53 } … … 65 56 $query = "SELECT email, investigatorGUID, editXMLFilename FROM HPCAnalysisRequest " . 66 57 "WHERE HPCAnalysisRequestID=$requestID"; 67 $result = mysql _query( $query, $us3_link);58 $result = mysqli_query( $us3_link, $query ); 68 59 69 60 if ( ! $result ) 70 61 { 71 62 write_log( "$me: Bad query: $query" ); 72 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql _error( $us3_link ) );63 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) ); 73 64 return( -1 ); 74 65 } 75 66 76 list( $email_address, $investigatorGUID, $editXMLFilename ) = mysql _fetch_array( $result );67 list( $email_address, $investigatorGUID, $editXMLFilename ) = mysqli_fetch_array( $result ); 77 68 78 69 $query = "SELECT personID FROM people " . 79 70 "WHERE personGUID='$investigatorGUID'"; 80 $result = mysql _query( $query, $us3_link);81 82 list( $personID ) = mysql _fetch_array( $result );71 $result = mysqli_query( $us3_link, $query ); 72 73 list( $personID ) = mysqli_fetch_array( $result ); 83 74 84 75 $query = "SELECT clusterName, submitTime, queueStatus, method " . … … 87 78 "AND h.HPCAnalysisRequestID=r.HPCAnalysisRequestID"; 88 79 89 $result = mysql _query( $query, $us3_link);90 91 if ( ! $result ) 92 { 93 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );80 $result = mysqli_query( $us3_link, $query ); 81 82 if ( ! $result ) 83 { 84 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 94 85 return( -1 ); 95 86 } 96 87 97 if ( mysql _num_rows( $result ) == 0 )88 if ( mysqli_num_rows( $result ) == 0 ) 98 89 { 99 90 write_log( "$me: US3 Table error - No records for requestID: $requestID" ); … … 101 92 } 102 93 103 list( $cluster, $submittime, $queuestatus, $jobtype ) = mysql _fetch_array( $result );94 list( $cluster, $submittime, $queuestatus, $jobtype ) = mysqli_fetch_array( $result ); 104 95 105 96 // Get the GFAC ID … … 107 98 "WHERE HPCAnalysisRequestID=$requestID"; 108 99 109 $result = mysql _query( $query, $us3_link);100 $result = mysqli_query( $us3_link, $query ); 110 101 111 102 if ( ! $result ) 112 103 { 113 104 write_log( "$me: Bad query: $query" ); 114 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql _error( $us3_link ) );105 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) ); 115 106 return( -1 ); 116 107 } 117 108 118 list( $HPCAnalysisResultID, $gfacID ) = mysql _fetch_array( $result );109 list( $HPCAnalysisResultID, $gfacID ) = mysqli_fetch_array( $result ); 119 110 120 111 // Get data from global GFAC DB then insert it into US3 DB 121 112 122 $result = mysql_select_db( $gDB, $gfac_link ); 113 /* 114 $result = mysqli_select_db( $gfac_link, $gDB ); 123 115 124 116 if ( ! $result ) … … 128 120 return( -1 ); 129 121 } 122 */ 130 123 131 124 $query = "SELECT status, cluster, id FROM analysis " . 132 125 "WHERE gfacID='$gfacID'"; 133 126 134 $result = mysql _query( $query, $gfac_link);127 $result = mysqli_query( $gfac_link, $query ); 135 128 if ( ! $result ) 136 129 { … … 140 133 } 141 134 142 list( $status, $cluster, $id ) = mysql _fetch_array( $result );135 list( $status, $cluster, $id ) = mysqli_fetch_array( $result ); 143 136 144 137 $is_us3iab = preg_match( "/us3iab/", $cluster ); … … 156 149 "WHERE gfacID='$gfacID'"; 157 150 158 $result = mysql _query( $query, $gfac_link);159 160 if ( ! $result ) 161 { 162 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );163 mail_to_user( "fail", "Internal error " . mysql _error( $gfac_link ) );151 $result = mysqli_query( $gfac_link, $query ); 152 153 if ( ! $result ) 154 { 155 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 156 mail_to_user( "fail", "Internal error " . mysqli_error( $gfac_link ) ); 164 157 return( -1 ); 165 158 } 166 159 167 list( $analysisID ) = mysql _fetch_array( $result );160 list( $analysisID ) = mysqli_fetch_array( $result ); 168 161 169 162 // Get the request guid (LIMS submit dir name) 170 163 $query = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " . 171 164 "WHERE HPCAnalysisRequestID = $requestID "; 172 $result = mysql _query( $query, $us3_link);165 $result = mysqli_query( $us3_link, $query ); 173 166 174 167 if ( ! $result ) 175 168 { 176 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );177 } 178 179 list( $requestGUID ) = mysql _fetch_array( $result );169 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 170 } 171 172 list( $requestGUID ) = mysqli_fetch_array( $result ); 180 173 $output_dir = "$submit_dir/$requestGUID"; 181 174 … … 254 247 "WHERE analysisID = $analysisID " . 255 248 "ORDER BY time "; 256 $result = mysql _query( $query, $gfac_link);249 $result = mysqli_query( $gfac_link, $query ); 257 250 258 251 if ( ! $result ) 259 252 { 260 253 // Just log it and continue 261 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );254 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 262 255 } 263 256 … … 268 261 "Processed: $now\n\n" . 269 262 "Queue Messages\n\n" ; 270 if ( mysql _num_rows( $result ) > 0 )271 { 272 while ( list( $message, $time ) = mysql _fetch_array( $result ) )263 if ( mysqli_num_rows( $result ) > 0 ) 264 { 265 while ( list( $message, $time ) = mysqli_fetch_array( $result ) ) 273 266 $message_log .= "$time $message\n"; 274 267 } … … 277 270 "WHERE analysisID = $analysisID "; 278 271 279 $result = mysql _query( $query, $gfac_link);272 $result = mysqli_query( $gfac_link, $query ); 280 273 281 274 if ( ! $result ) 282 275 { 283 276 // Just log it and continue 284 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );277 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 285 278 } 286 279 … … 288 281 "WHERE gfacID='$gfacID' "; 289 282 290 $result = mysql _query( $query, $gfac_link);291 list( $queue_msg ) = mysql _fetch_array( $result );283 $result = mysqli_query( $gfac_link, $query ); 284 list( $queue_msg ) = mysqli_fetch_array( $result ); 292 285 293 286 // But let's allow for investigation of other large stdout and/or stderr … … 306 299 $query = "DELETE from analysis WHERE gfacID='$gfacID'"; 307 300 308 $result = mysql _query( $query, $gfac_link);301 $result = mysqli_query( $gfac_link, $query ); 309 302 310 303 if ( ! $result ) 311 304 { 312 305 // Just log it and continue 313 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );306 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 314 307 } 315 308 … … 322 315 $message_filename = "$output_dir/$db-$requestID-messages.txt"; 323 316 file_put_contents( $message_filename, $message_log, FILE_APPEND ); 324 // mysql _close( $gfac_link );317 // mysqli_close( $gfac_link ); 325 318 326 319 ///////// … … 328 321 329 322 $query = "UPDATE HPCAnalysisResult SET " . 330 "stderr='" . mysql _real_escape_string( $stderr, $us3_link) . "', " .331 "stdout='" . mysql _real_escape_string( $stdout, $us3_link) . "', " .323 "stderr='" . mysqli_real_escape_string( $us3_link, $stderr ) . "', " . 324 "stdout='" . mysqli_real_escape_string( $us3_link, $stdout ) . "', " . 332 325 "queueStatus='completed' " . 333 326 "WHERE HPCAnalysisResultID=$HPCAnalysisResultID"; 334 327 335 $result = mysql _query( $query, $us3_link);336 337 if ( ! $result ) 338 { 339 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );340 mail_to_user( "fail", "Bad query:\n$query\n" . mysql _error( $us3_link ) );328 $result = mysqli_query( $us3_link, $query ); 329 330 if ( ! $result ) 331 { 332 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 333 mail_to_user( "fail", "Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 341 334 return( -1 ); 342 335 } … … 345 338 $query = "DELETE from analysis WHERE gfacID='$gfacID'"; 346 339 347 $result = mysql _query( $query, $gfac_link);340 $result = mysqli_query( $gfac_link, $query ); 348 341 349 342 if ( ! $result ) 350 343 { 351 344 // Just log it and continue 352 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );345 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 353 346 } 354 347 … … 429 422 "mgroupcount = {$otherdata['groupcount']} " . 430 423 "WHERE HPCAnalysisResultID=$HPCAnalysisResultID"; 431 $result = mysql _query( $query, $us3_link);424 $result = mysqli_query( $us3_link, $query ); 432 425 433 426 if ( ! $result ) 434 427 { 435 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );428 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 436 429 } 437 430 … … 450 443 $modelGUID = $noise_data[ 'modelGUID' ]; 451 444 $noiseGUID = $noise_data[ 'noiseGUID' ]; 445 $editGUID = '00000000-0000-0000-0000-000000000000'; 446 if ( isset( $model_data[ 'editGUID' ] ) ) 447 $editGUID = $model_data[ 'editGUID' ]; 452 448 453 449 $query = "INSERT INTO noise SET " . 454 450 "noiseGUID='$noiseGUID'," . 455 451 "modelGUID='$modelGUID'," . 456 "editedDataID=1, " . 452 "editedDataID=" . 453 "(SELECT editedDataID FROM editedData WHERE editGUID='$editGUID')," . 457 454 "modelID=1, " . 458 455 "noiseType='$type'," . 459 456 "description='$desc'," . 460 "xml='" . mysql _real_escape_string( $xml, $us3_link) . "'";457 "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'"; 461 458 462 459 // Add later after all files are processed: editDataID, modelID 463 460 464 $result = mysql _query( $query, $us3_link);461 $result = mysqli_query( $us3_link, $query ); 465 462 466 463 if ( ! $result ) 467 464 { 468 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );469 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );465 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 466 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 470 467 return( -1 ); 471 468 } 472 469 473 $id = mysql _insert_id( $us3_link );470 $id = mysqli_insert_id( $us3_link ); 474 471 $file_type = "noise"; 475 472 $noiseIDs[] = $id; … … 498 495 "mrecsGUID='$mrecGUID'," . 499 496 "description='$desc'," . 500 "xml='" . mysql _real_escape_string( $xml, $us3_link) . "'";497 "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'"; 501 498 502 499 // Add later after all files are processed: editDataID, modelID 503 500 504 $result = mysql _query( $query, $us3_link);501 $result = mysqli_query( $us3_link, $query ); 505 502 506 503 if ( ! $result ) 507 504 { 508 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );509 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );505 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 506 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 510 507 return( -1 ); 511 508 } 512 509 513 $id = mysql _insert_id( $us3_link );510 $id = mysqli_insert_id( $us3_link ); 514 511 $file_type = "mrecs"; 515 512 $mrecsIDs[] = $id; … … 543 540 "meniscus='$meniscus'," . 544 541 "variance='$variance'," . 545 "xml='" . mysql _real_escape_string( $xml, $us3_link) . "'";546 547 $result = mysql _query( $query, $us3_link);542 "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'"; 543 544 $result = mysqli_query( $us3_link, $query ); 548 545 549 546 if ( ! $result ) 550 547 { 551 write_log( "$me: Bad query:\n$query " . mysql _error( $us3_link ) );552 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );548 write_log( "$me: Bad query:\n$query " . mysqli_error( $us3_link ) ); 549 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 553 550 return( -1 ); 554 551 } 555 552 556 $modelID = mysql _insert_id( $us3_link );553 $modelID = mysqli_insert_id( $us3_link ); 557 554 $id = $modelID; 558 555 $file_type = "model"; … … 560 557 $query = "INSERT INTO modelPerson SET " . 561 558 "modelID=$modelID, personID=$personID"; 562 $result = mysql _query( $query, $us3_link);559 $result = mysqli_query( $us3_link, $query ); 563 560 } 564 561 … … 571 568 "resultID=$id"; 572 569 573 $result = mysql _query( $query, $us3_link);570 $result = mysqli_query( $us3_link, $query ); 574 571 575 572 if ( ! $result ) 576 573 { 577 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );578 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );574 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 575 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 579 576 return( -1 ); 580 577 } … … 595 592 "WHERE noiseID=$noiseID"; 596 593 597 $result = mysql _query( $query, $us3_link);594 $result = mysqli_query( $us3_link, $query ); 598 595 599 596 if ( ! $result ) 600 597 { 601 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );602 mail_to_user( "fail", "Bad query\n$query\n" . mysql _error( $us3_link ) );598 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 599 mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) ); 603 600 return( -1 ); 604 601 } … … 615 612 "WHERE mrecsID=$mrecsID"; 616 613 617 $result = mysql _query( $query, $us3_link);614 $result = mysqli_query( $us3_link, $query ); 618 615 619 616 if ( ! $result ) 620 617 { 621 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );622 mail_to_user( "fail", "Bad query\n$query\n" . mysql _error( $us3_link ) );618 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 619 mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) ); 623 620 return( -1 ); 624 621 } … … 633 630 $query = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " . 634 631 "WHERE HPCAnalysisRequestID = $requestID "; 635 $result = mysql _query( $query, $us3_link);632 $result = mysqli_query( $us3_link, $query ); 636 633 637 634 if ( ! $result ) 638 635 { 639 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );636 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 640 637 } 641 638 642 // list( $requestGUID ) = mysql _fetch_array( $result );639 // list( $requestGUID ) = mysqli_fetch_array( $result ); 643 640 // 644 641 // chdir( "$submit_dir/$requestGUID" ); … … 651 648 // exec( "rm -rf $gfacID" ); 652 649 653 mysql _close( $us3_link );650 mysqli_close( $us3_link ); 654 651 655 652 ///////// … … 725 722 { 726 723 $limshost = gethostname(); 727 if ( ! preg_match( "/\./", $limshost ) ) 724 if ( preg_match( "/scyld/", $limshost ) ) 725 $limshost = 'alamo.uthscsa.edu'; 726 else if ( ! preg_match( "/\./", $limshost ) ) 728 727 $limshost = $limshost . $org_domain; 729 728 } … … 870 869 global $me; 871 870 global $db; 871 global $dbhost; 872 872 global $status; 873 873 $is_us3iab = preg_match( "/us3iab/", $cluster ); 874 874 $is_jetstr = preg_match( "/jetstream/", $cluster ); 875 876 // Figure out remote directory 875 $limshost = $dbhost; 876 $stderr = ''; 877 $stdout = ''; 878 $tarfile = ''; 879 880 if ( $limshost == 'localhost' ) 881 { // If DB host is local host, get full LIMS host name 882 $limshost = gethostname(); 883 if ( preg_match( "/scyld/", $limshost ) ) 884 $limshost = 'alamo.uthscsa.edu'; 885 else if ( ! preg_match( "/\./", $limshost ) ) 886 $limshost = $limshost . $org_domain; 887 } 888 889 if ( preg_match( "/alamo/", $limshost ) && 890 preg_match( "/alamo/", $cluster ) ) 891 { // If both LIMS and cluster are alamo, set up local transfers 892 $is_us3iab = 1; 893 if ( ! preg_match( "/\/local/", $work_remote ) ) 894 $work_remote = $work_remote . "/local"; 895 } 896 897 // Figure out job's remote (or local) work directory 877 898 $remoteDir = sprintf( "$work_remote/$db-%06d", $requestID ); 878 899 //write_log( "$me: is_us3iab=$is_us3iab remoteDir=$remoteDir" ); … … 891 912 $lworkdir = "/N/us3_cluster/work/local"; 892 913 } 893 $cmd = "ssh us3@$clushost 'ls -d $lworkdir' 2 /dev/null";914 $cmd = "ssh us3@$clushost 'ls -d $lworkdir' 2>/dev/null"; 894 915 exec( $cmd, $output, $stat ); 895 916 $work_remote = $output[ 0 ]; … … 934 955 } 935 956 else 936 { 957 { // Is US3IAB or alamo-to-alamo, so just change to local work directory 937 958 $pwd = chdir( "$remoteDir" ); 938 959 write_log( "$me: IS US3IAB: pwd=$pwd $remoteDir"); … … 942 963 // Write the files to gfacDB 943 964 965 $secwait = 10; 966 $num_try = 0; 967 while ( ! file_exists( "stderr" ) && $num_try < 3 ) 968 { // Do waits and retries to let stderr appear 969 sleep( $secwait ); 970 $num_try++; 971 $secwait *= 2; 972 write_log( "$me: not-exist-stderr: num_try=$num_try" ); 973 } 974 975 $lense = 0; 944 976 if ( file_exists( "stderr" ) ) 945 { // Filter stderr to not have libnnls debug lines 946 // exec( "mv stderr stderr+nnls", $output, $stat ); 947 // exec( "grep -vi nnls stderr+nnls >stderr", $output, $stat ); 977 { 978 $lense = filesize( "stderr" ); 979 if ( $lense > 1000000 ) 980 { // Replace exceptionally large stderr with smaller version 981 exec( "mv stderr stderr-orig", $output, $stat ); 982 exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat ); 983 exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat ); 984 exec( "cat stderr-h stderr-t >stderr", $output, $stat ); 985 } 948 986 $stderr = file_get_contents( "stderr" ); 949 987 } 950 988 else 989 { 951 990 $stderr = ""; 991 } 992 952 993 if ( file_exists( "stdout" ) ) $stdout = file_get_contents( "stdout" ); 994 953 995 $fn1_tarfile = "analysis-results.tar"; 954 996 $fn2_tarfile = "output/" . $fn1_tarfile; … … 958 1000 $tarfile = file_get_contents( $fn2_tarfile ); 959 1001 960 $lense = strlen( $stderr ); 961 if ( $lense > 1000000 ) 962 { // Replace exceptionally large stderr with smaller version 963 exec( "mv stderr stderr-orig", $output, $stat ); 964 exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat ); 965 exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat ); 966 exec( "cat stderr-h stderr-t >stderr", $output, $stat ); 967 $stderr = file_get_contents( "stderr" ); 968 } 969 $lent = strlen( $tarfile ); 970 write_log( "$me: tarfile size: $lent"); 1002 // $lense = strlen( $stderr ); 1003 // if ( $lense > 1000000 ) 1004 // { // Replace exceptionally large stderr with smaller version 1005 // exec( "mv stderr stderr-orig", $output, $stat ); 1006 // exec( "head -n 5000 stderr-orig >stderr-h", $output, $stat ); 1007 // exec( "tail -n 5000 stderr-orig >stderr-t", $output, $stat ); 1008 // exec( "cat stderr-h stderr-t >stderr", $output, $stat ); 1009 // $stderr = file_get_contents( "stderr" ); 1010 // } 971 1011 $lene = strlen( $stderr ); 972 1012 write_log( "$me: stderr size: $lene (was $lense)"); 973 1013 $leno = strlen( $stdout ); 974 1014 write_log( "$me: stdout size: $leno"); 975 $estarf=mysql_real_escape_string($tarfile,$gfac_link); 1015 $lent = strlen( $tarfile ); 1016 write_log( "$me: tarfile size: $lent"); 1017 $esstde = mysqli_real_escape_string( $gfac_link, $stderr ); 1018 $esstdo = mysqli_real_escape_string( $gfac_link, $stdout ); 1019 $estarf = mysqli_real_escape_string( $gfac_link, $tarfile ); 1020 $lene = strlen($esstde); 1021 write_log( "$me: es-stderr size: $lene"); 1022 $leno = strlen($esstdo); 1023 write_log( "$me: es-stdout size: $leno"); 976 1024 $lenf = strlen($estarf); 977 write_log( "$me: es-tarfile size: $lenf"); 978 $esstdo=mysql_real_escape_string($stdout,$gfac_link); 979 $leno = strlen($esstdo); 980 write_log( "$me: es-stdout size: $leno"); 981 $esstde=mysql_real_escape_string($stderr,$gfac_link); 982 $lene = strlen($esstde); 983 write_log( "$me: es-stderr size: $lene"); 1025 write_log( "$me: es-tarfile size: $lenf"); 984 1026 $query = "UPDATE analysis SET " . 985 "stderr='" . mysql_real_escape_string( $stderr, $gfac_link ). "'," .986 "stdout='" . mysql_real_escape_string( $stdout, $gfac_link ). "'," .987 "tarfile='" . mysql_real_escape_string( $tarfile, $gfac_link ). "'";988 989 $result = mysql _query( $query, $gfac_link);990 991 if ( ! $result ) 992 { 993 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );1027 "stderr='" . $esstde . "'," . 1028 "stdout='" . $esstdo . "'," . 1029 "tarfile='" . $estarf . "'"; 1030 1031 $result = mysqli_query( $gfac_link, $query ); 1032 1033 if ( ! $result ) 1034 { 1035 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 994 1036 echo "Bad query\n"; 995 1037 return( -1 ); -
trunk/cleanup_gfac.php
r25 r35 41 41 write_log( "$me: debug db=$db; requestID=$requestID" ); 42 42 43 $us3_link = mysql _connect( $dbhost, $user, $passwd);43 $us3_link = mysqli_connect( $dbhost, $user, $passwd, $db ); 44 44 45 45 if ( ! $us3_link ) 46 46 { 47 write_log( "$me: could not connect: $dbhost, $user, $passwd" ); 48 mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB" ); 49 return( -1 ); 50 } 51 52 $result = mysql_select_db( $db, $us3_link ); 53 54 if ( ! $result ) 55 { 56 write_log( "$me: could not select DB $db" ); 57 mail_to_user( "fail", "Internal Error $requestID\n$could not select DB $db" ); 47 write_log( "$me: could not connect: $dbhost, $user, $passwd, $db" ); 48 mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB $db" ); 58 49 return( -1 ); 59 50 } … … 62 53 $query = "SELECT email, investigatorGUID, editXMLFilename FROM HPCAnalysisRequest " . 63 54 "WHERE HPCAnalysisRequestID=$requestID"; 64 $result = mysql _query( $query, $us3_link);55 $result = mysqli_query( $us3_link, $query ); 65 56 66 57 if ( ! $result ) 67 58 { 68 59 write_log( "$me: Bad query: $query" ); 69 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql _error( $us3_link ) );70 return( -1 ); 71 } 72 73 list( $email_address, $investigatorGUID, $editXMLFilename ) = mysql _fetch_array( $result );60 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) ); 61 return( -1 ); 62 } 63 64 list( $email_address, $investigatorGUID, $editXMLFilename ) = mysqli_fetch_array( $result ); 74 65 75 66 $query = "SELECT personID FROM people " . 76 67 "WHERE personGUID='$investigatorGUID'"; 77 $result = mysql _query( $query, $us3_link);78 79 list( $personID ) = mysql _fetch_array( $result );68 $result = mysqli_query( $us3_link, $query ); 69 70 list( $personID ) = mysqli_fetch_array( $result ); 80 71 81 72 /* … … 90 81 "AND h.HPCAnalysisRequestID=r.HPCAnalysisRequestID"; 91 82 92 $result = mysql _query( $query, $us3_link);93 94 if ( ! $result ) 95 { 96 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );97 return( -1 ); 98 } 99 100 if ( mysql _num_rows( $result ) == 0 )83 $result = mysqli_query( $us3_link, $query ); 84 85 if ( ! $result ) 86 { 87 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 88 return( -1 ); 89 } 90 91 if ( mysqli_num_rows( $result ) == 0 ) 101 92 { 102 93 write_log( "$me: US3 Table error - No records for requestID: $requestID" ); … … 104 95 } 105 96 106 list( $cluster, $submittime, $queuestatus, $jobtype ) = mysql _fetch_array( $result );97 list( $cluster, $submittime, $queuestatus, $jobtype ) = mysqli_fetch_array( $result ); 107 98 108 99 // Get the GFAC ID … … 110 101 "WHERE HPCAnalysisRequestID=$requestID"; 111 102 112 $result = mysql _query( $query, $us3_link);103 $result = mysqli_query( $us3_link, $query ); 113 104 114 105 if ( ! $result ) 115 106 { 116 107 write_log( "$me: Bad query: $query" ); 117 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysql _error( $us3_link ) );118 return( -1 ); 119 } 120 121 list( $HPCAnalysisResultID, $gfacID ) = mysql _fetch_array( $result );108 mail_to_user( "fail", "Internal Error $requestID\n$query\n" . mysqli_error( $us3_link ) ); 109 return( -1 ); 110 } 111 112 list( $HPCAnalysisResultID, $gfacID ) = mysqli_fetch_array( $result ); 122 113 123 114 //////// 124 115 // Get data from global GFAC DB and insert it into US3 DB 125 // $gfac_link = mysql_connect( $dbhost, $guser, $gpasswd ); 126 127 $result = mysql_select_db( $gDB, $gfac_link ); 128 129 if ( ! $result ) 130 { 131 write_log( "$me: Could not connect to DB $gDB" ); 116 $gfac_link = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 117 118 if ( ! $gfac_link ) 119 { 120 write_log( "$me: Could not connect to DB $dbhost : $gDB" ); 132 121 mail_to_user( "fail", "Internal Error $requestID\nCould not connect to DB $gDB" ); 133 122 return( -1 ); … … 137 126 "WHERE gfacID='$gfacID'"; 138 127 139 $result = mysql _query( $query, $gfac_link);128 $result = mysqli_query( $gfac_link, $query ); 140 129 if ( ! $result ) 141 130 { … … 145 134 } 146 135 147 $num_rows = mysql _num_rows( $result );136 $num_rows = mysqli_num_rows( $result ); 148 137 if ( $num_rows == 0 ) 149 138 { … … 156 145 //} 157 146 158 list( $status, $cluster, $id ) = mysql _fetch_array( $result );147 list( $status, $cluster, $id ) = mysqli_fetch_array( $result ); 159 148 //write_log( "$me: db=$db; requestID=$requestID; status=$status; cluster=$cluster" ); 160 149 … … 176 165 "WHERE gfacID='$gfacID'"; 177 166 178 $result = mysql _query( $query, $gfac_link);179 180 if ( ! $result ) 181 { 182 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );183 mail_to_user( "fail", "Internal error " . mysql _error( $gfac_link ) );184 return( -1 ); 185 } 186 187 $num_rows = mysql _num_rows( $result );167 $result = mysqli_query( $gfac_link, $query ); 168 169 if ( ! $result ) 170 { 171 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 172 mail_to_user( "fail", "Internal error " . mysqli_error( $gfac_link ) ); 173 return( -1 ); 174 } 175 176 $num_rows = mysqli_num_rows( $result ); 188 177 if ( $num_rows == 0 ) 189 178 { … … 192 181 } 193 182 194 list( $analysisID, $stderr, $stdout, $tarfile ) = mysql _fetch_array( $result );183 list( $analysisID, $stderr, $stdout, $tarfile ) = mysqli_fetch_array( $result ); 195 184 196 185 if ( strlen( $tarfile ) > 0 ) … … 209 198 "WHERE analysisID = $analysisID " . 210 199 "ORDER BY time "; 211 $result = mysql _query( $query, $gfac_link);200 $result = mysqli_query( $gfac_link, $query ); 212 201 213 202 if ( ! $result ) 214 203 { 215 204 // Just log it and continue 216 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );205 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 217 206 } 218 207 … … 226 215 $need_finish = ( $status == 'COMPLETE' ); 227 216 228 if ( mysql _num_rows( $result ) > 0 )217 if ( mysqli_num_rows( $result ) > 0 ) 229 218 { 230 219 $time_msg = time(); 231 while ( list( $message, $time ) = mysql _fetch_array( $result ) )220 while ( list( $message, $time ) = mysqli_fetch_array( $result ) ) 232 221 { 233 222 //write_log( "$me: message=$message" ); … … 263 252 "WHERE analysisID = $analysisID "; 264 253 265 $result = mysql _query( $query, $gfac_link);254 $result = mysqli_query( $gfac_link, $query ); 266 255 267 256 if ( ! $result ) 268 257 { 269 258 // Just log it and continue 270 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );259 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 271 260 } 272 261 … … 274 263 $query = "SELECT stdout, stderr, status, queue_msg FROM analysis " . 275 264 "WHERE gfacID='$gfacID' "; 276 $result = mysql _query( $query, $gfac_link);265 $result = mysqli_query( $gfac_link, $query ); 277 266 try 278 267 { 279 268 // What if this is too large? 280 list( $stdout, $stderr, $status, $queue_msg ) = mysql _fetch_array( $result );269 list( $stdout, $stderr, $status, $queue_msg ) = mysqli_fetch_array( $result ); 281 270 } 282 271 catch ( Exception $e ) 283 272 { 284 write_log( "$me: stdout + stderr larger than 128M - $gfacID\n" . mysql _error( $gfac_link ) );273 write_log( "$me: stdout + stderr larger than 128M - $gfacID\n" . mysqli_error( $gfac_link ) ); 285 274 // Just go ahead and clean up 286 275 } … … 301 290 $query = "DELETE from analysis WHERE gfacID='$gfacID'"; 302 291 303 $result = mysql _query( $query, $gfac_link);292 $result = mysqli_query( $gfac_link, $query ); 304 293 305 294 if ( ! $result ) 306 295 { 307 296 // Just log it and continue 308 write_log( "$me: Bad query:\n$query\n" . mysql _error( $gfac_link ) );297 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $gfac_link ) ); 309 298 } 310 299 write_log( "$me: GFAC DB entry deleted" ); … … 316 305 $query = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " . 317 306 "WHERE HPCAnalysisRequestID = $requestID "; 318 $result = mysql _query( $query, $us3_link);307 $result = mysqli_query( $us3_link, $query ); 319 308 320 309 if ( ! $result ) 321 310 { 322 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );311 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 323 312 } 324 313 325 list( $requestGUID ) = mysql _fetch_array( $result );314 list( $requestGUID ) = mysqli_fetch_array( $result ); 326 315 $output_dir = "$submit_dir/$requestGUID"; 327 316 write_log( "$me: Output dir determined: $output_dir" ); … … 334 323 $message_filename = "$output_dir/$db-$requestID-messages.txt"; 335 324 file_put_contents( $message_filename, $message_log, FILE_APPEND ); 336 // mysql _close( $gfac_link );325 // mysqli_close( $gfac_link ); 337 326 write_log( "$me: *messages.txt written" ); 338 327 … … 341 330 342 331 $query = "UPDATE HPCAnalysisResult SET " . 343 "stderr='" . mysql _real_escape_string( $stderr, $us3_link) . "', " .344 "stdout='" . mysql _real_escape_string( $stdout, $us3_link) . "' " .332 "stderr='" . mysqli_real_escape_string( $us3_link, $stderr ) . "', " . 333 "stdout='" . mysqli_real_escape_string( $us3_link, $stdout ) . "' " . 345 334 "WHERE HPCAnalysisResultID=$HPCAnalysisResultID"; 346 335 347 $result = mysql _query( $query, $us3_link);348 349 if ( ! $result ) 350 { 351 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );352 mail_to_user( "fail", "Bad query:\n$query\n" . mysql _error( $us3_link ) );336 $result = mysqli_query( $us3_link, $query ); 337 338 if ( ! $result ) 339 { 340 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 341 mail_to_user( "fail", "Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 353 342 return( -1 ); 354 343 } … … 442 431 "mgroupcount = {$otherdata['groupcount']} " . 443 432 "WHERE HPCAnalysisResultID=$HPCAnalysisResultID"; 444 $result = mysql _query( $query, $us3_link);433 $result = mysqli_query( $us3_link, $query ); 445 434 446 435 if ( ! $result ) 447 436 { 448 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );437 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 449 438 } 450 439 … … 463 452 $modelGUID = $noise_data[ 'modelGUID' ]; 464 453 $noiseGUID = $noise_data[ 'noiseGUID' ]; 454 $editGUID = '00000000-0000-0000-0000-000000000000'; 455 if ( isset( $model_data[ 'editGUID' ] ) ) 456 $editGUID = $model_data[ 'editGUID' ]; 465 457 466 458 $query = "INSERT INTO noise SET " . 467 459 "noiseGUID='$noiseGUID'," . 468 460 "modelGUID='$modelGUID'," . 469 "editedDataID=2, " . 461 "editedDataID=" . 462 "(SELECT editedDataID FROM editedData WHERE editGUID='$editGUID')," . 470 463 "modelID=1, " . 471 464 "noiseType='$type'," . 472 465 "description='$desc'," . 473 "xml='" . mysql _real_escape_string( $xml, $us3_link) . "'";466 "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'"; 474 467 475 468 // Add later after all files are processed: editDataID, modelID 476 469 477 $result = mysql _query( $query, $us3_link);470 $result = mysqli_query( $us3_link, $query ); 478 471 479 472 if ( ! $result ) 480 473 { 481 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );482 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );474 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 475 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 483 476 return( -1 ); 484 477 } 485 478 486 $id = mysql _insert_id( $us3_link );479 $id = mysqli_insert_id( $us3_link ); 487 480 $file_type = "noise"; 488 481 $noiseIDs[] = $id; … … 490 483 // Keep track of modelGUIDs for later, when we replace them 491 484 $modelGUIDs[ $id ] = $modelGUID; 492 //write_log( "$me: noise file inserted into DB : id=$id " );485 //write_log( "$me: noise file inserted into DB : id=$id modelGUID=$modelGUID" ); 493 486 494 487 } … … 512 505 "mrecsGUID='$mrecGUID'," . 513 506 "description='$desc'," . 514 "xml='" . mysql _real_escape_string( $xml, $us3_link) . "'";507 "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'"; 515 508 516 509 // Add later after all files are processed: editDataID, modelID 517 510 518 $result = mysql _query( $query, $us3_link);511 $result = mysqli_query( $us3_link, $query ); 519 512 520 513 if ( ! $result ) 521 514 { 522 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );523 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );515 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 516 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 524 517 return( -1 ); 525 518 } 526 519 527 $id = mysql _insert_id( $us3_link );520 $id = mysqli_insert_id( $us3_link ); 528 521 $file_type = "mrecs"; 529 522 $mrecsIDs[] = $id; … … 560 553 "meniscus='$meniscus'," . 561 554 "variance='$variance'," . 562 "xml='" . mysql _real_escape_string( $xml, $us3_link) . "'";563 564 $result = mysql _query( $query, $us3_link);555 "xml='" . mysqli_real_escape_string( $us3_link, $xml ) . "'"; 556 557 $result = mysqli_query( $us3_link, $query ); 565 558 566 559 if ( ! $result ) 567 560 { 568 write_log( "$me: Bad query:\n$query " . mysql _error( $us3_link ) );569 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );561 write_log( "$me: Bad query:\n$query " . mysqli_error( $us3_link ) ); 562 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 570 563 return( -1 ); 571 564 } 572 565 573 $modelID = mysql _insert_id( $us3_link );566 $modelID = mysqli_insert_id( $us3_link ); 574 567 $id = $modelID; 575 568 $file_type = "model"; … … 577 570 $query = "INSERT INTO modelPerson SET " . 578 571 "modelID=$modelID, personID=$personID"; 579 $result = mysql _query( $query, $us3_link);572 $result = mysqli_query( $us3_link, $query ); 580 573 //write_log( "$me: model file inserted into DB : id=$id" ); 581 574 } … … 586 579 "resultID=$id"; 587 580 588 $result = mysql _query( $query, $us3_link);581 $result = mysqli_query( $us3_link, $query ); 589 582 590 583 if ( ! $result ) 591 584 { 592 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );593 mail_to_user( "fail", "Internal error\n$query\n" . mysql _error( $us3_link ) );585 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 586 mail_to_user( "fail", "Internal error\n$query\n" . mysqli_error( $us3_link ) ); 594 587 return( -1 ); 595 588 } … … 611 604 "WHERE noiseID=$noiseID"; 612 605 613 $result = mysql _query( $query, $us3_link);606 $result = mysqli_query( $us3_link, $query ); 614 607 615 608 if ( ! $result ) 616 609 { 617 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );618 mail_to_user( "fail", "Bad query\n$query\n" . mysql _error( $us3_link ) );610 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 611 mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) ); 619 612 return( -1 ); 620 613 } … … 633 626 "WHERE mrecsID=$mrecsID"; 634 627 635 $result = mysql _query( $query, $us3_link);628 $result = mysqli_query( $us3_link, $query ); 636 629 637 630 if ( ! $result ) 638 631 { 639 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );640 mail_to_user( "fail", "Bad query\n$query\n" . mysql _error( $us3_link ) );632 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 633 mail_to_user( "fail", "Bad query\n$query\n" . mysqli_error( $us3_link ) ); 641 634 return( -1 ); 642 635 } … … 651 644 $query = "SELECT HPCAnalysisRequestGUID FROM HPCAnalysisRequest " . 652 645 "WHERE HPCAnalysisRequestID = $requestID "; 653 $result = mysql _query( $query, $us3_link);654 655 if ( ! $result ) 656 { 657 write_log( "$me: Bad query:\n$query\n" . mysql _error( $us3_link ) );658 } 659 660 list( $requestGUID ) = mysql _fetch_array( $result );646 $result = mysqli_query( $us3_link, $query ); 647 648 if ( ! $result ) 649 { 650 write_log( "$me: Bad query:\n$query\n" . mysqli_error( $us3_link ) ); 651 } 652 653 list( $requestGUID ) = mysqli_fetch_array( $result ); 661 654 662 655 chdir( "$submit_dir/$requestGUID" ); … … 669 662 // exec( "rm -rf $gfacID" ); 670 663 671 mysql _close( $us3_link );664 mysqli_close( $us3_link ); 672 665 673 666 ///////// -
trunk/cluster_status.php
r32 r35 22 22 } 23 23 24 exit(); 24 //exit(); 25 exit(0); 25 26 26 27 // Get the cluster status … … 115 116 //echo " $cluster $queued, $status, $running\n"; 116 117 117 $gfac_link = mysql_connect( $dbhost, $guser, $gpasswd ); 118 $result = mysql_select_db( $gDB, $gfac_link ); 119 120 if ( ! $result ) 118 $gfac_link = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 119 120 if ( ! $gfac_link ) 121 121 { 122 122 write_log( "$self: Could not connect to DB $gDB" ); … … 126 126 127 127 $query = "SELECT * FROM cluster_status WHERE cluster='$cluster'"; 128 $result = mysql _query( $query, $gfac_link);128 $result = mysqli_query( $gfac_link, $query ); 129 129 130 130 if ( ! $result ) 131 131 { 132 write_log( "$self: Query failed $query - " . mysql _error( $gfac_link ) );133 echo "$self: Query failed $query - " . mysql _error( $gfac_link ) . "\n";132 write_log( "$self: Query failed $query - " . mysqli_error( $gfac_link ) ); 133 echo "$self: Query failed $query - " . mysqli_error( $gfac_link ) . "\n"; 134 134 exit(); 135 135 } 136 136 137 $rows = mysql _num_rows( $result );137 $rows = mysqli_num_rows( $result ); 138 138 139 139 if ( $rows == 0 ) // INSERT … … 154 154 } 155 155 156 $result = mysql _query( $query, $gfac_link);156 $result = mysqli_query( $gfac_link, $query ); 157 157 158 158 if ( ! $result ) 159 159 { 160 write_log( "$self: Query failed $query - " . mysql _error( $gfac_link ) );161 echo "$self: Query failed $query - " . mysql _error( $gfac_link ) . "\n";160 write_log( "$self: Query failed $query - " . mysqli_error( $gfac_link ) ); 161 echo "$self: Query failed $query - " . mysqli_error( $gfac_link ) . "\n"; 162 162 } 163 163 } … … 182 182 else 183 183 { 184 $clusters = array( "alamo", "lonestar5", "stampede", "comet", 185 "stampede2-b", "jetstream", "jureca", "jacinto-b" ); 184 // $clusters = array( "alamo", "lonestar5", "comet", 185 // "stampede2", "jetstream", "jureca", "jacinto" ); 186 $clusters = array( "alamo", "lonestar5", "comet", 187 "stampede2", "jetstream" ); 186 188 } 187 189 … … 238 240 break; 239 241 } 240 case 'stampede ':241 { 242 $host = "us3@stampede .tacc.utexas.edu";243 $qstat = `ssh $host '/usr/local/bin/showq 2> &1|grep "Total Jobs"'`;242 case 'stampede2': 243 { 244 $host = "us3@stampede2.tacc.utexas.edu"; 245 $qstat = `ssh $host '/usr/local/bin/showq 2>/dev/null|grep "Total Jobs"'`; 244 246 $sparts = preg_split( '/\s+/', $qstat ); 245 247 $tot = $sparts[ 2 ]; … … 251 253 break; 252 254 } 253 case 'stampede2':254 {255 $host = "us3@stampede2.tacc.utexas.edu";256 $qstat = `ssh $host '/usr/local/bin/showq 2>&1|grep "Total Jobs"'`;257 $sparts = preg_split( '/\s+/', $qstat );258 $tot = $sparts[ 2 ];259 $run = $sparts[ 5 ];260 $que = $sparts[ 8 ];261 $sta = "up";262 if ( $tot == '' || $tot == '0' )263 $sta = "down";264 break;265 }266 255 case 'lonestar5': 267 256 { 268 257 $host = "us3@ls5.tacc.utexas.edu"; 269 $qstat = `ssh $host '/usr/local/bin/showq 2> &1|grep "Total Jobs"'`;258 $qstat = `ssh $host '/usr/local/bin/showq 2>/dev/null|grep "Total Jobs"'`; 270 259 $sparts = preg_split( '/\s+/', $qstat ); 271 260 $tot = $sparts[ 2 ]; … … 280 269 { 281 270 $run = $sparts[ 5 ]; 282 //$que = $sparts[ 8 ];283 $que = $sparts[ 11 ];271 $que = $sparts[ 8 ]; 272 // $que = $sparts[ 11 ]; 284 273 } 285 274 break; … … 288 277 { 289 278 $host = "us3@comet.sdsc.edu"; 290 $qstat = `ssh $host '/usr/bin/sinfo -s -p compute -o "%a %F" |tail -1'`; 291 $sparts = preg_split( '/\s+/', $qstat ); 292 $sta = $sparts[ 0 ]; 293 $knts = $sparts[ 1 ]; 294 $sparts = preg_split( '/\//', $knts ); 295 $run = $sparts[ 0 ]; 296 $que = $sparts[ 1 ]; 297 if ( $sta == "" ) 298 $sta = "down"; 299 break; 300 } 301 case 'gordon': 302 { 303 $host = "us3@gordon.sdsc.edu"; 304 $qstat = `ssh $host '/opt/torque/bin/qstat -B 2>&1|tail -1'`; 305 $sparts = preg_split( '/\s+/', $qstat ); 306 $que = $sparts[ 3 ]; 307 $run = $sparts[ 4 ]; 308 $sta = $sparts[ 10 ]; 309 if ( $sta == "Active" ) 310 $sta = "up"; 279 //$qstat = `ssh $host '/usr/bin/sinfo -s -p compute -o "%a %F" |tail -1'`; 280 $qstat = `ssh $host '/home/us3/scripts/cstat 2>&1'`; 281 $sparts = preg_split( '/\s+/', $qstat ); 282 $tot = $sparts[ 1 ]; 283 $run = '0'; 284 $que = '0'; 285 $sta = "up"; 286 if ( $tot == '' || $tot == '0' ) 287 { 288 $sta = "down"; 289 } 311 290 else 312 $sta = "down"; 291 { 292 $run = $sparts[ 3 ]; 293 $que = $sparts[ 5 ]; 294 } 313 295 break; 314 296 } -
trunk/gridctl.php
r32 r35 20 20 21 21 // Get data from global GFAC DB 22 $gLink = mysql _connect( $dbhost, $guser, $gpasswd);23 24 if ( ! mysql_select_db( $gDB, $gLink ))25 { 26 write_log( "$self: Could not select DB $gDB - " . mysql _error() );22 $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 23 24 if ( ! $gLink ) 25 { 26 write_log( "$self: Could not select DB $gDB - " . mysqli_error() ); 27 27 mail_to_admin( "fail", "Internal Error: Could not select DB $gDB" ); 28 sleep(300); 28 29 exit(); 29 30 } … … 31 32 $query = "SELECT gfacID, us3_db, cluster, status, queue_msg, " . 32 33 "UNIX_TIMESTAMP(time), time from analysis"; 33 $result = mysql _query( $query, $gLink);34 $result = mysqli_query( $gLink, $query ); 34 35 35 36 if ( ! $result ) 36 37 { 37 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );38 mail_to_admin( "fail", "Query failed $query\n" . mysql _error( $gLink ) );38 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 39 mail_to_admin( "fail", "Query failed $query\n" . mysqli_error( $gLink ) ); 39 40 exit(); 40 41 } 41 42 42 if ( mysql _num_rows( $result ) == 0 )43 if ( mysqli_num_rows( $result ) == 0 ) 43 44 { 44 45 //write_log( "$self: analysis read got numrows==0" ); 45 46 exit(); // Nothing to do 46 47 } 48 //write_log( "$loghdr gfac-analysis rows $nrows" ); 47 49 48 50 $me_devel = preg_match( "/class_devel/", $class_dir ); 51 //echo "me_devel=$me_devel class_dir=$class_dir\n"; 49 52 50 53 while ( list( $gfacID, $us3_db, $cluster, $status, $queue_msg, $time, $updateTime ) 51 = mysql _fetch_array( $result ) )54 = mysqli_fetch_array( $result ) ) 52 55 { 53 56 // If this entry does not match class/class_devel, skip processing 57 //echo " gfacID=$gfacID gf_status=$status\n"; 54 58 55 59 if ( preg_match( "/US3-A/i", $gfacID ) ) 56 60 { // For thrift, job and gridctl must match 57 61 $job_devel = preg_match( "/US3-ADEV/i", $gfacID ); 62 //echo " THR: job_devel=$job_devel\n"; 58 63 if ( ( $me_devel && !$job_devel ) || 59 64 ( !$me_devel && $job_devel ) ) … … 65 70 else if ( $me_devel ) 66 71 { // Local (us3iab/-local) and class_devel: skip processing 72 //echo " LOC: me_devel=$me_devel\n"; 67 73 continue; 68 74 } … … 99 105 //write_log( "$loghdr status_in=$status_in" ); 100 106 $status = aira_status( $gfacID, $status_in ); 107 //echo "$loghdr status_in=$status_in status_ex=$status\n"; 101 108 if($status != $status_in ) 102 109 write_log( "$loghdr Set to $status from $status_in" ); … … 110 117 if ( $status_gw == 'COMPLETE' ) 111 118 $status = $status_gw; 119 //echo "$loghdr status_gw=$status_gw status=$status\n"; 112 120 //write_log( "$loghdr non-AThrift status=$status status_gw=$status_gw" ); 113 121 } … … 119 127 if ( $status_gw == 'COMPLETE' || $status == 'UNKNOWN' ) 120 128 $status = $status_gw; 129 //echo "$loghdr status_lo=$status\n"; 121 130 //write_log( "$loghdr Local status=$status status_gw=$status_gw" ); 122 131 } … … 130 139 131 140 $query2 = "UPDATE analysis SET status='ERROR' WHERE gfacID='$gfacID'"; 132 $result2 = mysql _query( $query2, $gLink);141 $result2 = mysqli_query( $gLink, $query2 ); 133 142 $status = 'ERROR'; 134 143 135 144 if ( ! $result2 ) 136 write_log( "$loghdr Query failed $query2 - " . mysql _error( $gLink ) );145 write_log( "$loghdr Query failed $query2 - " . mysqli_error( $gLink ) ); 137 146 138 147 } … … 200 209 } 201 210 } 211 mysqli_close( $gLink ); 202 212 203 213 exit(); … … 235 245 mail_to_admin( "hang", "$message - id: $gfacID" ); 236 246 $query = "UPDATE analysis SET status='SUBMIT_TIMEOUT' WHERE gfacID='$gfacID'"; 237 $result = mysql _query( $query, $gLink);247 $result = mysqli_query( $gLink, $query ); 238 248 239 249 if ( ! $result ) 240 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );250 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 241 251 242 252 update_queue_messages( $message ); … … 271 281 mail_to_admin( "hang", "$message - id: $gfacID" ); 272 282 $query = "UPDATE analysis SET status='FAILED' WHERE gfacID='$gfacID'"; 273 $result = mysql _query( $query, $gLink);283 $result = mysqli_query( $gLink, $query ); 274 284 275 285 if ( ! $result ) 276 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );286 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 277 287 278 288 update_queue_messages( $message ); … … 311 321 mail_to_admin( "hang", "$message - id: $gfacID" ); 312 322 $query = "UPDATE analysis SET status='RUN_TIMEOUT' WHERE gfacID='$gfacID'"; 313 $result = mysql _query( $query, $gLink);323 $result = mysqli_query( $gLink, $query ); 314 324 315 325 if ( ! $result ) 316 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );326 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 317 327 318 328 update_queue_messages( $message ); … … 349 359 mail_to_admin( "hang", "$message - id: $gfacID" ); 350 360 $query = "UPDATE analysis SET status='FAILED' WHERE gfacID='$gfacID'"; 351 $result = mysql _query( $query, $gLink);361 $result = mysqli_query( $gLink, $query ); 352 362 353 363 if ( ! $result ) 354 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );364 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 355 365 356 366 update_queue_messages( $message ); … … 397 407 mail_to_admin( "hang", "$message - id: $gfacID" ); 398 408 $query = "UPDATE analysis SET status='DATA_TIMEOUT' WHERE gfacID='$gfacID'"; 399 $result = mysql _query( $query, $gLink);409 $result = mysqli_query( $gLink, $query ); 400 410 401 411 if ( ! $result ) 402 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );412 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 403 413 404 414 update_queue_messages( $message ); … … 445 455 mail_to_admin( "hang", "$message - id: $gfacID" ); 446 456 $query = "UPDATE analysis SET status='FAILED' WHERE gfacID='$gfacID'"; 447 $result = mysql _query( $query, $gLink);457 $result = mysqli_query( $gLink, $query ); 448 458 449 459 if ( ! $result ) 450 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );460 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 451 461 452 462 update_queue_messages( $message ); … … 477 487 // Double check that the gfacID exists 478 488 $query = "SELECT count(*) FROM analysis WHERE gfacID='$gfacID'"; 479 $result = mysql _query( $query, $gLink);489 $result = mysqli_query( $gLink, $query ); 480 490 481 491 if ( ! $result ) 482 492 { 483 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );484 mail_to_admin( "fail", "Query failed $query\n" . mysql _error( $gLink ) );485 return; 486 } 487 488 list( $count ) = mysql _fetch_array( $result );489 490 if ($count==0)491 write_log( "$loghdr count = $count gfacID = $gfacID" );493 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 494 mail_to_admin( "fail", "Query failed $query\n" . mysqli_error( $gLink ) ); 495 return; 496 } 497 498 list( $count ) = mysqli_fetch_array( $result ); 499 500 //if ($count==0) 501 //write_log( "$loghdr count = $count gfacID = $gfacID" ); 492 502 if ( $count == 0 ) return; 493 503 … … 597 607 } 598 608 599 $result = mysql _query( $query, $gLink);609 $result = mysqli_query( $gLink, $query ); 600 610 if ( ! $result ) 601 write_log( "$loghdr Query failed $query - " . mysql _error( $gLink ) );611 write_log( "$loghdr Query failed $query - " . mysqli_error( $gLink ) ); 602 612 603 613 if ( $message != 'NONE' ) … … 619 629 global $loghdr; 620 630 621 $us3_link = mysql _connect( $dbhost, $user, $passwd);631 $us3_link = mysqli_connect( $dbhost, $user, $passwd, $us3_db ); 622 632 623 633 if ( ! $us3_link ) 624 634 { 625 write_log( "$loghdr could not connect: $dbhost, $user, $passwd" ); 626 mail_to_admin( "fail", "Could not connect to $dbhost" ); 627 return 0; 628 } 629 630 631 $result = mysql_select_db( $us3_db, $us3_link ); 632 633 if ( ! $result ) 634 { 635 write_log( "$loghdr could not select DB $us3_db" ); 636 mail_to_admin( "fail", "Could not select DB $us3_db, $dbhost, $user, $passwd" ); 635 write_log( "$loghdr could not connect: $dbhost, $user, $passwd, $us3_db" ); 636 mail_to_admin( "fail", "Could not connect to $dbhost : $us3_db" ); 637 637 return 0; 638 638 } … … 640 640 $query = "SELECT HPCAnalysisRequestID, UNIX_TIMESTAMP(updateTime) " . 641 641 "FROM HPCAnalysisResult WHERE gfacID='$gfacID'"; 642 $result = mysql _query( $query, $us3_link);642 $result = mysqli_query( $us3_link, $query ); 643 643 644 644 if ( ! $result ) 645 645 { 646 write_log( "$self: Query failed $query - " . mysql _error( $us3_link ) );647 mail_to_admin( "fail", "Query failed $query\n" . mysql _error( $us3_link ) );646 write_log( "$self: Query failed $query - " . mysqli_error( $us3_link ) ); 647 mail_to_admin( "fail", "Query failed $query\n" . mysqli_error( $us3_link ) ); 648 648 return 0; 649 649 } 650 650 651 list( $requestID, $updateTime ) = mysql _fetch_array( $result );652 mysql _close( $us3_link );651 list( $requestID, $updateTime ) = mysqli_fetch_array( $result ); 652 mysqli_close( $us3_link ); 653 653 654 654 return $requestID; … … 859 859 //write_log( "$self result: $result" ); 860 860 861 ///////////////////////////////////////////////////////////////////862 861 $secwait = 2; 863 862 $num_try = 0; … … 870 869 write_log( "$me: num_try=$num_try secwait=$secwait" ); 871 870 } 872 /////////////////////////////////////////////////////////////////// 873 // if ( $result == "" || 874 // preg_match( "/^qstat: Unknown/", $result ) || 875 // preg_match( "/ssh_exchange_id/", $result ) ) 871 876 872 if ( preg_match( "/^qstat: Unknown/", $result ) || 877 873 preg_match( "/ssh_exchange_id/", $result ) ) 878 874 { 879 write_log( "$self get_local_status: Local job $gfacID unknown" ); 880 //write_log( "$self get_local_status: result=$result" ); 875 write_log( "$self get_local_status: Local job $gfacID unknown result=$result" ); 881 876 return 'UNKNOWN'; 882 877 } … … 937 932 $query = "SELECT id FROM analysis " . 938 933 "WHERE gfacID = '$gfacID' "; 939 $result = mysql _query( $query, $gLink);934 $result = mysqli_query( $gLink, $query ); 940 935 if ( ! $result ) 941 936 { 942 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );943 return; 944 } 945 list( $analysisID ) = mysql _fetch_array( $result );937 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 938 return; 939 } 940 list( $analysisID ) = mysqli_fetch_array( $result ); 946 941 947 942 // Insert message into queue_message table 948 943 $query = "INSERT INTO queue_messages SET " . 949 "message = '" . mysql _real_escape_string( $message, $gLink) . "', " .944 "message = '" . mysqli_real_escape_string( $gLink, $message ) . "', " . 950 945 "analysisID = '$analysisID' "; 951 $result = mysql _query( $query, $gLink);946 $result = mysqli_query( $gLink, $query ); 952 947 if ( ! $result ) 953 948 { 954 write_log( "$self: Query failed $query - " . mysql _error( $gLink ) );949 write_log( "$self: Query failed $query - " . mysqli_error( $gLink ) ); 955 950 return; 956 951 } … … 966 961 global $us3_db; 967 962 968 $us3_link = mysql _connect( $dbhost, $user, $passwd);963 $us3_link = mysqli_connect( $dbhost, $user, $passwd, $us3_db ); 969 964 970 965 if ( ! $us3_link ) 971 966 { 972 967 write_log( "$self: could not connect: $dbhost, $user, $passwd" ); 973 mail_to_admin( "fail", "Could not connect to $dbhost " );968 mail_to_admin( "fail", "Could not connect to $dbhost : $us3_db" ); 974 969 return 0; 975 970 } 976 971 977 978 $result = mysql_select_db( $us3_db, $us3_link );979 980 if ( ! $result )981 {982 write_log( "$self: could not select DB $us3_db" );983 mail_to_admin( "fail", "Could not select DB $us3_db, $dbhost, $user, $passwd" );984 return 0;985 }986 987 972 $query = "UPDATE HPCAnalysisResult SET " . 988 "lastMessage='" . mysql _real_escape_string( $message, $us3_link) . "'" .973 "lastMessage='" . mysqli_real_escape_string( $us3_link, $message ) . "'" . 989 974 "WHERE gfacID = '$gfacID' "; 990 975 991 mysql _query( $query, $us3_link);992 mysql _close( $us3_link );976 mysqli_query( $us3_link, $query ); 977 mysqli_close( $us3_link ); 993 978 } 994 979 … … 1173 1158 } 1174 1159 1160 //if ( $status != 'SUBMITTED' ) 1175 1161 //write_log( "$loghdr status/_in/_gw/_ex=$status/$status_in/$status_gw/$status_ex" ); 1176 1162 if ( $status != $status_gw ) -
trunk/manage-us3-pipe.php
r26 r35 55 55 56 56 // We need the gfacID 57 $resource = mysql _connect( $dbhost, $user, $passwd);57 $resource = mysqli_connect( $dbhost, $user, $passwd, $db ); 58 58 59 59 if ( ! $resource ) 60 60 { 61 write_log( "$self process(): Could not connect to MySQL - " . mysql _error() );61 write_log( "$self process(): Could not connect to MySQL - " . mysqli_error($resource) ); 62 62 write_log( "$self process(): original msg - $msg" ); 63 63 return; 64 }65 66 if ( ! mysql_select_db( $db, $resource ) )67 {68 write_log( "$self: Could not select DB $db " . mysql_error( $resource ) );69 write_log( "$self process(): original msg - $msg" );70 return;71 64 } 72 65 … … 76 69 "LIMIT 1"; 77 70 78 $result = mysql _query( $query, $resource);71 $result = mysqli_query( $resource, $query ); 79 72 80 73 if ( ! $result ) … … 86 79 87 80 // Set flags for Airavata/Thrift and "Finished..." 88 list( $gfacID ) = mysql _fetch_row( $result );89 mysql _close( $resource );81 list( $gfacID ) = mysqli_fetch_row( $result ); 82 mysqli_close( $resource ); 90 83 91 84 $is_athrift = preg_match( "/^US3-A/i", $gfacID ); … … 164 157 global $self; 165 158 166 $resource = mysql _connect( $dbhost, $user, $passwd);159 $resource = mysqli_connect( $dbhost, $user, $passwd, $db ); 167 160 168 161 if ( ! $resource ) 169 162 { 170 write_log( "$self: Could not connect to DB" ); 171 return; 172 } 173 174 if ( ! mysql_select_db( $db, $resource ) ) 175 { 176 write_log( "$self: Could not select DB $db " . mysql_error( $resource ) ); 163 write_log( "$self: Could not connect to DB $db " . mysqli_error( $resource ) ); 177 164 return; 178 165 } … … 183 170 "LIMIT 1"; 184 171 185 $result = mysql _query( $query, $resource);172 $result = mysqli_query( $resource, $query ); 186 173 187 174 if ( ! $result ) … … 191 178 } 192 179 193 list( $resultID ) = mysql _fetch_row( $result );180 list( $resultID ) = mysqli_fetch_row( $result ); 194 181 195 182 $query = "UPDATE HPCAnalysisResult SET "; … … 219 206 } 220 207 221 $query .= "lastMessage='" . mysql _real_escape_string($message ) . "'" .208 $query .= "lastMessage='" . mysqli_real_escape_string( $resource, $message ) . "'" . 222 209 "WHERE HPCAnalysisResultID=$resultID"; 223 210 224 mysql _query( $query, $resource);225 mysql _close( $resource );211 mysqli_query( $resource, $query ); 212 mysqli_close( $resource ); 226 213 } 227 214 … … 242 229 243 230 // Get data from global GFAC DB 244 $gLink = mysql _connect( $dbhost, $guser, $gpasswd);245 if ( ! mysql_select_db( $gDB, $gLink ))246 { 247 write_log( "$self: Could not select DB $gDB " . mysql _error( $gLink ) );231 $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 232 if ( ! $gLink ) 233 { 234 write_log( "$self: Could not select DB $gDB " . mysqli_error( $gLink ) ); 248 235 return; 249 236 } … … 260 247 { 261 248 $query = "UPDATE analysis " . 262 "SET queue_msg='" . mysql _real_escape_string($message ) . "' " .249 "SET queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " . 263 250 "WHERE gfacID='$gfacID'"; 264 251 265 252 //write_log( "$self process(): updgf-u : status=$status" ); 266 mysql _query( $query, $gLink);253 mysqli_query( $gLink, $query ); 267 254 } 268 255 … … 270 257 { 271 258 $query = "UPDATE analysis SET status='$status', " . 272 "queue_msg='" . mysql _real_escape_string($message ) . "' " .259 "queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " . 273 260 "WHERE gfacID='$gfacID'"; 274 261 275 262 //write_log( "$self process(): updgf-s : status=$status" ); 276 mysql _query( $query, $gLink);263 mysqli_query( $gLink, $query ); 277 264 } 278 265 … … 280 267 $query = "SELECT id FROM analysis " . 281 268 "WHERE gfacID = '$gfacID'"; 282 $result = mysql _query( $query, $gLink);269 $result = mysqli_query( $gLink, $query ); 283 270 if ( ! $result ) 284 271 { 285 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );286 return; 287 } 288 289 if ( mysql _num_rows( $result ) == 0 )272 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 273 return; 274 } 275 276 if ( mysqli_num_rows( $result ) == 0 ) 290 277 { 291 278 write_log( "$self: can't find $gfacID in GFAC db" ); … … 293 280 } 294 281 295 list( $aID ) = mysql _fetch_array( $result );282 list( $aID ) = mysqli_fetch_array( $result ); 296 283 297 284 $query = "INSERT INTO queue_messages " . 298 285 "SET analysisID = $aID, " . 299 "message = '" . mysql _real_escape_string($message ) . "'";300 $result = mysql _query( $query, $gLink);286 "message = '" . mysqli_real_escape_string( $gLink, $message ) . "'"; 287 $result = mysqli_query( $gLink, $query ); 301 288 if ( ! $result ) 302 289 { 303 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );304 return; 305 } 306 307 mysql _close( $gLink );290 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 291 return; 292 } 293 294 mysqli_close( $gLink ); 308 295 } 309 296 … … 353 340 354 341 // Get data from global GFAC DB 355 $gLink = mysql _connect( $dbhost, $guser, $gpasswd);356 if ( ! mysql_select_db( $gDB, $gLink ))357 { 358 write_log( "$self: Could not select DB $gDB " . mysql_error( $gLink ) );342 $gLink = mysqli_connect( $dbhost, $guser, $gpasswd, $gDB ); 343 if ( ! $gLink ) 344 { 345 write_log( "$self: Could not connect to DB $gDB " . mysqli_error( $gLink ) ); 359 346 return; 360 347 } … … 362 349 // Update message and update status to 'FINISHED' 363 350 $query = "UPDATE analysis SET status='FINISHED', " . 364 "queue_msg='" . mysql _real_escape_string($message ) . "' " .351 "queue_msg='" . mysqli_real_escape_string( $gLink, $message ) . "' " . 365 352 "WHERE gfacID='$gfacID'"; 366 353 367 mysql _query( $query, $gLink);354 mysqli_query( $gLink, $query ); 368 355 write_log( "$self: Status FINISHED and 'Finished...' message updated" ); 369 356 … … 371 358 $query = "SELECT id FROM analysis " . 372 359 "WHERE gfacID = '$gfacID'"; 373 $result = mysql _query( $query, $gLink);360 $result = mysqli_query( $gLink, $query ); 374 361 if ( ! $result ) 375 362 { 376 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );377 return; 378 } 379 380 if ( mysql _num_rows( $result ) == 0 )363 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 364 return; 365 } 366 367 if ( mysqli_num_rows( $result ) == 0 ) 381 368 { 382 369 // write_log( "$self: can't find $gfacID in GFAC db" ); … … 384 371 } 385 372 386 list( $aID ) = mysql _fetch_array( $result );373 list( $aID ) = mysqli_fetch_array( $result ); 387 374 388 375 $query = "INSERT INTO queue_messages " . 389 376 "SET analysisID = $aID, " . 390 "message = '" . mysql _real_escape_string($message ) . "'";391 $result = mysql _query( $query, $gLink);377 "message = '" . mysqli_real_escape_string( $gLink, $message ) . "'"; 378 $result = mysqli_query( $gLink, $query ); 392 379 if ( ! $result ) 393 380 { 394 write_log( "$self: bad query: $query " . mysql _error( $gLink ) );395 return; 396 } 397 398 mysql _close( $gLink );381 write_log( "$self: bad query: $query " . mysqli_error( $gLink ) ); 382 return; 383 } 384 385 mysqli_close( $gLink ); 399 386 } 400 387 ?> -
trunk/runID_info.php
r15 r35 28 28 29 29 global $uses_airavata; 30 global $link; 30 31 31 32 ?> … … 62 63 function experiment_select( $select_name, $current_ID = NULL ) 63 64 { 65 global $link; 64 66 $myID = $_SESSION['id']; 65 67 … … 72 74 $users_clause . 73 75 "ORDER BY lname, runID "; 74 $result = mysql _query($query )75 or die( "Query failed : $query<br />" . mysql _error() );76 77 if ( mysql _num_rows( $result ) == 0 ) return "";76 $result = mysqli_query( $link, $query ) 77 or die( "Query failed : $query<br />" . mysqli_error($link) ); 78 79 if ( mysqli_num_rows( $result ) == 0 ) return ""; 78 80 79 81 $text = "<form action='{$_SERVER['PHP_SELF']}' method='post'>\n" . 80 82 " <select name='$select_name' size='1' onchange='form.submit();'>\n" . 81 83 " <option value=-1>Please select...</option>\n"; 82 while ( list( $experimentID, $runID, $lname ) = mysql _fetch_array( $result ) )84 while ( list( $experimentID, $runID, $lname ) = mysqli_fetch_array( $result ) ) 83 85 { 84 86 $selected = ( $current_ID == $experimentID ) ? " selected='selected'" : ""; … … 95 97 function runID_info( $experimentID ) 96 98 { 99 global $link; 97 100 $query = "SELECT people.personID, personGUID, lname, fname, email " . 98 101 "FROM experiment, projectPerson, people " . … … 100 103 "AND experiment.projectID = projectPerson.projectID " . 101 104 "AND projectPerson.personID = people.personID "; 102 $result = mysql _query($query )103 or die( "Query failed : $query<br />\n" . mysql _error() );104 list( $ID, $GUID, $lname, $fname, $email ) = mysql _fetch_array( $result );105 $result = mysqli_query( $link, $query ) 106 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 107 list( $ID, $GUID, $lname, $fname, $email ) = mysqli_fetch_array( $result ); 105 108 106 109 $text = <<<HTML … … 126 129 "WHERE experimentID = $experimentID " . 127 130 "AND experiment.rotorCalibrationID = rotorCalibration.rotorCalibrationID "; 128 $result = mysql _query($query )129 or die( "Query failed : $query<br />\n" . mysql _error() );130 list( $GUID, $coeff1, $coeff2, $type, $runType ) = mysql _fetch_array( $result );131 $result = mysqli_query( $link, $query ) 132 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 133 list( $GUID, $coeff1, $coeff2, $type, $runType ) = mysqli_fetch_array( $result ); 131 134 $text .= <<<HTML 132 135 <table cellspacing='0' cellpadding='0' class='admin'> … … 154 157 "WHERE experimentID = $experimentID " . 155 158 "ORDER BY filename "; 156 $result = mysql _query($query )157 or die( "Query failed : $query<br />\n" . mysql _error() );158 159 if ( mysql _num_rows( $result ) == 0 )159 $result = mysqli_query( $link, $query ) 160 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 161 162 if ( mysqli_num_rows( $result ) == 0 ) 160 163 return $text; 161 164 … … 176 179 HTML; 177 180 178 while ( list( $ID, $GUID, $filename, $solutionID ) = mysql _fetch_array( $result ) )181 while ( list( $ID, $GUID, $filename, $solutionID ) = mysqli_fetch_array( $result ) ) 179 182 { 180 183 $rawIDs[] = $ID; … … 200 203 "WHERE rawDataID IN ( $rawIDs_csv ) " . 201 204 "ORDER BY editedDataID, filename "; 202 $result = mysql _query($query )203 or die( "Query failed : $query<br />\n" . mysql _error() );204 205 if ( mysql _num_rows( $result ) == 0 )205 $result = mysqli_query( $link, $query ) 206 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 207 208 if ( mysqli_num_rows( $result ) == 0 ) 206 209 return $text; 207 210 … … 222 225 223 226 $editIDs = array(); 224 while ( list ( $editID, $rawID, $GUID, $filename ) = mysql _fetch_array( $result ) )227 while ( list ( $editID, $rawID, $GUID, $filename ) = mysqli_fetch_array( $result ) ) 225 228 { 226 229 $editIDs[] = $editID; … … 245 248 "WHERE editedDataID IN ( $editIDs_csv ) " . 246 249 "ORDER BY modelID "; 247 $result = mysql _query($query )248 or die( "Query failed : $query<br />\n" . mysql _error() );249 250 if ( mysql _num_rows( $result ) != 0 )250 $result = mysqli_query( $link, $query ) 251 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 252 253 if ( mysqli_num_rows( $result ) != 0 ) 251 254 { 252 255 $text .= <<<HTML … … 268 271 269 272 $modelIDs = array(); 270 while ( list ( $modelID, $editID, $GUID, $variance, $meniscus, $personID ) = mysql _fetch_array( $result ) )273 while ( list ( $modelID, $editID, $GUID, $variance, $meniscus, $personID ) = mysqli_fetch_array( $result ) ) 271 274 { 272 275 $modelIDs[] = $modelID; … … 295 298 "WHERE modelID IN ( $modelIDs_csv ) " . 296 299 "ORDER BY noiseID "; 297 $result = mysql _query($query )298 or die( "Query failed : $query<br />\n" . mysql _error() );299 300 if ( mysql _num_rows( $result ) != 0 )300 $result = mysqli_query( $link, $query ) 301 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 302 303 if ( mysqli_num_rows( $result ) != 0 ) 301 304 { 302 305 $text .= <<<HTML … … 317 320 HTML; 318 321 319 while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysql _fetch_array( $result ) )322 while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysqli_fetch_array( $result ) ) 320 323 { 321 324 $text .= <<<HTML … … 340 343 "WHERE editedDataID IN ( $editIDs_csv ) " . 341 344 "ORDER BY noiseID "; 342 $result = mysql _query($query )343 or die( "Query failed : $query<br />\n" . mysql _error() );344 345 if ( mysql _num_rows( $result ) != 0 )345 $result = mysqli_query( $link, $query ) 346 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 347 348 if ( mysqli_num_rows( $result ) != 0 ) 346 349 { 347 350 $text .= <<<HTML … … 362 365 HTML; 363 366 364 while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysql _fetch_array( $result ) )367 while ( list ( $noiseID, $GUID, $editID, $modelID, $modelGUID, $type ) = mysqli_fetch_array( $result ) ) 365 368 { 366 369 $text .= <<<HTML … … 386 389 "ORDER BY reportID "; 387 390 388 $result = mysql _query($query )389 or die( "Query failed : $query<br />\n" . mysql _error() );390 391 if ( mysql _num_rows( $result ) != 0 )391 $result = mysqli_query( $link, $query ) 392 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 393 394 if ( mysqli_num_rows( $result ) != 0 ) 392 395 { 393 396 $text .= <<<HTML … … 405 408 HTML; 406 409 407 while ( list ( $reportID, $GUID, $title ) = mysql _fetch_array( $result ) )410 while ( list ( $reportID, $GUID, $title ) = mysqli_fetch_array( $result ) ) 408 411 { 409 412 $reportIDs[] = $reportID; … … 430 433 "ORDER BY reportID, reportTripleID "; 431 434 432 $result = mysql _query($query )433 or die( "Query failed : $query<br />\n" . mysql _error() );434 435 if ( mysql _num_rows( $result ) != 0 )435 $result = mysqli_query( $link, $query ) 436 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 437 438 if ( mysqli_num_rows( $result ) != 0 ) 436 439 { 437 440 $text .= <<<HTML … … 453 456 454 457 while ( list ( $reportTripleID, $GUID, $resultID, $triple, $dataDesc, $rptID ) 455 = mysql _fetch_array( $result ) )458 = mysqli_fetch_array( $result ) ) 456 459 { 457 460 $reportTripleIDs[] = $reportTripleID; … … 483 486 "ORDER BY reportTripleID, reportDocumentID "; 484 487 485 $result = mysql _query($query )486 or die( "Query failed : $query<br />\n" . mysql _error() );487 488 if ( mysql _num_rows( $result ) != 0 )488 $result = mysqli_query( $link, $query ) 489 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 490 491 if ( mysqli_num_rows( $result ) != 0 ) 489 492 { 490 493 $text .= <<<HTML … … 507 510 while ( list ( $reportDocumentID, $GUID, $editID, $label, $filename, 508 511 $analysis, $subAnal, $docType, $tripID ) 509 = mysql _fetch_array( $result ) )512 = mysqli_fetch_array( $result ) ) 510 513 { 511 514 $text .= <<<HTML … … 531 534 "WHERE experimentID = $experimentID " . 532 535 "ORDER BY HPCAnalysisRequestID "; 533 $result = mysql _query($query )534 or die( "Query failed : $query<br />\n" . mysql _error() );535 536 if ( mysql _num_rows( $result ) == 0 )536 $result = mysqli_query( $link, $query ) 537 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 538 539 if ( mysqli_num_rows( $result ) == 0 ) 537 540 return $text; 538 541 … … 554 557 HTML; 555 558 556 while ( list( $ID, $GUID, $filename, $submit, $cluster, $method ) = mysql _fetch_array( $result ) )559 while ( list( $ID, $GUID, $filename, $submit, $cluster, $method ) = mysqli_fetch_array( $result ) ) 557 560 { 558 561 $requestIDs[] = $ID; … … 579 582 "WHERE HPCAnalysisRequestID IN ( $requestIDs_csv ) " . 580 583 "ORDER BY HPCAnalysisResultID "; 581 $result = mysql _query($query )582 or die( "Query failed : $query<br />\n" . mysql _error() );583 584 if ( mysql _num_rows( $result ) != 0 )584 $result = mysqli_query( $link, $query ) 585 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 586 587 if ( mysqli_num_rows( $result ) != 0 ) 585 588 { 586 589 $text .= <<<HTML … … 600 603 601 604 $incomplete = array(); 602 while ( list( $ID, $requestID, $gfacID, $status, $updated ) = mysql _fetch_array( $result ) )605 while ( list( $ID, $requestID, $gfacID, $status, $updated ) = mysqli_fetch_array( $result ) ) 603 606 { 604 607 if ( $status != 'completed' ) … … 628 631 global $globaldbhost, $globaldbuser, $globaldbpasswd, $globaldbname; 629 632 630 $globaldb = mysql _connect( $globaldbhost, $globaldbuser, $globaldbpasswd);633 $globaldb = mysqli_connect( $globaldbhost, $globaldbuser, $globaldbpasswd, $globaldbname ); 631 634 632 635 if ( ! $globaldb ) 633 636 { 634 $text .= "<p>Cannot open global database on $globaldbhost</p>\n"; 635 return $text; 636 } 637 638 if ( ! mysql_select_db( $globaldbname, $globaldb ) ) 639 { 640 $text .= "<p>Cannot change to global database $globaldbname</p>\n"; 637 $text .= "<p>Cannot open global database on $globaldbhost : $globaldbname</p>\n"; 641 638 return $text; 642 639 } … … 665 662 "FROM analysis " . 666 663 "WHERE gfacID = '$gfacID' "; 667 $result = mysql _query($query )668 or die( "Query failed : $query<br />\n" . mysql _error() );669 670 if ( mysql _num_rows( $result ) == 1 )664 $result = mysqli_query( $link, $query ) 665 or die( "Query failed : $query<br />\n" . mysqli_error($link) ); 666 667 if ( mysqli_num_rows( $result ) == 1 ) 671 668 { 672 669 $in_queue++; 673 list( $cluster, $db, $status, $msg, $time ) = mysql _fetch_array( $result );670 list( $cluster, $db, $status, $msg, $time ) = mysqli_fetch_array( $result ); 674 671 $text .= <<<HTML 675 672 <tr><td>$gfacID</td> … … 691 688 "</table>\n"; 692 689 693 mysql _close( $globaldb );690 mysqli_close( $globaldb ); 694 691 695 692 return $text; … … 698 695 function HPCDetail( $requestID ) 699 696 { 697 global $link; 700 698 $query = "SELECT * FROM HPCAnalysisRequest WHERE HPCAnalysisRequestID=$requestID"; 701 $result = mysql _query($query )702 or die( "Query failed : $query<br />\n" . mysql _error());703 $row = mysql _fetch_assoc( $result );699 $result = mysqli_query( $link, $query ) 700 or die( "Query failed : $query<br />\n" . mysqli_error($link)); 701 $row = mysqli_fetch_assoc( $result ); 704 702 $row['requestXMLFile'] = '<pre>' . htmlentities( $row['requestXMLFile'] ) . '</pre>'; 705 703 … … 722 720 723 721 $query = "SELECT * FROM HPCAnalysisResult WHERE HPCAnalysisRequestID=$requestID"; 724 $result = mysql _query($query )725 or die( "Query failed : $query<br />\n" . mysql _error());726 $row = mysql _fetch_assoc( $result );722 $result = mysqli_query( $link, $query ) 723 or die( "Query failed : $query<br />\n" . mysqli_error($link)); 724 $row = mysqli_fetch_assoc( $result ); 727 725 $row['jobfile'] = '<pre>' . htmlentities( $row['jobfile'] ) . '</pre>'; 728 726 … … 761 759 "WHERE HPCAnalysisResultID = $resultID " . 762 760 "AND HPCAnalysisResultType = 'model' "; 763 $result = mysql _query($query )764 or die( "Query failed : $query<br />\n" . mysql _error());765 $models = mysql _fetch_row( $result ); // An array with all of them761 $result = mysqli_query( $link, $query ) 762 or die( "Query failed : $query<br />\n" . mysqli_error($link)); 763 $models = mysqli_fetch_row( $result ); // An array with all of them 766 764 if ( $models !== false ) 767 765 $row['modelIDs'] = implode( ", ", $models ); … … 770 768 "WHERE HPCAnalysisResultID = $resultID " . 771 769 "AND HPCAnalysisResultType = 'noise' "; 772 $result = mysql _query($query )773 or die( "Query failed : $query<br />\n" . mysql _error());774 $noise = mysql _fetch_row( $result ); // An array with all of them770 $result = mysqli_query( $link, $query ) 771 or die( "Query failed : $query<br />\n" . mysqli_error($link)); 772 $noise = mysqli_fetch_row( $result ); // An array with all of them 775 773 if ( $noise !== false ) 776 774 $row['noiseIDs'] = implode( ", ", $noise ); -
trunk/update_notice.php
r34 r35 92 92 // "none" - present in both and messages identical (no DB update). 93 93 94 $noteLink = mysql _connect( $dbhost, $dbuser, $dbpassw);94 $noteLink = mysqli_connect( $dbhost, $dbuser, $dbpassw, $notice_db ); 95 95 96 if ( ! mysql_select_db( $notice_db, $noteLink ))96 if ( ! $noteLink ) 97 97 { 98 echo "Could not select DB $notice_db - " . mysql_error() . "\n";98 echo "Could not connect to DB $notice_db - " . mysqli_error($noteLink) . "\n"; 99 99 exit(); 100 100 } … … 102 102 $query = "SELECT id, type, revision, message FROM notice"; 103 103 104 $result = mysql _query( $query, $noteLink)105 or die( "Query failed : $query<br />" . mysql _error() );104 $result = mysqli_query( $noteLink, $query ) 105 or die( "Query failed : $query<br />" . mysqli_error($noteLink) ); 106 106 107 107 echo "=====START of DB QUERY LOOP===== \n"; 108 $num_rows = mysql _num_rows( $result );108 $num_rows = mysqli_num_rows( $result ); 109 109 110 110 echo " numrows = $num_rows \n"; 111 while ( list( $id, $type, $rev, $msg ) = mysql _fetch_array( $result ) )111 while ( list( $id, $type, $rev, $msg ) = mysqli_fetch_array( $result ) ) 112 112 { 113 113 $key = $type . $rev; … … 180 180 echo " query: [ $query ] \n"; 181 181 182 $result = mysql _query( $query, $noteLink)183 or die( "Query failed : $query<br />" . mysql _error() );182 $result = mysqli_query( $noteLink, $query ) 183 or die( "Query failed : $query<br />" . mysqli_error($noteLink) ); 184 184 185 185 }
Note:
See TracChangeset
for help on using the changeset viewer.