- Timestamp:
- Apr 7, 2023, 4:50:38 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/check_chip_locations.pl
r42444 r42445 17 17 18 18 my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts; 19 my ($neb_dbh, $gpc_dbh ) = &parse_db_config ("$topdir/nebulous.config");19 my ($neb_dbh, $gpc_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config"); 20 20 21 21 # read the list of chip_ids: … … 32 32 # instance lists by host: YYYYMMDD/HOSTNAME.inst.STAGE.txt 33 33 # chip states by chip: YYYYMMDD/CHIPNAME.uris.STAGE.txt 34 35 my $Nchip = 0; 36 37 my $Ngood = 0; 38 my $Ndead = 0; 39 my $Ngone = 0; 40 my $Nsing = 0; 41 my $Ndups = 0; 42 my $Nsbck = 0; 43 my $Nxbck = 0; 44 45 my $Ncul1 = 0; 46 my $Ncul2 = 0; 47 my $Ncul3 = 0; 34 48 35 49 foreach my $chip_id (@chip_ids) { … … 90 104 } 91 105 92 # run neb-replicate for SING entries? 93 # run neb-replicate for SBCK entries? (does this put a second copy at ATRC or ITC?) 94 # save the list of instances on each host 95 ## run md5sum on the instances for each host 96 ## only note inconsistent md5sums? (need to save the gpc1 md5sum values) 97 # rerun to generate a list of the host with max instances per chip? 98 99 ### when to cull entries? 100 ## neb-replicate puts the new entry at ATRC by default 101 ## neb-replicate --volume VOL puts the new entry at the specified location 102 ### in order to use this, I need to choose the target volume 106 print "Nchip: $Nchip\n"; 107 print "Ngood: $Ngood\n"; 108 print "Ngone: $Ngone\n"; 109 print "Ndead: $Ndead\n"; 110 print "Nsing: $Nsing\n"; 111 print "Ndups: $Ndups\n"; 112 print "Nsbck: $Nsbck\n"; 113 print "Nxbck: $Nxbck\n"; 114 print "Ncul1: $Ncul1\n"; 115 print "Ncul2: $Ncul2\n"; 116 print "Ncul3: $Ncul3\n"; 117 118 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3; 119 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 120 121 # update the stats in the database 122 my $sql_update_stats = "UPDATE nights set"; 123 $sql_update_stats .= " Nchip = $Nchip"; 124 $sql_update_stats .= ", Ngood = $Ngood"; 125 $sql_update_stats .= ", Ndead = $Ndead"; 126 $sql_update_stats .= ", Ngone = $Ngone"; 127 $sql_update_stats .= ", Nsing = $Nsing"; 128 $sql_update_stats .= ", Ndups = $Ndups"; 129 $sql_update_stats .= ", Nsbck = $Nsbck"; 130 $sql_update_stats .= ", Nxbck = $Nxbck"; 131 $sql_update_stats .= ", Ncul1 = $Ncul1"; 132 $sql_update_stats .= ", Ncul2 = $Ncul2"; 133 $sql_update_stats .= ", Ncul3 = $Ncul3"; 134 $sql_update_stats .= " WHERE dateobs = $dateword"; 135 136 my $query = $raw_dbh->prepare($sql_update_stats); 137 $query->execute () or die "invalid response from RAW database\n"; 103 138 104 139 exit 0; … … 256 291 257 292 my $outinfo = "$extID $data_st $md5_sum"; 293 $Nchip ++; 258 294 259 295 # GOOD : already fixed 260 296 if (($Nmain == 1) && ($Nback == 1)) { 261 297 print $outfh "GOOD: $outinfo\n"; 298 $Ngood ++; 262 299 return; 263 300 } … … 267 304 if (($Nmain == 1) && ($Nback == 0)) { 268 305 print $outfh "SING: $outinfo\n"; 306 $Nsing ++; 269 307 return; 270 308 } … … 274 312 if (($Nmain == 0) && ($Nback == 1)) { 275 313 print $outfh "SBCK: $outinfo\n"; 314 $Nsbck ++; 276 315 return; 277 316 } … … 281 320 if (($Nmain > 1) && ($Nback == 0)) { 282 321 print $outfh "DUPS: $outinfo\n"; 322 $Ndups ++; 283 323 return; 284 324 } … … 288 328 if (($Nmain == 0) && ($Nback > 1)) { 289 329 print $outfh "XBCK: $outinfo\n"; 330 $Nxbck ++; 290 331 return; 291 332 } … … 294 335 if (($Nmain == 0) && ($Nback == 0) && $Ndead) { 295 336 print $outfh "DEAD: $outinfo\n"; 337 $Ndead ++; 296 338 return; 297 339 } … … 299 341 if (($Nmain == 0) && ($Nback == 0) && ($Ndead == 0)) { 300 342 print $outfh "GONE: $outinfo\n"; 343 $Ngone ++; 301 344 return; 302 345 } … … 306 349 if (($Nmain > 1) && ($Nback == 1)) { 307 350 print $outfh "CUL1: $outinfo\n"; 351 $Ncul1 ++; 308 352 return; 309 353 } … … 313 357 if (($Nback > 1) && ($Nmain == 1)) { 314 358 print $outfh "CUL2: $outinfo\n"; 359 $Ncul2 ++; 315 360 return; 316 361 } … … 320 365 if (($Nback > 1) && ($Nmain > 1)) { 321 366 print $outfh "CUL3: $outinfo\n"; 367 $Ncul3 ++; 322 368 return; 323 369 } … … 335 381 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 336 382 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 337 pod2usage( -msg => "Define the stage ( v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;383 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 338 384 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 339 385 … … 363 409 my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user ); 364 410 my ( $gpcdb_name, $gpcdb_host, $gpcdb_port, $gpcdb_pass, $gpcdb_user ); 411 my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user ); 365 412 366 413 if (-e $conffile) { … … 380 427 if ($_ =~ /GPC1_PASS /) { $gpcdb_pass = (split /\s+/,$_)[2]; } 381 428 if ($_ =~ /GPC1_PORT /) { $gpcdb_port = (split /\s+/,$_)[2]; } 429 430 if ($_ =~ /RAW_NAME /) { $rawdb_name = (split /\s+/,$_)[2]; } 431 if ($_ =~ /RAW_HOST /) { $rawdb_host = (split /\s+/,$_)[2]; } 432 if ($_ =~ /RAW_USER /) { $rawdb_user = (split /\s+/,$_)[2]; } 433 if ($_ =~ /RAW_PASS /) { $rawdb_pass = (split /\s+/,$_)[2]; } 434 if ($_ =~ /RAW_PORT /) { $rawdb_port = (split /\s+/,$_)[2]; } 382 435 } 383 436 close(IN); 384 437 print STDERR "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n"; 385 438 print STDERR "gpc1 dbh config: $gpcdb_name $gpcdb_host $gpcdb_port $gpcdb_user $gpcdb_pass\n"; 439 print STDERR "raw dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n"; 386 440 } 387 441 … … 398 452 pod2usage( -msg => "Cannot configure gpc1 database (dbpass)", -exitval => 2) unless defined $gpcdb_pass; 399 453 454 pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name; 455 pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host; 456 pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user; 457 pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port; 458 pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass; 459 400 460 my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host"; 401 461 if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; } … … 406 466 my $gpc_dbh = DBI->connect($gpcdb_dsn, $gpcdb_user, $gpcdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n"; 407 467 408 return ($neb_dbh, $gpc_dbh); 468 my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host"; 469 if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; } 470 my $raw_dbh = DBI->connect($rawdb_dsn, $rawdb_user, $rawdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n"; 471 472 return ($neb_dbh, $gpc_dbh, $raw_dbh); 409 473 } 410 474
Note:
See TracChangeset
for help on using the changeset viewer.
