IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 31, 2011, 5:18:37 PM (15 years ago)
Author:
watersc1
Message:

Updates to finish migration of summarization code into nebulous outputs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diskspace/merge_counts_and_sizes.pl

    r32230 r32265  
    22
    33use Getopt::Std;
     4use DateTime;
     5use PS::IPP::Config;
    46
    5 getopts('I',\%opt);
     7getopts('N',\%opt);
    68
    7 open(S,"summary.dat") || die "Cannot find summary.dat\n";
     9my $ipprc = PS::IPP::Config->new("GPC1");
     10my $nebcon = $ipprc->nebulous();
     11
     12my @lt = gmtime;
     13my $dt = DateTime->now;
     14$dt->subtract( days => $lt[6] );
     15my $datestring = $dt->ymd;
     16
     17my $summary_file = "neb:///ipp_diskspace/${datestring}/summary.dat";
     18my $S_real_file = $ipprc->file_resolve($summary_file);
     19open(S,$S_real_file) || die "Cannot find summary.dat\n";
    820
    921while (<S>) {
     
    1931close(S);
    2032
    21 if (exists($opt{I})) {
    22     open(C,"run_im_counts.dat") || die "Cannot find run_counts.dat\n";
    23 }
    24 else {
    25     open(C,"run_counts.dat") || die "Cannot find run_counts.dat\n";
    26 }
     33my $count_file = "neb:///ipp_diskspace/${datestring}/run_im_counts.dat";
     34my $C_real_file = $ipprc->file_resolve($count_file);
     35open(C,$C_real_file) || die "Cannot find run_counts.dat\n";
    2736while(<C>) {
    2837    chomp;
     
    3746close(C);
    3847
    39 if (exists($opt{I})) {
    40     open(M,"mappings_im.dat") || die "Cannot find mappings.dat\n";
    41 }
    42 else {
    43     open(M,"mappings.dat") || die "Cannot find mappings.dat\n";
    44 }
     48my $mappings_file = "neb:///ipp_diskspace/mappings_im.dat";
     49my $M_real_file = $ipprc->file_resolve($mappings_file);
     50open(M,$M_real_file) || die "Cannot find mappings.dat\n";
    4551while (<M>) {
    4652    chomp;
     
    5763}
    5864close(M);
     65
    5966foreach $stage (keys (%size)) {
    6067    foreach $state (keys (%{ $count{$stage} })) {
     
    6875
    6976foreach $stage (keys (%size)) {
    70 #    unless ($stage eq 'RAW') { next; }
    7177    foreach $state (keys (%{ $count{$stage} })) {
    7278        $VpN{$stage}{$state} = 0;
    7379        foreach $product (keys (%{ $size{$stage} })) {
    7480            $N{$stage}{$product} += $map{$stage}{$product}{$state} * $count{$stage}{$state};
    75 #           if ($N{$stage}{$product} > 0) {
    76 #               $VpN{$stage}{$state} += $size{$stage}{$product} / $N{$stage}{$product};
    77 #           }
    78 
    7981        }               
    8082    }
     
    8991}
    9092
     93my $out_fh;
     94
     95if (exists($opt{N})) {
     96    my $dt = DateTime->now;
     97
     98    my @lt = gmtime;
     99    my $dt_data = DateTime->now;
     100    $dt->subtract( days => $lt[6]);
     101    my $datestring = $dt->ymd;
     102    my $ipprc = PS::IPP::Config->new("GPC1");
     103    my $nebcon = $ipprc->nebulous();
     104
     105    my $outfile = "neb:///ipp_diskspace/${datestring}/usage_report.dat";
     106
     107    if ($ipprc->file_exists($outfile)) {
     108        my $U_file = $ipprc->file_resolve($outfile);
     109        open($out_fh,">$U_file");
     110    }
     111    else {
     112        $out_fh = $ipprc->file_create_open($outfile);
     113    }
     114}
     115
    91116foreach $stage (sort (keys %VpN)) {
    92 #    unless ($stage eq 'RAW') { next; }
    93 
    94117    foreach $state (sort (keys %{ $VpN{$stage} })) {
    95118        unless(exists($count{$stage}{$state})) {
     
    124147        printf("%-8s %-18s %-10s %14.4f %12.6f %9d\n",
    125148                $stage,$state,$label,$V,$VpN{$stage}{$state},$count{$stage}{$state});
     149        if (exists($opt{N})) {
     150            printf($out_fh "%-8s %-18s %-10s %14.4f %12.6f %9d\n",
     151                   $stage,$state,$label,$V,$VpN{$stage}{$state},$count{$stage}{$state});
     152        }
    126153    }
    127154}
     
    130157    $sum += $labels{$l};
    131158    print STDERR "\t$l  \t$labels{$l}\n";
     159    if (exists($opt{N})) {
     160        print $out_fh "\t$l  \t$labels{$l}\n";
     161    }
    132162}
    133163print STDERR "\tTOTAL    \t$sum\n";
    134164print STDERR "\tEXP_TOT  \t$total\n";
     165
     166if (exists($opt{N})) {
     167    print $out_fh "\tTOTAL    \t$sum\n";
     168    print $out_fh "\tEXP_TOT  \t$total\n";
     169    close($out_fh);
     170}
Note: See TracChangeset for help on using the changeset viewer.