Changeset 42531
- Timestamp:
- Aug 17, 2023, 4:41:34 PM (3 years ago)
- Location:
- branches/eam_branches/ipp-20230313/tools
- Files:
-
- 2 deleted
- 16 edited
- 21 copied
-
. (modified) (1 prop)
-
eam/rawfix.20230221/Makefile (copied) (copied from trunk/tools/eam/rawfix.20230221/Makefile )
-
eam/rawfix.20230221/src.v0 (copied) (copied from trunk/tools/eam/rawfix.20230221/src.v0 )
-
eam/rawfix.20230221/src/advance.rawfix.pl (copied) (copied from trunk/tools/eam/rawfix.20230221/src/advance.rawfix.pl )
-
eam/rawfix.20230221/src/advance.rawfix.sh (copied) (copied from trunk/tools/eam/rawfix.20230221/src/advance.rawfix.sh )
-
eam/rawfix.20230221/src/check.rawfix.sh (modified) (5 diffs)
-
eam/rawfix.20230221/src/check_chip_locations.pl (modified) (17 diffs)
-
eam/rawfix.20230221/src/check_chip_locations.v0.pl (deleted)
-
eam/rawfix.20230221/src/check_md5s_dateobs.pl (modified) (5 diffs)
-
eam/rawfix.20230221/src/check_night_status.pl (copied) (copied from trunk/tools/eam/rawfix.20230221/src/check_night_status.pl )
-
eam/rawfix.20230221/src/create.rawfix.sh (modified) (2 diffs)
-
eam/rawfix.20230221/src/finish.fixchip.sh (copied) (copied from trunk/tools/eam/rawfix.20230221/src/finish.fixchip.sh )
-
eam/rawfix.20230221/src/fix_chip_failures.pl (copied) (copied from trunk/tools/eam/rawfix.20230221/src/fix_chip_failures.pl )
-
eam/rawfix.20230221/src/fix_chip_locations.pl (modified) (14 diffs)
-
eam/rawfix.20230221/src/get_hosts_fixchip.sh (copied) (copied from trunk/tools/eam/rawfix.20230221/src/get_hosts_fixchip.sh )
-
eam/rawfix.20230221/src/get_hosts_md5s.sh (modified) (1 diff)
-
eam/rawfix.20230221/src/get_md5s_dateobs.pl (deleted)
-
eam/rawfix.20230221/src/get_md5s_instances.pl (modified) (7 diffs)
-
eam/rawfix.20230221/src/ipp_apply_burntool_psvideo.pl (copied) (copied from trunk/tools/eam/rawfix.20230221/src/ipp_apply_burntool_psvideo.pl )
-
eam/rawfix.20230221/src/psvideostats.sh (copied) (copied from trunk/tools/eam/rawfix.20230221/src/psvideostats.sh )
-
eam/rawfix.20230221/src/queue.rawfix.sh (modified) (1 diff)
-
eam/rawfix.20230221/src/rawfix.advance.pt (copied) (copied from trunk/tools/eam/rawfix.20230221/src/rawfix.advance.pt )
-
eam/rawfix.20230221/src/rawfix.burntool.pt (copied) (copied from trunk/tools/eam/rawfix.20230221/src/rawfix.burntool.pt )
-
eam/rawfix.20230221/src/rawfix.ckchip.pt (modified) (5 diffs)
-
eam/rawfix.20230221/src/rawfix.fixchip.pt (modified) (8 diffs)
-
eam/rawfix.20230221/src/rawfix.md5chk.pt (copied) (copied from trunk/tools/eam/rawfix.20230221/src/rawfix.md5chk.pt )
-
eam/rawfix.20230221/src/rawfix.md5sum.pt (modified) (13 diffs)
-
eam/rawfix.20230221/src/rawfix.pt (modified) (1 diff)
-
eam/rawfix.20230221/src/select.nights.sql (copied) (copied from trunk/tools/eam/rawfix.20230221/src/select.nights.sql )
-
eam/rawfix.20230221/src/task.test.pt (copied) (copied from trunk/tools/eam/rawfix.20230221/src/task.test.pt )
-
eam/rawfix.20230221/src/update.rawfix.sh (modified) (2 diffs)
-
eam/rawfix.20230221/src/update_chip_stats.pl (copied) (copied from trunk/tools/eam/rawfix.20230221/src/update_chip_stats.pl )
-
eam/rebalance/launch.find.sh (copied) (copied from trunk/tools/eam/rebalance/launch.find.sh )
-
eam/rebalance/launch.insert.sh (copied) (copied from trunk/tools/eam/rebalance/launch.insert.sh )
-
eam/rebalance/launch.rsync.sh (modified) (1 diff)
-
eam/skycoverage/coverage.css (copied) (copied from trunk/tools/eam/skycoverage/coverage.css )
-
eam/skycoverage/coverage.mana.sh (modified) (1 diff)
-
eam/skycoverage/gpc1.tgz (copied) (copied from trunk/tools/eam/skycoverage/gpc1.tgz )
-
eam/skycoverage/gpc2.tgz (copied) (copied from trunk/tools/eam/skycoverage/gpc2.tgz )
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/tools
- Property svn:mergeinfo changed
/trunk/tools (added) merged: 42411,42415-42417,42429-42430,42440-42447,42449-42455,42457-42460,42462,42464-42465,42467-42468,42485
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/check.rawfix.sh
r42406 r42531 14 14 15 15 # make the rawfix database to track rawfix operations 16 set DBHOST = "ipp 060"16 set DBHOST = "ippc190" 17 17 set DBNAME = "rawfix" 18 set DBUSER = "dvo"19 set DBPASS = "dvo"18 # set DBUSER = "dvo" 19 # set DBPASS = "dvo" 20 20 21 21 # set DBOPTS = "-B --skip-column-names -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME" 22 set DBOPTS = "- B -h $DBHOST -u $DBUSER -p$DBPASS$DBNAME"22 set DBOPTS = "--defaults-extra-file=~/.my.cnf.rawfix -B -h $DBHOST $DBNAME" 23 23 24 24 if ($mode == "all") then … … 28 28 endif 29 29 30 mysql $DBOPTS -e "select dateobs, state from nights"30 mysql $DBOPTS -e "select dateobs, iter, state from nights" 31 31 exit 0 32 32 endif … … 49 49 50 50 set mynight = $2 51 mysql $DBOPTS - e "select dateobs, statefrom nights where (dateobs = '$mynight')"51 mysql $DBOPTS -E -e "select * from nights where (dateobs = '$mynight')" 52 52 exit 0 53 53 endif … … 61 61 set mystate = $2 62 62 63 if ($mystate == "new") goto good_state 64 if ($mystate == "rsync") goto good_state 65 if ($mystate == "md5sum.new") goto good_state 66 if ($mystate == "md5sum.done") goto good_state 67 if ($mystate == "md5sum.fail") goto good_state 68 if ($mystate == "ckchip.new") goto good_state 69 if ($mystate == "ckchip.done") goto good_state 70 if ($mystate == "ckchip.fail") goto good_state 71 if ($mystate == "fixchip.new") goto good_state 72 if ($mystate == "fixchip.done") goto good_state 73 if ($mystate == "fixchip.fail") goto good_state 63 if ($mystate == "ckchip.new") goto good_state 64 if ($mystate == "ckchip.done") goto good_state 65 if ($mystate == "ckchip.fail") goto good_state 66 if ($mystate == "fixchip.new") goto good_state 67 if ($mystate == "fixchip.done") goto good_state 68 if ($mystate == "fixchip.fail") goto good_state 69 if ($mystate == "md5sum.new") goto good_state 70 if ($mystate == "md5sum.done") goto good_state 71 if ($mystate == "md5sum.fail") goto good_state 72 if ($mystate == "md5chk.new") goto good_state 73 if ($mystate == "md5chk.done") goto good_state 74 if ($mystate == "md5chk.fail") goto good_state 75 if ($mystate == "burntool.new") goto good_state 76 if ($mystate == "burntool.done") goto good_state 77 if ($mystate == "burntool.fail") goto good_state 74 78 75 79 echo "ERROR: unknown mode $mystate" … … 77 81 78 82 good_state: 79 mysql $DBOPTS -e "select dateobs from nights where (state = '$mystate')" 83 set t = `date +%T..%N` 84 mysql $DBOPTS -e "select dateobs, iter from nights where (state = '$mystate')" | awk -v T=$t '(NR == 1){print $0, "timestamp"}(NR > 1){print $1, $2, T}' 80 85 exit 0 81 86 endif -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/check_chip_locations.pl
r42406 r42531 13 13 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 14 14 15 # USAGE: check_chip_locations.pl --dateobs (night) --chiplist (file) 16 # USAGE: check_chip_locations.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt 17 18 my ($fulldate, $dateword, $chiplist ) = &parse_cmdopts;19 my ($neb_dbh, $gpc_dbh ) = &parse_db_config ('nebulous.config');15 # USAGE: check_chip_locations.pl --dateobs (night) --chiplist (file) --stage (0,1,etc) 16 # USAGE: check_chip_locations.pl --dateobs 2010/05/01 --chiplist gpc1.chips.txt --stage 0 17 18 my ($fulldate, $dateword, $chiplist, $stage, $topdir, $basedir) = &parse_cmdopts; 19 my ($neb_dbh, $gpc_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config"); 20 20 21 21 # read the list of chip_ids: … … 27 27 28 28 # put output files in a directory defined by the night 29 mkdir $dateword;29 mkdir "$basedir/$dateword"; 30 30 31 31 # output files: 32 # instance lists by host: YYYYMMDD/HOSTNAME.inst.txt 33 # chip states by chip: YYYYMMDD/CHIPNAME.uris.txt 32 # instance lists by host: YYYYMMDD/HOSTNAME.inst.STAGE.txt 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; 48 my $Nfail = 0; 49 50 my ($goodchips_r, $failchips_r) = &get_good_or_fail_chiplists ($basedir, $dateword, $stage); 34 51 35 52 foreach my $chip_id (@chip_ids) { 36 53 37 my $outfile = "$dateword/$chip_id.uris.txt";38 54 my $outfh; 39 open ($outfh, ">$outfile"); 55 open ($outfh, ">$basedir/$dateword/$chip_id.uris.$stage.txt"); 56 57 # print "open $basedir/$dateword/$chip_id.uris.$stage.txt\n"; 40 58 41 59 # get the list of chip neb paths for one chip 42 60 my ($neb_paths_r, $ds_array_r, $md_array_r) = &get_chip_paths ($fulldate, $chip_id); 43 44 # I think this makes a copy of the arrays, which is inefficient45 # my @neb_paths = @$neb_paths_r;46 # my @ds_array = @$ds_array_r;47 # my @md_array = @$md_array_r;48 61 49 62 # reset the hostcount for this chip … … 65 78 66 79 # determine the status of the instances 67 my ($Nmain, $Nback, $N dead) = &check_instance_xattr ($inforows, $ext_id, $data_st, $md5_sum);68 69 &check_instance_state ($outfh, $ext_id, $ Nmain, $Nback, $Ndead);80 my ($Nmain, $Nback, $Nlost) = &check_instance_xattr ($inforows, $ext_id, $data_st, $md5_sum); 81 82 &check_instance_state ($outfh, $ext_id, $data_st, $md5_sum, $Nmain, $Nback, $Nlost); 70 83 } 71 84 … … 74 87 # now save the host count for this chip 75 88 my $hostfh; 76 open ($hostfh, ">$ dateword/$chip_id.hosts.txt");89 open ($hostfh, ">$basedir/$dateword/$chip_id.hosts.txt"); 77 90 78 91 # save the host count for this chip 79 92 my @hostnames = keys %hostcount; 80 93 foreach my $myname (@hostnames) { 81 print $hostfh " host $myname =$hostcount{$myname}\n";94 print $hostfh "$myname $hostcount{$myname}\n"; 82 95 } 83 96 close ($hostfh); … … 91 104 } 92 105 93 # run neb-replicate for SING entries? 94 # run neb-replicate for SBCK entries? (does this put a second copy at ATRC or ITC?) 95 # save the list of instances on each host 96 ## run md5sum on the instances for each host 97 ## only note inconsistent md5sums? (need to save the gpc1 md5sum values) 98 # rerun to generate a list of the host with max instances per chip? 99 100 ### when to cull entries? 101 ## neb-replicate puts the new entry at ATRC by default 102 ## neb-replicate --volume VOL puts the new entry at the specified location 103 ### 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 print "Nfail: $Nfail\n"; 118 119 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 120 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 121 122 # update the stats in the database 123 my $sql_update_stats = "UPDATE nights set"; 124 $sql_update_stats .= " Nchip = $Nchip"; 125 $sql_update_stats .= ", Ngood = $Ngood"; 126 $sql_update_stats .= ", Ndead = $Ndead"; 127 $sql_update_stats .= ", Ngone = $Ngone"; 128 $sql_update_stats .= ", Nsing = $Nsing"; 129 $sql_update_stats .= ", Ndups = $Ndups"; 130 $sql_update_stats .= ", Nsbck = $Nsbck"; 131 $sql_update_stats .= ", Nxbck = $Nxbck"; 132 $sql_update_stats .= ", Ncul1 = $Ncul1"; 133 $sql_update_stats .= ", Ncul2 = $Ncul2"; 134 $sql_update_stats .= ", Ncul3 = $Ncul3"; 135 $sql_update_stats .= ", Nfail = $Nfail"; 136 $sql_update_stats .= " WHERE dateobs = $dateword"; 137 138 my $query = $raw_dbh->prepare($sql_update_stats); 139 $query->execute () or die "invalid response from RAW database\n"; 104 140 105 141 exit 0; … … 121 157 my @chip_ids; 122 158 123 open(CHIPS, $chiplist) or die "cannot open file $chiplist\n";159 open(CHIPS,"$topdir/$chiplist") or die "cannot open file $chiplist\n"; 124 160 125 161 my @lines = <CHIPS>; … … 160 196 if ($Nvalues != 3) { print "ERROR: invalid response?\n"; next; } 161 197 198 # data_state and possibly md5sum can be NULL, need to handle specially 199 my $dstate = $values[1]; if (not defined $dstate) { $dstate = "NULL"; } 200 my $md5sum = $values[2]; if (not defined $md5sum) { $md5sum = "XXXX"; } 201 162 202 push (@nebarray, $values[0]); 163 push (@ds_array, $values[1]); 164 push (@md_array, $values[2]); 165 if ($DEBUG > 4) { print "$values[0]\n $values[1]\n $values[2]\n"; } 203 push (@md_array, $md5sum); 204 push (@ds_array, $dstate); 205 206 if ($DEBUG > 5) { print "V0: $values[0]\n"; print "V1: $values[1]\n"; print "V2: $values[2]\n"; } 207 if ($DEBUG > 4) { print "PRINT: $values[0]\n $dstate\n $md5sum\n"; } 166 208 } 167 209 … … 178 220 179 221 # my ($ext_id) = $nebname =~ m|neb://\w*/(\S*)|; ---> what if we do not have the host.volnum portion? (this attempt fails) 180 my ($ext_id) = $nebname =~ m|neb://[0-9a-zA-Z ]*\.[0-9]/(\S*)|;222 my ($ext_id) = $nebname =~ m|neb://[0-9a-zA-Z\.]*/(\S*)|; 181 223 if ($DEBUG > 5) { print "nebname: $ext_id\n"; } 182 224 183 225 my $sql_chip_instances = "SELECT uri, host, available, xattr, cab_id from instance join storage_object using (so_id) join volume using (vol_id) where ext_id = '$ext_id'"; 184 226 my $rowref = $neb_dbh->selectall_arrayref( $sql_chip_instances ); 185 227 186 228 return ($rowref, $ext_id); 187 229 } … … 205 247 my $Nmain = 0; 206 248 my $Nback = 0; 207 my $N dead= 0;249 my $Nlost = 0; 208 250 209 251 # xattr = 0 means instance @ ITC (main) … … 226 268 my $xattr = $values[3]; 227 269 270 if ($xattr > 1) { $Nlost ++; next; } # do not save instances on dead partitions 271 if ($xattr == 0) { $Nmain ++; } 272 if ($xattr == 1) { $Nback ++; } 273 228 274 # count the number of each host by incrementing the hash element corresponding to the hostname: 229 275 # NOTE: hostcount is global … … 231 277 232 278 if (not defined $hostfile{$hostname}) { 233 open ($hostfile{$hostname}, ">$ dateword/$hostname.inst.txt");279 open ($hostfile{$hostname}, ">$basedir/$dateword/$hostname.inst.$stage.txt"); 234 280 ## XXX deal with open failure here 235 281 } 282 236 283 my $fh = $hostfile{$hostname}; 237 284 print $fh "$instance $data_st $md5_sum\n"; 238 239 if ($xattr == 0) { $Nmain ++; } 240 if ($xattr == 1) { $Nback ++; } 241 if ($xattr > 1) { $Ndead ++; } 242 } 243 244 return ($Nmain, $Nback, $Ndead); 285 } 286 287 return ($Nmain, $Nback, $Nlost); 245 288 } 246 289 … … 249 292 my $outfh = $_[0]; 250 293 my $extID = $_[1]; 251 my $Nmain = $_[2]; 252 my $Nback = $_[3]; 253 my $Ndead = $_[4]; 254 255 # SKIP : already fixed 294 my $data_st = $_[2]; 295 my $md5_sum = $_[3]; 296 my $Nmain = $_[4]; 297 my $Nback = $_[5]; 298 my $Nlost = $_[6]; 299 300 my $outinfo = "$extID $data_st $md5_sum"; 301 $Nchip ++; 302 303 my $haveMD5 = 0; 304 my $goodMD5 = 0; 305 if ($goodchips_r->{$extID}) { $haveMD5 = 1; $goodMD5 = 1; } 306 if ($failchips_r->{$extID}) { $haveMD5 = 1; $goodMD5 = 0; } 307 308 if ($extID eq "gpc1/20100503/o5319g0003d/o5319g0003d.ota46.fits") { 309 print STDERR "$outinfo $Nmain $Nback $haveMD5 $goodMD5\n"; 310 } 311 312 # GOOD : already fixed 256 313 if (($Nmain == 1) && ($Nback == 1)) { 257 print $outfh "GOOD: $extID\n"; 258 return; 259 } 260 261 # single copy @ ITC, no backup 314 print $outfh "GOOD: $outinfo\n"; 315 &update_counts (\$Ngood, \$Nfail, $haveMD5, $goodMD5); 316 return; 317 } 318 319 # SING : single copy @ ITC, no backup 262 320 # make a backup 263 321 if (($Nmain == 1) && ($Nback == 0)) { 264 print $outfh "SING: $extID\n"; 265 return; 266 } 267 268 # ITC files with a single backup copies need to be culled 269 # cull Nmain - 1 270 if (($Nmain > 1) && ($Nback == 1)) { 271 print $outfh "CULL: $extID\n"; 272 return; 273 } 274 275 # multiple copies @ ITC 322 print $outfh "SING: $outinfo\n"; 323 &update_counts (\$Nsing, \$Nfail, $haveMD5, $goodMD5); 324 return; 325 } 326 327 # SBCK : single copy @ ATRC, no main copy 328 # make a backup @ ITC 329 if (($Nmain == 0) && ($Nback == 1)) { 330 print $outfh "SBCK: $outinfo\n"; 331 &update_counts (\$Nsbck, \$Nfail, $haveMD5, $goodMD5); 332 return; 333 } 334 335 # DUPS : multiple copies @ ITC, none at ATRC 276 336 # make a backup and cull Nmain - 1 277 337 if (($Nmain > 1) && ($Nback == 0)) { 278 print $outfh "DUPS: $extID\n"; 279 return; 280 } 281 282 # no more valid instances 283 if (($Nmain == 0) && ($Nback == 0) && $Ndead) { 284 print $outfh "DEAD: $extID\n"; 285 return; 286 } 287 if (($Nmain == 0) && ($Nback == 0) && ($Ndead == 0)) { 288 print $outfh "GONE: $extID\n"; 289 return; 290 } 291 292 # single copy @ ATRC 293 # make a backup @ ITC 294 if (($Nmain == 0) && ($Nback == 1)) { 295 print $outfh "SBCK: $extID\n"; 296 return; 297 } 298 299 # multiple copies @ ATRC, but none at ITC 338 print $outfh "DUPS: $outinfo\n"; 339 &update_counts (\$Ndups, \$Nfail, $haveMD5, $goodMD5); 340 return; 341 } 342 343 # XBCK : multiple copies @ ATRC, but none at ITC 300 344 # make a backup at ITC, cull ATRC extras 301 345 if (($Nmain == 0) && ($Nback > 1)) { 302 print $outfh "XBCK: $extID\n"; 346 print $outfh "XBCK: $outinfo\n"; 347 &update_counts (\$Nxbck, \$Nfail, $haveMD5, $goodMD5); 348 return; 349 } 350 351 # DEAD : no more valid instances 352 if (($Nmain == 0) && ($Nback == 0) && $Nlost) { 353 print $outfh "DEAD: $outinfo\n"; 354 &update_counts (\$Ndead, \$Nfail, $haveMD5, $goodMD5); 355 return; 356 } 357 # GONE : no more valid instances 358 if (($Nmain == 0) && ($Nback == 0) && ($Nlost == 0)) { 359 print $outfh "GONE: $outinfo\n"; 360 &update_counts (\$Ngone, \$Nfail, $haveMD5, $goodMD5); 361 return; 362 } 363 364 # CUL1 : multiple ITC files, single backup 365 # cull only ITC 366 if (($Nmain > 1) && ($Nback == 1)) { 367 print $outfh "CUL1: $outinfo\n"; 368 &update_counts (\$Ncul1, \$Nfail, $haveMD5, $goodMD5); 369 return; 370 } 371 372 # CUL2 : multiple ATRC files, single ITC 373 # cull only ATRC 374 if (($Nback > 1) && ($Nmain == 1)) { 375 print $outfh "CUL2: $outinfo\n"; 376 &update_counts (\$Ncul2, \$Nfail, $haveMD5, $goodMD5); 377 return; 378 } 379 380 # CUL3 : excess ATRC & ITC files, cull from both? 381 # cull Nmain - 1 382 if (($Nback > 1) && ($Nmain > 1)) { 383 print $outfh "CUL3: $outinfo\n"; 384 &update_counts (\$Ncul3, \$Nfail, $haveMD5, $goodMD5); 303 385 return; 304 386 } 305 387 306 388 # unexpected state: 307 print $outfh "OOPS: $ extID\n";389 print $outfh "OOPS: $outinfo\n"; 308 390 return; 309 391 } 310 392 393 sub update_counts { 394 395 my $Nstat_r = $_[0]; 396 my $Nfail_r = $_[1]; 397 my $haveMD5 = $_[2]; 398 my $goodMD5 = $_[3]; 399 400 ## if we know the MD5 is bad, add to Nfail, otherwise add to Ndups 401 if ($haveMD5 && !$goodMD5) { 402 $$Nfail_r ++; 403 } else { 404 $$Nstat_r ++; 405 } 406 } 407 408 sub get_good_or_fail_chiplists { 409 410 my $basedir = $_[0]; 411 my $dateword = $_[1]; 412 my $stage = $_[2]; 413 414 # load the lists of good and fail chips 415 my $prev = $stage - 1; 416 my $goodfile = "$basedir/$dateword/goodchips.$prev.txt"; 417 my %goodchips; 418 if (-e $goodfile) { 419 open (GOODFILE, $goodfile); 420 my @lines = <GOODFILE>; 421 close (GOODFILE); 422 423 foreach my $line (@lines) { 424 chomp $line; 425 $goodchips{$line} = 1; 426 } 427 } 428 my $failfile = "$basedir/$dateword/failchips.$prev.txt"; 429 my %failchips; 430 if (-e $failfile) { 431 open (FAILFILE, $failfile); 432 my @lines = <FAILFILE>; 433 close (FAILFILE); 434 435 foreach my $line (@lines) { 436 chomp $line; 437 $failchips{$line} = 1; 438 } 439 } 440 return (\%goodchips, \%failchips); 441 } 442 311 443 sub parse_cmdopts { 312 444 313 my ($dateobs, $chiplist );314 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist ) || pod2usage(2);445 my ($dateobs, $chiplist, $stage, $topdir); 446 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, 'topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2); 315 447 316 448 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 317 449 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 450 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 451 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 318 452 453 # check that stage is an integer 454 unless (&is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 455 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 456 319 457 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) 320 458 … … 324 462 pod2usage( -msg => "Cannot interpret date, use YYYY/MM/DD", -exitval => 2) if ($date_month < 1) or ($date_month > 12); 325 463 pod2usage( -msg => "Cannot interpret date, use YYYY/MM/DD", -exitval => 2) if ($date_day < 1) or ($date_day > 31); 464 326 465 my $fulldate = "$date_year/$date_month/$date_day"; 327 328 466 my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day); 329 467 330 return ($fulldate, $dateword, $chiplist) 468 my $yearobs = substr ($dateword, 0, 4); 469 my $basedir = "$topdir/$yearobs"; 470 471 return ($fulldate, $dateword, $chiplist, $stage, $topdir, $basedir) 331 472 } 332 473 … … 338 479 my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user ); 339 480 my ( $gpcdb_name, $gpcdb_host, $gpcdb_port, $gpcdb_pass, $gpcdb_user ); 481 my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user ); 340 482 341 483 if (-e $conffile) { … … 355 497 if ($_ =~ /GPC1_PASS /) { $gpcdb_pass = (split /\s+/,$_)[2]; } 356 498 if ($_ =~ /GPC1_PORT /) { $gpcdb_port = (split /\s+/,$_)[2]; } 499 500 if ($_ =~ /RAW_NAME /) { $rawdb_name = (split /\s+/,$_)[2]; } 501 if ($_ =~ /RAW_HOST /) { $rawdb_host = (split /\s+/,$_)[2]; } 502 if ($_ =~ /RAW_USER /) { $rawdb_user = (split /\s+/,$_)[2]; } 503 if ($_ =~ /RAW_PASS /) { $rawdb_pass = (split /\s+/,$_)[2]; } 504 if ($_ =~ /RAW_PORT /) { $rawdb_port = (split /\s+/,$_)[2]; } 357 505 } 358 506 close(IN); 359 507 print STDERR "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n"; 360 508 print STDERR "gpc1 dbh config: $gpcdb_name $gpcdb_host $gpcdb_port $gpcdb_user $gpcdb_pass\n"; 509 print STDERR "raw dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n"; 361 510 } 362 511 … … 373 522 pod2usage( -msg => "Cannot configure gpc1 database (dbpass)", -exitval => 2) unless defined $gpcdb_pass; 374 523 524 pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name; 525 pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host; 526 pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user; 527 pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port; 528 pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass; 529 375 530 my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host"; 376 531 if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; } … … 381 536 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"; 382 537 383 return ($neb_dbh, $gpc_dbh); 384 } 385 386 538 my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host"; 539 if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; } 540 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"; 541 542 return ($neb_dbh, $gpc_dbh, $raw_dbh); 543 } 544 545 sub is_integer { 546 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 547 } 548 387 549 # example of using the return value of arrayref: 388 550 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/check_md5s_dateobs.pl
r42404 r42531 1 1 #! /usr/bin/env perl 2 2 3 my $DEBUG = 4;3 my $DEBUG = 1; 4 4 my $time = time(); 5 5 … … 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 13 14 # USAGE: check_md5s_dateobs.pl --dateobs (night) 15 16 my ($dateword) = &parse_cmdopts; 17 18 my @instlist = glob ("$dateword/*.inst.txt"); 19 my @md5slist = glob ("$dateword/*.md5s.txt"); 20 21 foreach my $instfile (@instlist) { 22 23 # find the matching md5sum file for this host 24 25 my ($host) = $instfile =~ m|$dateword/([0-9a-zA-Z]*).inst.txt|; 26 # print STDERR "host: $host\n"; 27 28 my $md5match = "NONE"; 29 foreach my $md5sfile (@md5slist) { 30 31 my ($md5shost) = $md5sfile =~ m|$dateword/([0-9a-zA-Z]*).md5s.txt|; 32 # print STDERR "md5host: $md5shost\n"; 33 34 if ($host ne $md5shost) { next; } 35 36 $md5match = $md5sfile; 37 last; 38 } 39 40 if ($md5match eq "NONE") { 41 print STDERR "missing md5sum file for $instfile\n"; 42 next; 43 } 14 # USAGE: check_md5s_dateobs.pl --dateobs (night) --topdir (topdir) 15 16 my ($dateword, $stage, $topdir, $basedir) = &parse_cmdopts; 17 # basedir used only for night-level files 18 19 my $instlist_r = &load_instlist_filenames ($basedir, $dateword, $stage); 20 my $md5slist_r = &load_md5slist_filenames ($basedir, $dateword, $stage, $instlist_r); 21 22 my $Nfail = 0; 23 my %failchips; 24 my %goodchips; 25 26 # make a list of the master instance files: 27 28 foreach my $instfile (@$instlist_r) { 29 30 # print "inst: $instfile\n"; 31 32 my $md5sfile = $md5slist_r->{$instfile}; 44 33 45 34 ## read in the md5sums 46 open (FILE, $md5 match);35 open (FILE, $md5sfile); 47 36 my @md5data = <FILE>; 48 37 close (FILE); 49 38 50 ## read in the list of instances 51 open (FILE, $instfile); 52 my @instdata = <FILE>; 53 close (FILE); 39 my $instdata_r = &load_instance_list ($basedir, $dateword, $stage, $instfile); 54 40 55 41 # if these do not match, complain and move on 42 # we are allowed to have more MD5s than instances: some instances 43 # may have been culled during this process (but the MD5s stay behind) 56 44 my $N1 = @md5data; 57 my $N2 = @instdata; 58 if ($N1 != $N2) { 59 print STDERR "inconsistent number of lines in $md5match : $N1 vs $N2\n"; 45 my $N2 = @$instdata_r; 46 if ($N1 < $N2) { 47 print STDOUT "not enough MD5s $md5sfile : $N1 vs $N2\n"; 48 $Nfail ++; 60 49 next; 61 } 62 63 # check for mismatched MD5sums 64 foreach my $line (@md5data) { 65 50 } else { 51 # print STDOUT "checking MD5s $md5sfile : $N1 vs $N2\n"; 52 } 53 54 # set up an empty hash for the instance names: 55 my %instfound = (); 56 foreach my $line (@$instdata_r) { 66 57 chomp $line; 67 58 my @words = split (/\s+/,$line); 59 my $inst = $words[0]; 60 $instfound{$inst} = 0; 61 } 62 63 # check for mismatched MD5sums 64 # we are not checking that all instances in the inst file are in the MD5 file 65 foreach my $line (@md5data) { 66 67 chomp $line; 68 my @words = split (/\s+/,$line); 68 69 69 70 # we expect lines of the form: INST STATE MDtru MDobs 70 if (@words != 4) { die "error in MD5 list $md5 match, line: $line\n"; }71 if (@words != 4) { die "error in MD5 list $md5sfile, line: $line\n"; } 71 72 72 73 my $inst = $words[0]; … … 75 76 my $md5obs = $words[3]; 76 77 78 unless (defined $instfound{$inst}) { print "skip md5 for removed instance $inst\n"; next; } 79 $instfound{$inst} = 1; 80 77 81 if ($md5tru ne $md5obs) { 78 print STDERR "FAIL: $inst $state $md5tru $md5obs\n"; 82 &save_failure ($inst); 83 if ($DEBUG > 2) { print STDOUT "FAIL: $inst $state $md5tru $md5obs\n"; } 84 } else { 85 &save_goodchip ($inst); 86 if ($DEBUG > 2) { print STDOUT "$inst $state $md5tru = $md5obs\n"; } 79 87 } 80 88 } 89 90 my @instfoundKEYS = keys %instfound; 91 foreach my $inst (@instfoundKEYS) { 92 unless ($instfound{$inst}) { die "missing MD5 for instance $inst\n"; } 93 } 94 } 95 96 # save both good and fail chip lists 97 open (OUTFILE, ">$basedir/$dateword/goodchips.$stage.txt"); 98 my @goodchipURIs = keys %goodchips; 99 foreach my $uri (@goodchipURIs) { 100 print OUTFILE "$uri\n"; 101 } 102 close (OUTFILE); 103 104 open (OUTFILE, ">$basedir/$dateword/failchips.$stage.txt"); 105 my @failchipURIs = keys %failchips; 106 foreach my $uri (@failchipURIs) { 107 print OUTFILE "$uri\n"; 108 } 109 close (OUTFILE); 110 111 112 ## we only report an error if we could not find the md5sum files or if the inst and md5s 113 ## files are inconsistent. In that case, we cannot check the md5s for all instances 114 ## if the md5sum is wrong for a chip, mark that chip and save it. It will be skipped in fix_chip_locations 115 if ($Nfail) { 116 print STDOUT "ERROR: $Nfail errors\n"; 117 exit 1; 118 } else { 119 print STDOUT "SUCCESS: $Nfail errors\n"; 120 exit 0; 121 } 122 123 # use global $basedir, $dateword, $myhost, $stage 124 sub load_instance_list { 125 my $basedir = $_[0]; 126 my $dateword = $_[1]; 127 my $stage = $_[2]; 128 my $instfile = $_[3]; 129 130 my @instdata_list; 131 132 # load the master list 133 &load_instance_list_onefile ($instfile, \@instdata_list); 134 135 # there may be additional instances in files with names like HOSTNAME.XYnn.inst.STAGE 136 my ($myhost) = $instfile =~ m|$dateword/([0-9a-zA-Z]*).inst.$stage.txt|; 137 my @instlist = glob ("$basedir/$dateword/$myhost.XY??.inst.$stage.txt"); 138 foreach my $infile (@instlist) { 139 &load_instance_list_onefile ($infile, \@instdata_list); 140 } 141 return (\@instdata_list); 142 } 143 144 # read the instance info 145 sub load_instance_list_onefile { 146 my $infile = $_[0]; 147 my $instdata_list_r = $_[1]; # reference to the file data 148 149 open(FILE,$infile) or die "cannot open file $infile\n"; 150 my @lines = <FILE>; 151 close (FILE); 152 153 foreach my $line (@lines) { 154 chomp $line; 155 if ($line =~ /^\s*#/) { next; } # skip lines with leading # 156 push (@$instdata_list_r, $line); 157 } 158 } 159 160 # return only the master instlist filenames (ignore ones with the chipnames in the name) 161 sub load_instlist_filenames { 162 163 my $basedir = $_[0]; 164 my $dateword = $_[1]; 165 my $stage = $_[2]; 166 167 my @instlist_all = glob ("$basedir/$dateword/*.inst.$stage.txt"); 168 169 my @instlist = (); 170 171 foreach my $instfile (@instlist_all) { 172 173 # skip the per-chip inst files (these should probably be merged into the master) 174 if ($instfile =~ m|XY[0-9][0-9].inst|) { next; } 175 176 push (@instlist, $instfile); 177 } 178 return (\@instlist); 179 } 180 181 # return a hash of the matched md5 file for each inst file 182 sub load_md5slist_filenames { 183 184 my $basedir = $_[0]; 185 my $dateword = $_[1]; 186 my $stage = $_[2]; 187 my $instlist_r = $_[3]; 188 189 my @md5slist = glob ("$basedir/$dateword/*.md5s.txt"); 190 191 my %md5shash; 192 193 my $Nfail = 0; 194 195 foreach my $instfile (@$instlist_r) { 196 197 # find the matching md5sum file for this host 198 199 my ($host) = $instfile =~ m|$dateword/([0-9a-zA-Z]*).inst.$stage.txt|; 200 # print STDERR "host: $host\n"; 201 202 my $md5match = "NONE"; 203 foreach my $md5sfile (@md5slist) { 204 205 my ($md5shost) = $md5sfile =~ m|$dateword/([0-9a-zA-Z]*).md5s.txt|; 206 207 if ($host ne $md5shost) { next; } 208 209 # print STDERR "md5host: $md5shost : $md5sfile = $instfile\n"; 210 211 $md5match = $md5sfile; 212 last; 213 } 214 215 if ($md5match eq "NONE") { 216 print STDOUT "missing md5sum file for $instfile\n"; 217 $Nfail ++; 218 next; 219 } 220 $md5shash{$instfile} = $md5match; 221 222 # print "match: $instfile = $md5match\n"; 223 224 } 225 if ($Nfail > 0) { 226 print STDOUT "ERROR: $Nfail errors\n"; 227 exit 1; 228 } 229 return (\%md5shash); 81 230 } 82 231 83 232 sub parse_cmdopts { 84 233 85 my ($dateobs );86 GetOptions( 'dateobs=s' => \$dateobs ) || pod2usage(2);234 my ($dateobs, $stage, $topdir); 235 GetOptions( 'dateobs=s' => \$dateobs, 'topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2); 87 236 88 237 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 238 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 239 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 240 241 # check that stage is an integer 242 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 243 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 89 244 90 245 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) … … 98 253 my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day); 99 254 100 return ($dateword); 255 my $yearobs = substr ($dateword, 0, 4); 256 my $basedir = "$topdir/$yearobs"; 257 258 return ($dateword, $stage, $topdir, $basedir); 101 259 } 102 260 … … 107 265 return $status; 108 266 } 267 268 sub neb_reverse { 269 270 my (@neb_path) = split /\//, $_[0]; 271 my $neb_key = $neb_path[-1]; 272 273 # Remove ins_id 274 $neb_key =~ s/^\d+\.//; 275 276 # Convert colons to slashes. 277 $neb_key =~ s%:%/%g; 278 279 # strip ending .fz added for compressed .fits images 280 $neb_key =~ s%.fz$%%; 281 return $neb_key; 282 } 283 284 sub save_failure { 285 my $nebfile = &neb_reverse($_[0]); 286 if (defined $failchips{$nebfile}) { 287 $failchips{$nebfile} ++; 288 } else { 289 $failchips{$nebfile} = 1; 290 } 291 return; 292 } 293 294 sub save_goodchip { 295 my $nebfile = &neb_reverse($_[0]); 296 if (defined $goodchips{$nebfile}) { 297 $goodchips{$nebfile} ++; 298 } else { 299 $goodchips{$nebfile} = 1; 300 } 301 return; 302 } 303 304 sub is_integer { 305 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 306 } -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/create.rawfix.sh
r42399 r42531 1 1 #!/bin/csh 2 3 echo "do not use without caution" 4 exit 2 2 5 3 6 # make the rawfix database to track rawfix operations … … 5 8 set DBUSER = "dvo" 6 9 10 # add in the iteration and the state summary 11 12 mysql -h localhost -u root <<EOF 13 use $DBNAME; 14 ALTER TABLE nights MODIFY Ngood INT, MODIFY Ndead INT, MODIFY Ngone INT; 15 ALTER TABLE nights MODIFY Nsing INT, MODIFY Ndups INT, MODIFY Nsbck INT, MODIFY Nxbck INT, MODIFY Nfail INT; 16 ALTER TABLE nights MODIFY Ncul1 INT, MODIFY Ncul2 INT, MODIFY Ncul3 INT; 17 EOF 18 19 exit 0 20 21 mysql -h localhost -u root <<EOF 22 use $DBNAME; 23 ALTER TABLE nights ADD COLUMN iter SMALLINT, ADD COLUMN Ngood SMALLINT, ADD COLUMN Ndead SMALLINT, ADD COLUMN Ngone SMALLINT; 24 ALTER TABLE nights ADD COLUMN Nsing SMALLINT, ADD COLUMN Ndups SMALLINT, ADD COLUMN Nsbck SMALLINT, ADD COLUMN Nxbck SMALLINT; 25 ALTER TABLE nights ADD COLUMN Ncul1 SMALLINT, ADD COLUMN Ncul2 SMALLINT, ADD COLUMN Ncul3 SMALLINT; 26 EOF 27 28 exit 0 29 7 30 mysql -h localhost -u root <<EOF 8 31 drop database if exists $DBNAME; 9 32 create database $DBNAME; 10 33 use $DBNAME; 11 create table nights (night_id BIGINT AUTO_INCREMENT, dateobs char(64), state char(64), primary key (night_id) );34 create table nights (night_id BIGINT AUTO_INCREMENT, dateobs char(64), state char(64), primary key (night_id), unique (dateobs)); 12 35 EOF 13 36 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
r42406 r42531 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 13 14 # USAGE: fix_chip_locations.pl --dateobs (night) -- chiplist (file)14 # USAGE: fix_chip_locations.pl --dateobs (night) --stage (0,1,etc) [--chiplist (file) | --chipID (ID)] 15 15 16 16 # we need to select targets for ITC copies of files currently only at ATRC: … … 18 18 # for each chip, target a single host? 19 19 20 my ($fulldate, $dateword, $chiplist) = &parse_cmdopts; 21 my ($neb_dbh) = &parse_db_config ('nebulous.config'); 22 23 # read the list of chip_ids: 24 my @chip_ids = &load_chip_list ($chiplist); 20 my ($fulldate, $dateword, $chiplist, $chipID, $stage, $topdir, $basedir) = &parse_cmdopts; 21 my ($neb_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config"); 22 # topdir used for nebulous.config and chiplist.txt, basedir used for night-level data 25 23 26 24 # choose ITC machines on which to place backup copies: 27 my @volarray = &get_neb_volumes; 28 my $volnum = 0; 25 my @vol_copy = &get_neb_volumes_copy; # array of neb hosts to copy data to at ITC 26 my %vol_good = &get_neb_volumes_good; # hash of valid neb hosts 27 28 my $Nchip = 0; # counts the number of instances 29 29 30 30 my $Ngood = 0; 31 my $Ndead = 0; 31 32 my $Ngone = 0; 32 my $Ndead = 0;33 33 my $Nsing = 0; 34 34 my $Ndups = 0; … … 36 36 my $Nxbck = 0; 37 37 38 my $Ncul1 = 0; 39 my $Ncul2 = 0; 40 my $Ncul3 = 0; 41 my $Nfail = 0; 42 43 my ($goodchips_r, $failchips_r) = &get_good_or_fail_chiplists ($basedir, $dateword, $stage); 44 45 # read the list of chip_ids: 46 my @chip_ids = &load_chip_list ($chiplist); 47 48 my $volnum = 0; # select the volume to be used from the list of @vol_copy 49 50 # loop over all chip_ids so we can distribute the target volumes 38 51 foreach my $chip_id (@chip_ids) { 39 40 my $urifile = "$dateword/$chip_id.uris.txt"; 41 open (FILE, "$urifile"); 42 my @lines = <FILE>; 43 close (FILE); 52 if (not defined $chipID or ($chipID eq $chip_id)) { 53 &fix_chip_locations_chipID ($chip_id, $volnum); 54 } 55 $volnum ++; 56 if ($volnum > @vol_copy) { $volnum = 0; } 57 } 58 59 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 60 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 61 62 if (not defined $chipID) { 63 # update the stats in the database 64 my $sql_update_stats = "UPDATE nights set"; 65 $sql_update_stats .= " Nchip = $Nchip"; 66 $sql_update_stats .= ", Ngood = $Ngood"; 67 $sql_update_stats .= ", Ndead = $Ndead"; 68 $sql_update_stats .= ", Ngone = $Ngone"; 69 $sql_update_stats .= ", Nsing = $Nsing"; 70 $sql_update_stats .= ", Ndups = $Ndups"; 71 $sql_update_stats .= ", Nsbck = $Nsbck"; 72 $sql_update_stats .= ", Nxbck = $Nxbck"; 73 $sql_update_stats .= ", Ncul1 = $Ncul1"; 74 $sql_update_stats .= ", Ncul2 = $Ncul2"; 75 $sql_update_stats .= ", Ncul3 = $Ncul3"; 76 $sql_update_stats .= ", Nfail = $Nfail"; 77 $sql_update_stats .= " WHERE dateobs = $dateword"; 78 79 my $query = $raw_dbh->prepare($sql_update_stats); 80 $query->execute () or die "invalid response from RAW database\n"; 81 } else { 82 83 open (OUTFILE, ">$basedir/$dateword/$chipID.stats.$stage.txt"); 84 85 print OUTFILE "Nchip: $Nchip\n"; 86 print OUTFILE "Ngood: $Ngood\n"; 87 print OUTFILE "Ngone: $Ngone\n"; 88 print OUTFILE "Ndead: $Ndead\n"; 89 print OUTFILE "Nsing: $Nsing\n"; 90 print OUTFILE "Ndups: $Ndups\n"; 91 print OUTFILE "Nsbck: $Nsbck\n"; 92 print OUTFILE "Nxbck: $Nxbck\n"; 93 print OUTFILE "Ncul1: $Ncul1\n"; 94 print OUTFILE "Ncul2: $Ncul2\n"; 95 print OUTFILE "Ncul3: $Ncul3\n"; 96 print OUTFILE "Nfail: $Nfail\n"; 97 98 close (OUTFILE); 99 } 100 101 exit 0; 102 103 sub fix_chip_locations_chipID { 104 105 my $chip_id = $_[0]; 106 my $volnum = $_[1]; 107 108 # read from chip_id file, update to next stage number 109 my $urifile = "$basedir/$dateword/$chip_id.uris.$stage.txt"; 110 if (! -e $urifile) { die "missing file $urifile\n"; } 111 open (URIFILE, $urifile); 112 my @lines = <URIFILE>; 113 close (URIFILE); 44 114 45 115 foreach my $line (@lines) { … … 49 119 50 120 # we expect lines of the form: STATE PATH 51 # e.g., GOOD: gpc1/20100502/o5318g0002d/o5318g0002d.ota76.fits 52 if (@words != 2) { die "error in URI list $urifile, line: $line\n"; }121 # e.g., GOOD: gpc1/20100502/o5318g0002d/o5318g0002d.ota76.fits DataState MD5sum 122 if (@words != 4) { die "error in URI list $urifile, line: $line\n"; } 53 123 54 124 my $state = $words[0]; 55 125 my $ext_id = $words[1]; 56 126 my $datast = $words[2]; 127 my $md5sum = $words[3]; 128 129 my $haveMD5 = 0; 130 my $goodMD5 = 0; 131 if ($goodchips_r->{$ext_id}) { $haveMD5 = 1; $goodMD5 = 1; } 132 if ($failchips_r->{$ext_id}) { $haveMD5 = 1; $goodMD5 = 0; } 133 134 $Nchip ++; 135 136 # nothing to be done, or need be done for these: 57 137 if ($state eq "GOOD:") { $Ngood++; next; } 58 138 if ($state eq "DEAD:") { $Ndead++; next; } 59 139 if ($state eq "GONE:") { $Ngone++; next; } 60 if ($state eq "DUPS:") { $Ndups++; next; }61 if ($state eq "XBCK:") { $Nxbck++; next; }62 140 63 141 # one copy at ITC: neb-replicate will create a copy at ATRC 142 # does not depend on existence of MD5sum 64 143 if ($state eq "SING:") { 65 144 my $status = &vsystem ("neb-replicate $ext_id"); … … 67 146 my ($newfile, $newhost, $newxattr) = &get_new_instance ($ext_id); 68 147 unless ($newxattr == 1) { die "new instance is not at ATRC? $ext_id : $newfile : $newhost : $newxattr\n"; } 69 open (OUTFILE, ">>$ dateword/$newhost.inst.txt");70 print OUTFILE "$newfile \n";148 open (OUTFILE, ">>$basedir/$dateword/$newhost.$chip_id.inst.$stage.txt"); 149 print OUTFILE "$newfile $datast $md5sum\n"; 71 150 close (OUTFILE); 72 151 $Nsing ++; … … 75 154 76 155 # one copy at ATRC: neb-replicate will create a copy at ITC iff we supply the target volume 156 # does not depend on existence of MD5sum 77 157 if ($state eq "SBCK:") { 78 my $tgtvol = $vol array[$volnum];158 my $tgtvol = $vol_copy[$volnum]; 79 159 my $status = &vsystem ("neb-replicate --volume $tgtvol $ext_id"); 80 160 if ($status) { print STDERR "FAIL SBCK: neb-replicate : $ext_id on $tgtvol\n"; next; } 81 161 my ($newfile, $newhost, $newxattr) = &get_new_instance ($ext_id); 82 162 unless ($newxattr == 0) { die "new instance is not at ITC? $ext_id : $newfile : $newhost : $newxattr\n"; } 83 open (OUTFILE, ">>$ dateword/$newhost.inst.txt");84 print OUTFILE "$newfile \n";163 open (OUTFILE, ">>$basedir/$dateword/$newhost.$chip_id.inst.$stage.txt"); 164 print OUTFILE "$newfile $datast $md5sum\n"; 85 165 close (OUTFILE); 86 166 $Nsbck ++; 87 167 next; 88 168 } 89 } 90 $volnum ++; 91 } 92 93 print "Ngood: $Ngood\n"; 94 print "Ngone: $Ngone\n"; 95 print "Ndead: $Ndead\n"; 96 print "Nsing: $Nsing\n"; 97 print "Ndups: $Ndups\n"; 98 print "Nsbck: $Nsbck\n"; 99 print "Nxbck: $Nxbck\n"; 100 101 exit 0; 169 170 # multiple copies @ ITC, but none at ATRC. use neb-replicate to make copies 171 # skip if we do not know the state of the md5sum 172 if ($state eq "DUPS:") { 173 if ($haveMD5 && $goodMD5) { 174 my $status = &vsystem ("neb-replicate $ext_id"); 175 if ($status) { print STDERR "FAIL DUPS: neb-replicate : $ext_id\n"; next; } 176 my ($newfile, $newhost, $newxattr) = &get_new_instance ($ext_id); 177 unless ($newxattr == 1) { die "new instance is not at ATRC? $ext_id : $newfile : $newhost : $newxattr\n"; } 178 open (OUTFILE, ">>$basedir/$dateword/$newhost.$chip_id.inst.$stage.txt"); 179 print OUTFILE "$newfile $datast $md5sum\n"; 180 close (OUTFILE); 181 } 182 ## if we know the MD5 is bad, add to Nfail, otherwise add to Ndups 183 if ($haveMD5 && !$goodMD5) { 184 $Nfail ++; 185 } else { 186 $Ndups++; 187 } 188 next; 189 } 190 191 # multiple copies @ ATRC, but none @ ITC: neb-replicate will create a copy at ITC iff we supply the target volume 192 # skip if we do not know the state of the md5sum 193 if ($state eq "XBCK:") { 194 if ($haveMD5 && $goodMD5) { 195 my $tgtvol = $vol_copy[$volnum]; 196 my $status = &vsystem ("neb-replicate --volume $tgtvol $ext_id"); 197 if ($status) { print STDERR "FAIL XBCK: neb-replicate : $ext_id on $tgtvol\n"; next; } 198 my ($newfile, $newhost, $newxattr) = &get_new_instance ($ext_id); 199 unless ($newxattr == 0) { die "new instance is not at ITC? $ext_id : $newfile : $newhost : $newxattr\n"; } 200 open (OUTFILE, ">>$basedir/$dateword/$newhost.$chip_id.inst.$stage.txt"); 201 print OUTFILE "$newfile $datast $md5sum\n"; 202 close (OUTFILE); 203 } 204 ## if we know the MD5 is bad, add to Nfail, otherwise add to Nxbck: 205 if ($haveMD5 && !$goodMD5) { 206 $Nfail ++; 207 } else { 208 $Nxbck++; 209 } 210 next; 211 } 212 213 # one copy at ITC: neb-replicate will create a copy at ATRC 214 # skip if we do not know the state of the md5sum 215 if (($state eq "CUL1:") || ($state eq "CUL2:") || ($state eq "CUL3:")) { 216 217 if ($haveMD5 && $goodMD5) { 218 # get info for all instances of this chip 219 # returns a reference to the array of instance data 220 # also strips neb://hostname.volnum/ from nebname and returns as ext_id 221 my ($inforows, $ext_id) = &get_chip_instances ($ext_id); 222 223 my ($main_keep, $back_keep, $cull_list_r) = &check_instance_xattr ($inforows, $ext_id); 224 225 if ($main_keep eq "") { print STDERR "FAIL $state: missing ITC copy for $ext_id\n"; next; } 226 if ($back_keep eq "") { print STDERR "FAIL $state: missing ATRC copy for $ext_id\n"; next; } 227 228 my $NcullTotal = @$cull_list_r; 229 foreach my $instance (@$cull_list_r) { 230 print "state $state : checking instance $instance ... "; 231 my ($volname) = $instance =~ m|file:///data/([0-9a-zA-Z]*\.[0-9])/\S*|; 232 print "volname $volname\n"; 233 unless (defined $vol_good{$volname}) { die "ERROR: invalid volume name $volname\n"; } 234 # print STDERR "neb-cull $state: $ext_id $volname ($main_keep $back_keep)\n"; 235 my $status = &vsystem ("neb-cull --volume $volname $ext_id"); 236 if ($status) { print STDERR "FAIL CULL: neb-replicate : $ext_id\n"; next; } 237 } 238 # print STDERR "Ncull Total $NcullTotal\n"; 239 } 240 241 ## if we know the MD5 is bad, add to Nfail, otherwise add to NculX 242 if ($haveMD5 && !$goodMD5) { 243 $Nfail ++; 244 } else { 245 if ($state eq "CUL1:") { $Ncul1++; next; } 246 if ($state eq "CUL2:") { $Ncul2++; next; } 247 if ($state eq "CUL3:") { $Ncul3++; next; } 248 } 249 } 250 } 251 } 102 252 103 253 sub get_new_instance { … … 120 270 } 121 271 122 # get the list of chip neb paths for one chip 123 sub get_neb_volumes { 272 sub get_chip_instances { 273 274 my $ext_id = $_[0]; 275 276 my $sql_chip_instances = "SELECT uri, host, available, xattr, cab_id from instance join storage_object using (so_id) join volume using (vol_id) where ext_id = '$ext_id'"; 277 my $rowref = $neb_dbh->selectall_arrayref( $sql_chip_instances ); 278 279 return ($rowref, $ext_id); 280 } 281 282 # select 1 instance with xattr = 0, 1 with xattr = 1. 283 # the rest should be culled. 284 285 sub check_instance_xattr { 286 287 my $rowref = $_[0]; 288 my $ext_id = $_[1]; 289 290 my @inforows = @$rowref; 291 my $Nrows = @inforows; 292 293 if ($DEBUG > 5) { print "found $Nrows instances\n"; } 294 295 # get user_copies for this storage_object 296 my $main_keep = ""; 297 my $back_keep = ""; 298 my @cull_list = (); 299 300 # xattr = 0 means instance @ ITC (main) 301 # xattr = 1 means instance @ ATRC (back) 302 for (my $j = 0; $j < $Nrows; $j ++) { 303 my $valref = $inforows[$j]; 304 my @values = @$valref; 305 306 # the number of returned values per row must match the query above (in get_chip_instances) 307 my $Nvalue = @values; 308 if ($Nvalue != 5) { 309 print STDERR "ERROR : INVALID DB XATTR RESPONSE: $ext_id\n"; 310 next; 311 } 312 313 my $instance = $values[0]; 314 my $hostname = $values[1]; 315 my $xattr = $values[3]; 316 317 if (($xattr == 0) && ($main_keep eq "")) { $main_keep = $instance; next; } 318 if (($xattr == 1) && ($back_keep eq "")) { $back_keep = $instance; next; } 319 320 if ($xattr > 1) { print "ignore lost instance $instance\n"; next; } 321 322 # if we make it here, we already have an instance at this location 323 push (@cull_list, $instance); 324 } 325 return ($main_keep, $back_keep, \@cull_list); 326 } 327 328 sub get_good_or_fail_chiplists { 329 330 my $basedir = $_[0]; 331 my $dateword = $_[1]; 332 my $stage = $_[2]; 333 334 # load the lists of good and fail chips 335 my $prev = $stage - 1; 336 my $goodfile = "$basedir/$dateword/goodchips.$prev.txt"; 337 my %goodchips; 338 if (-e $goodfile) { 339 open (GOODFILE, $goodfile); 340 my @lines = <GOODFILE>; 341 close (GOODFILE); 342 343 foreach my $line (@lines) { 344 chomp $line; 345 $goodchips{$line} = 1; 346 } 347 } 348 my $failfile = "$basedir/$dateword/failchips.$prev.txt"; 349 my %failchips; 350 if (-e $failfile) { 351 open (FAILFILE, $failfile); 352 my @lines = <FAILFILE>; 353 close (FAILFILE); 354 355 foreach my $line (@lines) { 356 chomp $line; 357 $failchips{$line} = 1; 358 } 359 } 360 return (\%goodchips, \%failchips); 361 } 362 363 # get the list of neb hosts to copy data to at ITC 364 sub get_neb_volumes_copy { 124 365 125 366 my @volarray; … … 148 389 } 149 390 391 # get the list of valid neb hosts (ITC or ATRC) 392 sub get_neb_volumes_good { 393 394 my %volarray; 395 396 my $sql_neb_volumes = "select name from mountedvol where ((xattr = 0) or (xattr = 1))"; 397 if ($DEBUG > 4) { print "sql: $sql_neb_volumes\n"; } 398 399 my $rowref = $neb_dbh->selectall_arrayref( $sql_neb_volumes ); 400 my @tmparray = @$rowref; 401 my $Nrows = @tmparray; 402 403 if ($DEBUG > 4) { print "found $Nrows possible volumes\n"; } 404 405 foreach my $valref (@tmparray) { 406 my @values = @$valref; 407 # there should only be a single value (only name selected above) 408 my $Nvalues = @values; 409 if ($Nvalues == 0) { print "ERROR: missing uri\n"; next; } 410 if ($Nvalues > 1) { print "ERROR: too many uri entries?\n"; next; } 411 412 $volarray{$values[0]} = 1; 413 if ($DEBUG > 4) { print "$values[0]\n"; } 414 } 415 416 return %volarray; 417 } 418 150 419 # read the list of chip_ids: 151 420 sub load_chip_list { … … 154 423 my @chip_ids; 155 424 156 open(CHIPS, $chiplist) or die "cannot open file $chiplist\n";425 open(CHIPS,"$topdir/$chiplist") or die "cannot open file $chiplist\n"; 157 426 158 427 my @lines = <CHIPS>; … … 173 442 sub parse_cmdopts { 174 443 175 my ($dateobs, $chiplist );176 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist ) || pod2usage(2);444 my ($dateobs, $chiplist, $chipID, $stage, $topdir); 445 GetOptions( 'dateobs=s' => \$dateobs, 'chiplist=s' => \$chiplist, 'chipID=s' => \$chipID, 'topdir=s' => \$topdir, 'stage=s' => \$stage) || pod2usage(2); 177 446 178 447 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 448 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 449 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 179 450 pod2usage( -msg => "Provide a list of chips with --chiplist", -exitval => 2) unless defined $chiplist; 180 451 452 # check that stage is an integer 453 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 454 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 455 181 456 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) 182 457 … … 190 465 my $dateword = sprintf ("%4d%02d%02d", $date_year, $date_month, $date_day); 191 466 192 return ($fulldate, $dateword, $chiplist); 467 my ($yearobs) = substr ($dateword, 0, 4); 468 my $basedir = "$topdir/$yearobs"; 469 470 return ($fulldate, $dateword, $chiplist, $chipID, $stage, $topdir, $basedir); 193 471 } 194 472 … … 199 477 200 478 my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user ); 479 my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user ); 201 480 202 481 if (-e $conffile) { … … 210 489 if ($_ =~ /NEB_PASS /) { $nebdb_pass = (split /\s+/,$_)[2]; } 211 490 if ($_ =~ /NEB_PORT /) { $nebdb_port = (split /\s+/,$_)[2]; } 491 492 if ($_ =~ /RAW_NAME /) { $rawdb_name = (split /\s+/,$_)[2]; } 493 if ($_ =~ /RAW_HOST /) { $rawdb_host = (split /\s+/,$_)[2]; } 494 if ($_ =~ /RAW_USER /) { $rawdb_user = (split /\s+/,$_)[2]; } 495 if ($_ =~ /RAW_PASS /) { $rawdb_pass = (split /\s+/,$_)[2]; } 496 if ($_ =~ /RAW_PORT /) { $rawdb_port = (split /\s+/,$_)[2]; } 212 497 } 213 498 close(IN); 214 499 print STDERR "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n"; 500 print STDERR "raw dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n"; 215 501 } 216 502 … … 221 507 pod2usage( -msg => "Cannot configure nebulous database (dbpass)", -exitval => 2) unless defined $nebdb_pass; 222 508 509 pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name; 510 pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host; 511 pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user; 512 pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port; 513 pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass; 514 223 515 my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host"; 224 516 if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; } 225 517 my $neb_dbh = DBI->connect($nebdb_dsn, $nebdb_user, $nebdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n"; 226 518 227 return ($neb_dbh); 519 my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host"; 520 if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; } 521 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"; 522 523 return ($neb_dbh, $raw_dbh); 228 524 } 229 525 230 526 sub vsystem { 231 527 print STDERR "@_\n"; 232 # return 0;528 # return 0; 233 529 my $status = system ("@_"); 234 530 return $status; 235 531 } 532 533 sub is_integer { 534 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 535 } 536 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/get_hosts_md5s.sh
r42404 r42531 1 1 #!/bin/csh 2 2 3 if ($#argv != 1) then4 echo "USAGE: get_hosts_md5s.sh ( dateobs)"3 if ($#argv != 3) then 4 echo "USAGE: get_hosts_md5s.sh (topdir) (dateobs) (stage)" 5 5 exit 2 6 6 endif 7 7 8 set dirname = $1 8 set topdir = $1 9 set dateobs = $2 10 set stage = $3 9 11 10 if (! -d $dirname) then 11 echo "ERROR: missing dateobs directory $dirname" 12 if (! -d $topdir) then 13 echo "ERROR: missing top-level directory $topdir" 14 exit 3 15 endif 16 17 set yearobs = `echo $dateobs | awk '{print substr($1,1,4)}'` 18 set basedir = $topdir/$yearobs 19 20 if (! -d $basedir/$dateobs) then 21 echo "ERROR: missing dateobs directory $basedir/$dateobs" 12 22 exit 3 13 23 endif 14 24 15 25 # report both the dateobs and the hostnames 16 ls $ dirname/*.inst.txt | awk -v dateobs=$dirname -F/ '(NR == 1){print "dateobs md5host"}{print dateobs, $2}' | sed s/.inst.txt//26 ls $basedir/$dateobs/*.inst.$stage.txt | grep -v "XY...inst" | awk -v dateobs=$dateobs -v stage=$stage -F/ '(NR == 1){print "dateobs stage md5host"}{print dateobs, stage, $NF}' | sed s/.inst.$stage.txt// 17 27 exit 0 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/get_md5s_instances.pl
r42404 r42531 4 4 my $time = time(); 5 5 6 use DBI;7 6 use Carp; 8 7 use Pod::Usage qw( pod2usage ); … … 12 11 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 12 14 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) 13 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage (0,1,etc) 15 14 16 my ($myhost, $input) = &parse_cmdopts; 15 my $input; 16 my ($myhost, $dateword, $topdir, $basedir, $stage) = &parse_cmdopts; 17 17 18 18 # check that we are running this script on 'myhost' … … 21 21 22 22 # read the list of instances: 23 my ($ins_list_r, $dst_list_r, $md5_list_r) = &load_instance_list ( $input);23 my ($ins_list_r, $dst_list_r, $md5_list_r) = &load_instance_list (); 24 24 25 my $output = $input; 26 $output =~ s/inst/md5s/; 25 my $output = "$basedir/$dateword/$myhost.md5s.txt"; 27 26 28 if ($output eq $input) { die "output file ($output) matches input file ($input)\n"; } 27 # read in existing md5s 28 my $out_hash_r; 29 29 if (-e $output) { 30 # check that all instances are in the output file? 31 print "$output exists, skipping\n"; 32 exit 0; 30 $out_hash_r = &load_output_list ($output); 33 31 } 34 32 35 open (OUTFILE, "> $output");33 open (OUTFILE, ">>$output"); 36 34 37 35 # foreach my $instance (@$ins_list_r) { … … 42 40 my $md5sum_tru = $md5_list_r->[$i]; 43 41 42 # if the instance is already in the output file, skip it 43 if (defined $out_hash_r) { 44 my $name = $out_hash_r->{$instance}; 45 if (defined $name) { 46 print STDERR "skipping $instance (already in output)\n"; 47 next; 48 } 49 } 50 44 51 my $filename = $instance; 45 52 $filename =~ s|file://||; 46 53 47 my $line; 48 if (0) { 49 $line = "fakevalue $filename"; # XXX TEST: disable calculation: 50 } else { 51 $line = `md5sum $filename`; 54 # check for the existence of the file first: 55 unless (-e $filename) { 56 print OUTFILE "$instance $data_state $md5sum_tru XXX\n"; 57 next; 52 58 } 59 60 my $line = `md5sum $filename`; 53 61 54 62 my ($md5sum, $rawfile) = split (" ", $line); … … 58 66 exit 0; 59 67 60 # read the list of chip_ids:68 # use global $basedir, $dateword, $myhost, $stage 61 69 sub load_instance_list { 70 my (@ins_list, @dst_list, @md5_list); 71 72 # load the master list 73 my $input = "$basedir/$dateword/$myhost.inst.$stage.txt"; 74 &load_instance_list_onefile ($input, \@ins_list, \@dst_list, \@md5_list); 75 76 # there may be additional instances in files with names like HOSTNAME.XYnn.inst.STAGE 77 my @instlist = glob ("$basedir/$dateword/$myhost.XY??.inst.$stage.txt"); 78 foreach my $infile (@instlist) { 79 &load_instance_list_onefile ($infile, \@ins_list, \@dst_list, \@md5_list); 80 } 81 return (\@ins_list, \@dst_list, \@md5_list); 82 } 83 84 # read the instance info 85 sub load_instance_list_onefile { 62 86 my $infile = $_[0]; 63 64 my (@ins_list, @dst_list, @md5_list); 87 my $ins_list_r = $_[1]; # reference to the instance list array 88 my $dst_list_r = $_[2]; # reference to the instance list array 89 my $md5_list_r = $_[3]; # reference to the instance list array 65 90 66 91 open(FILE,$infile) or die "cannot open file $infile\n"; … … 74 99 75 100 if (@words != 3) { die "error in input $infile : $line\n"; } 76 push (@ins_list, $words[0]); 77 push (@dst_list, $words[1]); 78 push (@md5_list, $words[2]); 101 push (@$ins_list_r, $words[0]); 102 push (@$dst_list_r, $words[1]); 103 push (@$md5_list_r, $words[2]); 104 } 105 close (FILE); 106 } 107 108 # read the instance list in the output file 109 sub load_output_list { 110 my $infile = $_[0]; 111 112 my (%out_hash); 113 114 open(FILE,$infile) or die "cannot open file $infile\n"; 115 116 my @lines = <FILE>; 117 118 foreach my $line (@lines) { 119 chomp $line; 120 if ($line =~ /^\s*#/) { next; } # skip lines with leading # 121 my @words = split (/\s+/,$line); 122 123 if (@words != 4) { die "error in input $infile : $line\n"; } 124 $out_hash{$words[0]} = 1; 79 125 } 80 126 close (FILE); 81 127 82 return (\ @ins_list, \@dst_list, \@md5_list);128 return (\%out_hash); 83 129 } 84 130 85 131 sub parse_cmdopts { 86 132 87 my ($myhost, $ input);88 GetOptions( 'hostname=s' => \$myhost, ' input=s' => \$input) || pod2usage(2);133 my ($myhost, $topdir, $dateobs, $stage); 134 GetOptions( 'hostname=s' => \$myhost, 'topdir=s' => \$topdir, 'dateobs=s' => \$dateobs, 'stage=s' => \$stage) || pod2usage(2); 89 135 90 pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input; 136 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYYMMDD", -exitval => 2) unless defined $dateobs; 137 # pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input; 91 138 pod2usage( -msg => "Define the host machine with --hostname", -exitval => 2) unless defined $myhost; 139 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 140 pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir; 92 141 93 return ($myhost, $input); 142 # check that stage is an integer 143 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 144 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 145 146 my $yearobs = substr ($dateobs, 0, 4); 147 my $basedir = "$topdir/$yearobs"; 148 149 return ($myhost, $dateobs, $topdir, $basedir, $stage); 94 150 } 95 151 … … 100 156 return $status; 101 157 } 158 159 sub is_integer { 160 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 161 } 162 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/queue.rawfix.sh
r42399 r42531 1 1 #!/bin/csh 2 2 3 if ($#argv != 1) then 4 echo "USAGE: queue.rawfix.sh (mjddate)" 3 if ($#argv != 2) then 4 echo "USAGE: queue.rawfix.sh (list) (filename)" 5 echo "USAGE: queue.rawfix.sh (night) (YYYYMMDD)" 5 6 exit 2 6 7 endif 7 8 9 set mode = $1 10 8 11 # make the rawfix database to track rawfix operations 9 set DBHOST = "ipp 060"12 set DBHOST = "ippc190" 10 13 set DBNAME = "rawfix" 11 set DBUSER = "dvo"12 set DBPASS = "dvo"14 # set DBUSER = "dvo" 15 # set DBPASS = "dvo" 13 16 14 ## XXX validate the format (YYYYMMDD)? 15 set mynight = $1 17 set DBOPTS = "--defaults-extra-file=~/.my.cnf.rawfix -h $DBHOST $DBNAME" 16 18 17 mysql -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME -e "insert into nights (dateobs, state) values ('$mynight', 'new')" 19 if ($mode == "list") then 20 set filename = $2 21 22 # validate the list: could be DATE STATE or just DATE (prcol 1)? 23 24 # just a big list of dates? 25 foreach night (`cat $filename`) 26 queue.rawfix.sh night $night 27 end 28 exit 0 29 endif 30 31 if ($mode == "night") then 32 ## XXX validate the format (YYYYMMDD)? 33 set mynight = $2 34 35 set year = `echo $mynight | awk '{print substr($0, 1, 4)}'` 36 if (($year < 2005) || ($year > 2030)) then 37 echo "invalid date $mynight" 38 exit 2 39 endif 40 41 set month = `echo $mynight | awk '{print 1*substr($0, 5, 2)}'` 42 if (($month < 1) || ($month > 12)) then 43 echo "invalid date $mynight" 44 exit 2 45 endif 46 47 set day = `echo $mynight | awk '{print 1*substr($0, 7, 2)}'` 48 if (($day < 1) || ($day > 31)) then 49 echo "invalid date $mynight" 50 exit 2 51 endif 52 53 mysql $DBOPTS -e "insert into nights (dateobs, state) values ('$mynight', 'new')" 54 exit 0 55 endif 56 57 echo "ERROR: unknown mode $mode" 58 exit 2 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/rawfix.ckchip.pt
r42406 r42531 30 30 end 31 31 32 # need to delete DONE entries here so the book is not repopulated 33 # by already-running load tasks 32 34 task.exit 0 33 35 # convert the stdout 'queue' to entries in a book 34 36 # fields in the table will become words in the page 35 37 queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout ckchip.book 38 book delpage ckchip.book -key pantaskState DONE 36 39 end 37 40 … … 52 55 53 56 task nights.ckchip.run 54 55 57 periods -poll $RPOLL 56 58 periods -exec $REXEC 57 59 periods -timeout 60 58 npending 1 59 60 stdout $LOGDIR/ckchip.run.stdout.log 61 stderr $LOGDIR/ckchip.run.stderr.log 60 host -required $HOST_CKCHIP 61 npending 2 62 62 63 63 task.exec … … 75 75 book setword ckchip.book $pageName pantaskState RUN 76 76 book getword ckchip.book $pageName dateobs -var DATEOBS 77 book getword ckchip.book $pageName iter -var ITER 77 78 option $pageName 78 79 … … 81 82 substr $DATEOBS 6 2 DAY 82 83 84 # this is the first place in the proces that this location is known 85 mkdir $mypath/$YEAR/$DATEOBS 86 stdout $mypath/$YEAR/$DATEOBS/log.ckchip.runhosts.v$ITER 87 stderr $mypath/$YEAR/$DATEOBS/log.ckchip.runhosts.v$ITER 88 83 89 sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY 84 90 85 command check_chip_locations.pl --dateobs $FULLDATE --chiplist gpc1.chips.txt 91 # this command accesses the Nebulous and GPC databases, so it must run at ITC. 92 command check_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --stage $ITER 86 93 end 87 94 88 # # XX delete the page from the book if done?95 # mark the entry done, will be deleted above in .load 89 96 task.exit 0 90 # convert the stdout 'queue' to entries in a book 91 # fields in the table will become words in the page 92 # use the queuesize (Nhosts) to track how many jobs are done / to be done 97 book setword ckchip.book $options:0 pantaskState DONE 93 98 exec update.rawfix.sh $options:0 ckchip.done 94 book delpage ckchip.book $options:095 99 end 96 100 … … 116 120 end 117 121 122 # option for writing stdout / stderr to a file 123 # queuepush stdout "------- end of stdout ---------" 124 # queuesave stdout $options:0/log.ckchip.v$ITER 125 # queuepush stderr "------- end of stderr ---------" 126 # queuesave stderr $options:0/log.ckchip.v$ITER -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/rawfix.fixchip.pt
r42406 r42531 9 9 if (not($?RAWFIX_FIXCHIP_INIT)) 10 10 book init fixchip.book 11 book init fixhost.book 11 12 $RAWFIX_FIXCHIP_INIT = 1 12 13 end 14 15 $MAX_FIXHOST = 2 13 16 14 17 # select nights in state fixchip.new … … 27 30 28 31 task.exec 29 # command check.rawfix.sh state ckchip.done30 32 command check.rawfix.sh state fixchip.new 31 33 end … … 35 37 # fields in the table will become words in the page 36 38 queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout fixchip.book 37 end 38 39 # exit values other than 0: 40 task.exit default 41 showcommand failure 42 end 43 44 task.exit crash 45 showcommand crash 46 end 47 48 # operation times out? 49 task.exit timeout 50 showcommand timeout 51 end 52 end 53 54 task nights.fixchip.run 55 39 book delpage fixchip.book -key pantaskState DONE 40 end 41 42 # exit values other than 0: 43 task.exit default 44 showcommand failure 45 end 46 47 task.exit crash 48 showcommand crash 49 end 50 51 # operation times out? 52 task.exit timeout 53 showcommand timeout 54 end 55 end 56 57 # output: fixhost.book 58 task nights.fixchip.loadhosts 56 59 periods -poll $RPOLL 57 60 periods -exec $REXEC 58 61 periods -timeout 60 62 host local 59 63 npending 1 60 61 stdout $LOGDIR/fixchip.run.stdout.log 62 stderr $LOGDIR/fixchip.run.stderr.log 64 # note: the tasks which return their results via stdout 65 # seem to fail if run remotely. 66 67 stdout $LOGDIR/fixchip.loadhosts.stdout.log 68 stderr $LOGDIR/fixchip.loadhosts.stderr.log 63 69 64 70 task.exec … … 76 82 book setword fixchip.book $pageName pantaskState RUN 77 83 book getword fixchip.book $pageName dateobs -var DATEOBS 84 book getword fixchip.book $pageName iter -var ITER 78 85 option $pageName 86 # save the page so we can use it below 87 88 substr $DATEOBS 0 4 YEAR 89 90 # write an entry point in the log for this night 91 sprintf tmpline "%s/%s/%s/log.fixchip.runhosts.v%d" $mypath $YEAR $DATEOBS $ITER 92 date -var mydate 93 exec echo "# start runhosts $mydate" >> $tmpline 94 95 # the command returns these fields: dateobs stage fixhost chipID 96 # NOTE: stage == ITER 97 command get_hosts_fixchip.sh $mypath $DATEOBS $ITER 98 end 99 100 task.exit 0 101 # convert the stdout 'queue' to entries in a book 102 # fields in the table will become words in the page 103 # queueprint stdout 104 queuesize stdout -var Nhosts 105 queue2book -raw-columns -key dateobs:chipID -uniq -setword pantaskState INIT stdout fixhost.book 106 book setword fixchip.book $options:0 NHOST {$Nhosts - 1} 107 book setword fixchip.book $options:0 NDONE 0 108 # book list 109 # book listbook fixchip.book 110 # use the queuesize (Nhosts) to track how many jobs are done / to be done 111 end 112 113 # exit values other than 0: 114 task.exit default 115 showcommand failure 116 book setword fixchip.book $options:0 pantasksQuality FAIL 117 end 118 119 task.exit crash 120 showcommand crash 121 book setword fixchip.book $options:0 pantasksQuality CRASH 122 end 123 124 # operation times out? 125 task.exit timeout 126 showcommand timeout 127 book setword fixchip.book $options:0 pantasksQuality TIMEOUT 128 end 129 end 130 131 task nights.fixchip.run 132 periods -poll $RPOLL 133 periods -exec $REXEC 134 periods -timeout 1800 135 136 task.exec 137 # if we are unable to run the 'exec', use a long retry time 138 periods -exec $REXEC 139 140 book npages fixhost.book -var N 141 if ($N == 0) break 142 if ($NETWORK == 0) break 143 144 # look for new nights in fixhost.book (pantaskState == INIT) 145 book getpage fixhost.book 0 -var pageName -key pantaskState INIT 146 if ("$pageName" == "NULL") break 147 148 book setword fixhost.book $pageName pantaskState RUN 149 book getword fixhost.book $pageName dateobs -var DATEOBS 150 book getword fixhost.book $pageName iter -var ITER 151 book getword fixhost.book $pageName fixhost -var FIXHOST 152 book getword fixhost.book $pageName chipID -var CHIP_ID 79 153 80 154 substr $DATEOBS 0 4 YEAR … … 83 157 sprintf FULLDATE "%s/%s/%s" $YEAR $MONTH $DAY 84 158 85 command fix_chip_locations.pl --dateobs $FULLDATE --chiplist gpc1.chips.txt 86 end 87 88 ## XX delete the page from the book if done? 89 task.exit 0 90 # convert the stdout 'queue' to entries in a book 91 # fields in the table will become words in the page 92 # use the queuesize (Nhosts) to track how many jobs are done / to be done 93 exec update.rawfix.sh $options:0 fixchip.done 94 book delpage fixchip.book $options:0 159 option $pageName $DATEOBS $YEAR 160 # save DATEOBS so we can find the md5sum.book entry 161 # also save YEAR for output log 162 163 stdout $mypath/$YEAR/$DATEOBS/log.fixchip.run.$CHIP_ID.v$ITER 164 stderr $mypath/$YEAR/$DATEOBS/log.fixchip.run.$CHIP_ID.v$ITER 165 166 host -required $FIXHOST 167 ## check if this host needs to be launched 168 if (not($?host:$FIXHOST)) 169 echo "host not defined, creating : $FIXHOST" 170 $host:$FIXHOST = 0 171 end 172 if ($host:$FIXHOST < $MAX_FIXHOST) 173 control host add $FIXHOST 174 $host:$FIXHOST ++ 175 end 176 177 # if we are able to run the 'exec', use a short retry time to launch all outstanding jobs 178 periods -exec 0.05 179 command fix_chip_locations.pl --topdir $mypath --dateobs $FULLDATE --chiplist gpc1.chips.txt --chipID $CHIP_ID --stage $ITER 180 end 181 182 task.exit 0 183 nights.fixchip.exit OK 184 end 185 186 # exit values other than 0: 187 task.exit default 188 nights.fixchip.exit FAIL 189 showcommand failure 190 end 191 192 task.exit crash 193 nights.fixchip.exit CRASH 194 showcommand crash 195 end 196 197 # operation times out? 198 task.exit timeout 199 nights.fixchip.exit TIMEOUT 200 showcommand timeout 201 end 202 end 203 204 # output: fixhost.book 205 task nights.fixchip.clean 206 207 periods -poll $RPOLL 208 periods -exec $REXEC 209 periods -timeout 60 210 npending 1 211 212 stdout $LOGDIR/fixchip.clean.stdout.log 213 stderr $LOGDIR/fixchip.clean.stderr.log 214 215 task.exec 216 # if we are unable to run the 'exec', use a long retry time 217 periods -exec $REXEC 218 219 book npages fixchip.book -var N 220 if ($N == 0) break 221 if ($NETWORK == 0) break 222 223 # look for completed nights in fixchip.book (pantaskState == STOP) 224 book getpage fixchip.book 0 -var pageName -key pantaskState STOP 225 if ("$pageName" == "NULL") break 226 227 # book listpage fixchip.book $pageName 228 229 # book setword fixchip.book $pageName pantaskState RUN 230 book getword fixchip.book $pageName dateobs -var DATEOBS 231 book getword fixchip.book $pageName pantasksQuality -var QUALITY 232 233 option $pageName 234 # save the page so we can use it below 235 236 if ("$QUALITY" == "OK") 237 command update.rawfix.sh $DATEOBS fixchip.done 238 else 239 command update.rawfix.sh $DATEOBS fixchip.fail 240 end 241 end 242 243 task.exit 0 244 # now that the entry is set to done in the db, remove the pantasks book entry 245 echo "cleaning this page: $options:0" 246 book setword fixchip.book $options:0 pantaskState DONE 95 247 end 96 248 … … 99 251 showcommand failure 100 252 book setword fixchip.book $options:0 pantasksQuality FAIL 101 exec update.rawfix.sh $options:0 fixchip.fail102 253 end 103 254 … … 105 256 showcommand crash 106 257 book setword fixchip.book $options:0 pantasksQuality CRASH 107 exec update.rawfix.sh $options:0 fixchip.fail108 258 end 109 259 … … 112 262 showcommand timeout 113 263 book setword fixchip.book $options:0 pantasksQuality TIMEOUT 114 exec update.rawfix.sh $options:0 fixchip.fail 115 end 116 end 117 264 end 265 end 266 267 ######################### UTILITIES ################################# 268 269 macro nights.fixchip.exit 270 if ($0 != 2) 271 echo "USAGE: nights.fixchip.exit (quality)" 272 break 273 end 274 275 # options are : pagename DATEOBS YEAR 276 277 book setword fixhost.book $options:0 pantaskState DONE 278 book getword fixchip.book $options:1 NHOST -var Nhosts 279 book getword fixchip.book $options:1 NDONE -var Ndone 280 book getword fixchip.book $options:1 stage -var ITER 281 $Ndone ++ 282 book setword fixchip.book $options:1 NDONE $Ndone 283 284 sprintf tmpline "%s/%s/%s/log.fixchip.runhosts.v%d" $mypath $options:2 $options:1 $ITER 285 if ("$1" != "OK") 286 book setword fixchip.book $options:1 pantasksQuality $1 287 exec echo "failure $1 $options:0" >> $tmpline 288 else 289 exec echo "success $1 $options:0" >> $tmpline 290 end 291 if ($Ndone == $Nhosts) 292 book setword fixchip.book $options:1 pantaskState STOP 293 end 294 book delpage fixhost.book $options:0 295 end 296 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/rawfix.md5sum.pt
r42405 r42531 12 12 $RAWFIX_MD5SUM_INIT = 1 13 13 end 14 15 $MAX_MD5HOST = 2 14 16 15 17 # select nights which are ready for md5sum calcs … … 35 37 # fields in the table will become words in the page 36 38 queue2book -raw-columns -key dateobs -uniq -setword pantaskState INIT -setword pantasksQuality OK stdout md5sum.book 39 book delpage md5sum.book -key pantaskState DONE 37 40 end 38 41 … … 54 57 # output: md5host.book 55 58 task nights.md5sum.loadhosts 56 57 59 periods -poll $RPOLL 58 60 periods -exec $REXEC 59 61 periods -timeout 60 62 host local 60 63 npending 1 64 # note: the tasks which return their results via stdout 65 # seem to fail if run remotely. 61 66 62 67 stdout $LOGDIR/md5sum.loadhosts.stdout.log … … 77 82 book setword md5sum.book $pageName pantaskState RUN 78 83 book getword md5sum.book $pageName dateobs -var DATEOBS 84 book getword md5sum.book $pageName iter -var ITER 79 85 option $pageName 80 86 # save the page so we can use it below 81 87 88 substr $DATEOBS 0 4 YEAR 89 82 90 # write an entry point in the log for this night 83 sprintf tmpline "%s/%s/ md5sum.runhosts.log" $mypath $DATEOBS91 sprintf tmpline "%s/%s/%s/log.md5sum.runhosts.v%d" $mypath $YEAR $DATEOBS $ITER 84 92 date -var mydate 85 93 exec echo "# start runhosts $mydate" >> $tmpline 86 94 87 command get_hosts_md5s.sh $DATEOBS 95 # the command returns these fields: dateobs stage md5host 96 # NOTE: stage == ITER 97 command get_hosts_md5s.sh $mypath $DATEOBS $ITER 88 98 end 89 99 … … 91 101 # convert the stdout 'queue' to entries in a book 92 102 # fields in the table will become words in the page 103 # queueprint stdout 93 104 queuesize stdout -var Nhosts 94 105 queue2book -raw-columns -key dateobs:md5host -uniq -setword pantaskState INIT stdout md5host.book 95 106 book setword md5sum.book $options:0 NHOST {$Nhosts - 1} 96 107 book setword md5sum.book $options:0 NDONE 0 108 # book list 109 # book listbook md5sum.book 97 110 # use the queuesize (Nhosts) to track how many jobs are done / to be done 98 111 end … … 116 129 end 117 130 131 # runs on the hosts identified by get_hosts_md5s.sh 118 132 # output: md5host.book 119 task nights.md5sum.run hosts133 task nights.md5sum.run 120 134 121 135 periods -poll $RPOLL 122 136 periods -exec $REXEC 123 137 periods -timeout 60 124 125 stdout $LOGDIR/md5sum.runhosts.stdout.log126 stderr $LOGDIR/md5sum.runhosts.stderr.log127 138 128 139 task.exec … … 138 149 if ("$pageName" == "NULL") break 139 150 151 # XXX NOTE: the output field is called 'stage' 140 152 book setword md5host.book $pageName pantaskState RUN 141 153 book getword md5host.book $pageName dateobs -var DATEOBS 154 book getword md5host.book $pageName stage -var ITER 142 155 book getword md5host.book $pageName md5host -var MD5HOST 143 156 144 option $pageName $DATEOBS 157 substr $DATEOBS 0 4 YEAR 158 159 option $pageName $DATEOBS $YEAR 145 160 # save DATEOBS so we can find the md5sum.book entry 146 147 # XXX TEST: $USE_HOST = ipp060 161 # also save YEAR for output log 162 163 # does the output go here? 164 stdout $mypath/$YEAR/$DATEOBS/log.md5sum.$MD5HOST.v$ITER 165 stderr $mypath/$YEAR/$DATEOBS/log.md5sum.$MD5HOST.v$ITER 148 166 149 167 $USE_HOST = $MD5HOST … … 154 172 $host:$USE_HOST = 0 155 173 end 156 if ( not($host:$USE_HOST))174 if ($host:$USE_HOST < $MAX_MD5HOST) 157 175 control host add $USE_HOST 158 $host:$USE_HOST = 1176 $host:$USE_HOST ++ 159 177 end 160 178 161 179 ## even when testing, use the original hostname here: 162 $input = $mypath/$DATEOBS/$MD5HOST.inst. txt180 $input = $mypath/$DATEOBS/$MD5HOST.inst.$ITER.txt 163 181 164 182 # need to make sure this will work on the ipp b-nodes: 165 183 # if we are able to run the 'exec', use a short retry time to launch all outstanding jobs 166 184 periods -exec 0.05 167 command $mypath/get_md5s_instances.pl --hostname $USE_HOST --input $input185 command get_md5s_instances.pl --hostname $USE_HOST --topdir $mypath --dateobs $DATEOBS --stage $ITER 168 186 end 169 187 170 188 task.exit 0 171 nights.md sum.exit OK189 nights.md5sum.exit OK 172 190 end 173 191 174 192 # exit values other than 0: 175 193 task.exit default 176 nights.md sum.exit FAIL194 nights.md5sum.exit FAIL 177 195 showcommand failure 178 196 end 179 197 180 198 task.exit crash 181 nights.md sum.exit CRASH199 nights.md5sum.exit CRASH 182 200 showcommand crash 183 201 end … … 185 203 # operation times out? 186 204 task.exit timeout 187 nights.md sum.exit TIMEOUT205 nights.md5sum.exit TIMEOUT 188 206 showcommand timeout 189 207 end … … 210 228 211 229 # look for completed nights in md5sum.book (pantaskState == DONE) 212 book getpage md5sum.book 0 -var pageName -key pantaskState DONE230 book getpage md5sum.book 0 -var pageName -key pantaskState STOP 213 231 if ("$pageName" == "NULL") break 214 232 … … 232 250 # now that the entry is set to done in the db, remove the pantasks book entry 233 251 echo "cleaning this page: $options:0" 234 book delpage md5sum.book $options:0252 book setword md5sum.book $options:0 pantaskState DONE 235 253 end 236 254 … … 255 273 ######################### UTILITIES ################################# 256 274 257 macro nights.md sum.exit275 macro nights.md5sum.exit 258 276 if ($0 != 2) 259 echo "USAGE: nights.md sum.exit (quality)"277 echo "USAGE: nights.md5sum.exit (quality)" 260 278 break 261 279 end 280 281 # options are : pagename DATEOBS YEAR 262 282 263 283 book setword md5host.book $options:0 pantaskState DONE 264 284 book getword md5sum.book $options:1 NHOST -var Nhosts 265 285 book getword md5sum.book $options:1 NDONE -var Ndone 286 book getword md5sum.book $options:1 stage -var ITER 266 287 $Ndone ++ 267 288 book setword md5sum.book $options:1 NDONE $Ndone 289 290 sprintf tmpline "%s/%s/%s/log.md5sum.runhosts.v%d" $mypath $options:2 $options:1 $ITER 268 291 if ("$1" != "OK") 269 292 book setword md5sum.book $options:1 pantasksQuality $1 270 sprintf tmpline "%s/%s/md5sum.runhosts.log" $mypath $options:1271 293 exec echo "failure $1 $options:0" >> $tmpline 272 294 else … … 274 296 end 275 297 if ($Ndone == $Nhosts) 276 book setword md5sum.book $options:1 pantaskState DONE298 book setword md5sum.book $options:1 pantaskState STOP 277 299 end 278 300 book delpage md5host.book $options:0 -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/rawfix.pt
r42406 r42531 1 1 ## pantasks scripts to manage the raw exposure data repair / cleanup 2 3 $TPOLL = 54 $TEXEC = 55 $RPOLL = 56 $REXEC = 57 $VERBOSE = 18 $NETWORK = 19 10 # use this to find the files in this local directory11 $mypath = /home/panstarrs/eugene/rawfix.2023022112 13 if (not($?LOGDIR))14 $LOGDIR = $mypath/pantasks_logs15 mkdir $LOGDIR16 end17 18 input rawfix.ckchip.pt19 # input rawfix.md5sum.pt20 2 21 3 ######################### UTILITIES ################################# -
branches/eam_branches/ipp-20230313/tools/eam/rawfix.20230221/src/update.rawfix.sh
r42400 r42531 2 2 3 3 if ($#argv < 1) then 4 echo "USAGE: update.rawfix.sh (night) (state) [ quality]"4 echo "USAGE: update.rawfix.sh (night) (state) [iter]" 5 5 echo " EG: update.rawfix.sh 20100501 new" 6 6 exit 2 … … 10 10 set state = $2 11 11 12 set iter = "" 13 if ($#argv == 3) then 14 set iter = ", iter = $3" 15 endif 16 12 17 # make the rawfix database to track rawfix operations 13 set DBHOST = "ipp 060"18 set DBHOST = "ippc190" 14 19 set DBNAME = "rawfix" 15 set DBUSER = "dvo"16 set DBPASS = "dvo"20 # set DBUSER = "dvo" 21 # set DBPASS = "dvo" 17 22 18 set DBOPTS = "-B --skip-column-names -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME" 23 # set DBOPTS = "-B --skip-column-names -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME" 24 set DBOPTS = "--defaults-extra-file=~/.my.cnf.rawfix -B --skip-column-names -h $DBHOST $DBNAME" 19 25 20 mysql $DBOPTS -e "update nights set state = '$state' where (dateobs = '$mynight')"26 mysql $DBOPTS -e "update nights set state = '$state' $iter where (dateobs = '$mynight')" 21 27 exit 0 -
branches/eam_branches/ipp-20230313/tools/eam/rebalance/launch.rsync.sh
r42314 r42531 1 1 #!/bin/csh 2 2 3 # set list = "ipp100 ipp101 ipp102 ipp104 ipp105 ipp108 ipp112 ipp114 ipp115 ipp117 ipp123 ipp124 ipp125 ipp126 ipp134 ipp136 ipp137 ipp139" 4 # set list = "ipp105 ipp108 ipp112 ipp114 ipp115 ipp123 ipp124 ipp125 ipp126 ipp134 ipp136 ipp137 ipp139" 5 set list = "ipp100 ipp101 ipp102 ipp104 ipp117" 6 set mydir = /data/ipphome1.0/home/eugene/rebalance.20220922 3 set program = `basename $0` 7 4 8 if ($#argv == 1) then 9 if ("$1" != "launch") then 10 echo "USAGE: launch.find.sh launch" 11 exit 2 12 endif 13 foreach f ($list) 14 echo ssh -f $f "cd $mydir && ./launch.rsync.sh" 15 ssh -f $f "cd $mydir && ./launch.rsync.sh" 16 # echo ssh $f ps ux 17 # ssh $f ps ux 18 # ssh $f killall mana 19 # ssh $f killall find 5 set run = v0 6 set version = 20230802 7 set mode = rsync 8 9 set srchost = (ipp100 ipp108 ipp112 ipp114) 10 set srcvol = ( 0 0 1 0) 11 set tgthost = (ipp161 ipp161 ipp162 ipp162) 12 set tgtvol = ( 0 1 0 1) 13 14 set mydir = /data/ipphome1.0/home/eugene/rebalance.20230802 15 16 if ($#argv == 0) then 17 echo "USAGE: $program launch" 18 echo "USAGE: $program run (Nentry)" 19 echo " eg: $program run 1" 20 exit 2 21 endif 22 23 if ("$1" == "launch") then 24 25 set i = 1 26 while ($i <= $#srchost) 27 echo ssh -f $srchost[$i] "cd $mydir && ./$program run $i" 28 ssh -f $srchost[$i] "cd $mydir && ./$program run $i" 29 @ i++ 20 30 end 21 31 exit 0 22 32 endif 23 33 24 set run = v0 25 set version = 20220922 34 if ("$1" == "run") then 35 if ($#argv != 2) then 36 echo "USAGE: $program run (Nentry)" 37 echo " eg: $program run 1" 38 exit 2 39 endif 26 40 27 set myhost = `hostname` 28 set Nhost = `hostname | sed s/ipp//` 41 set N = $2 29 42 30 set target = NONE 31 switch ($myhost) 32 # total of 23TB 33 case ipp100 34 case ipp101 35 case ipp123 36 set target = ipp153 37 breaksw; 43 set hn = $srchost[$N] 44 set hv = $srcvol[$N] 45 set tn = $tgthost[$N] 46 set tv = $tgtvol[$N] 38 47 39 # total of 35TB 40 case ipp102 41 case ipp104 42 case ipp124 43 case ipp136 44 set target = ipp154 45 breaksw; 48 set myhost = `hostname` 49 if ($hn != $myhost) then 50 echo "ERROR: need to run $mode on the source host ($hn vs $myhost)" 51 exit 3 52 endif 46 53 47 # total of 35TB 48 case ipp105 49 case ipp108 50 case ipp125 51 case ipp137 52 set target = ipp155 53 breaksw; 54 55 # total of 23TB 56 case ipp112 57 case ipp114 58 case ipp126 59 set target = ipp156 60 breaksw; 61 62 # total of 38TB 63 case ipp115 64 case ipp117 65 case ipp134 66 case ipp139 67 set target = ipp157 68 breaksw; 69 endsw 70 71 if ("$target" == "NONE") then 72 echo "need target" 73 exit 2 54 echo "running on $myhost for source $hn.$hv to target $tn.$tv in mode $mode, version $version" 55 mkdir -p $hn.$hv 56 echo "./rebalance.mana $mode $hn $hv $tn $tv $version > & $hn.$hv/log.$mode.$version.$run &" 57 ./rebalance.mana $mode $hn $hv $tn $tv $version > & $hn.$hv/log.$mode.$version.$run & 58 exit 0 74 59 endif 75 76 set v = 0 ; set h = `hostname` ; set t = $target; ./rebalance.mana rsync $h $v $t $v $version > & $h.$v/log.rsync.$version.$run &77 set v = 1 ; set h = `hostname` ; set t = $target; ./rebalance.mana rsync $h $v $t $v $version > & $h.$v/log.rsync.$version.$run &78 79 # e.g.: ssh -f ipp127 "cd `pwd` && ./launch.rsync.sh" -
branches/eam_branches/ipp-20230313/tools/eam/skycoverage/coverage.mana.sh
r41436 r42531 319 319 cplot -pt 0 -sz 0.4 $RCOLOR el eb 320 320 end 321 322 $RCOLOR = -c grey70 323 DR1.boundary 324 end 325 326 macro DR1.boundary 327 if (1) 328 if (0) 329 data EuclidDR1_polygon.csv 330 read -skip 1 -csv Re 1 De 2 331 cplot -pt 0 -sz 0.5 -c green Re De 332 end 333 334 # north boundary: 335 # corner 105, 80 -> 94.7, 56.9 in ecliptic 336 create Rn 105.2 285 0.1 337 set Dn = zero(Rn) + 80 338 cplot $RCOLOR -pt box -sz 0.4 Rn Dn 339 340 # west boundary 341 create elat 50 56.9 0.1 342 set elon = zero(elat) + 95 343 csystem E C elon elat 344 cplot $RCOLOR -pt box -sz 0.4 elon elat 345 346 # south boundary west 347 create elon 95 150 0.1 348 set elat = zero(elon) + 50 349 csystem E C elon elat 350 cplot $RCOLOR -pt box -sz 0.4 elon elat 351 352 # south boundary east 353 create elat 50 80 0.1 354 set elon = zero(elat) + 150 355 csystem E C elon elat 356 cplot $RCOLOR -pt box -sz 0.4 elon elat 357 358 # NEP circle 359 create elon3 150 296 0.1 360 set elat3 = zero(elon3) + 80 361 csystem E C elon3 elat3 362 cplot $RCOLOR elon3 elat3 -pt box -sz 0.4 363 364 # galactic plane boundary east 365 create glon 86.5 103 0.1 366 set glat = zero(glon) + 25 367 csystem G C glon glat 368 cplot $RCOLOR -pt box -sz 0.4 glon glat 369 370 # east boundary 371 create Dn 72 80 0.1 372 set Rn = zero(Dn) + 285 373 csystem E C elon elat 374 cplot $RCOLOR -pt box -sz 0.4 Rn Dn 375 376 # DR2 south boundary 377 create elon 100.3 189.5 0.1 378 set elat = zero(elon) + 37 379 csystem E C elon elat 380 cplot $RCOLOR -pt box -sz 0.4 elon elat 381 end 321 382 end 322 383
Note:
See TracChangeset
for help on using the changeset viewer.
