Changeset 32265
- Timestamp:
- Aug 31, 2011, 5:18:37 PM (15 years ago)
- Location:
- trunk/tools/diskspace
- Files:
-
- 4 edited
-
merge_counts_and_sizes.pl (modified) (8 diffs)
-
nebulous_data.pl (modified) (1 diff)
-
nebulous_wiki.pl (modified) (2 diffs)
-
run_counter.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diskspace/merge_counts_and_sizes.pl
r32230 r32265 2 2 3 3 use Getopt::Std; 4 use DateTime; 5 use PS::IPP::Config; 4 6 5 getopts(' I',\%opt);7 getopts('N',\%opt); 6 8 7 open(S,"summary.dat") || die "Cannot find summary.dat\n"; 9 my $ipprc = PS::IPP::Config->new("GPC1"); 10 my $nebcon = $ipprc->nebulous(); 11 12 my @lt = gmtime; 13 my $dt = DateTime->now; 14 $dt->subtract( days => $lt[6] ); 15 my $datestring = $dt->ymd; 16 17 my $summary_file = "neb:///ipp_diskspace/${datestring}/summary.dat"; 18 my $S_real_file = $ipprc->file_resolve($summary_file); 19 open(S,$S_real_file) || die "Cannot find summary.dat\n"; 8 20 9 21 while (<S>) { … … 19 31 close(S); 20 32 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 } 33 my $count_file = "neb:///ipp_diskspace/${datestring}/run_im_counts.dat"; 34 my $C_real_file = $ipprc->file_resolve($count_file); 35 open(C,$C_real_file) || die "Cannot find run_counts.dat\n"; 27 36 while(<C>) { 28 37 chomp; … … 37 46 close(C); 38 47 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 } 48 my $mappings_file = "neb:///ipp_diskspace/mappings_im.dat"; 49 my $M_real_file = $ipprc->file_resolve($mappings_file); 50 open(M,$M_real_file) || die "Cannot find mappings.dat\n"; 45 51 while (<M>) { 46 52 chomp; … … 57 63 } 58 64 close(M); 65 59 66 foreach $stage (keys (%size)) { 60 67 foreach $state (keys (%{ $count{$stage} })) { … … 68 75 69 76 foreach $stage (keys (%size)) { 70 # unless ($stage eq 'RAW') { next; }71 77 foreach $state (keys (%{ $count{$stage} })) { 72 78 $VpN{$stage}{$state} = 0; 73 79 foreach $product (keys (%{ $size{$stage} })) { 74 80 $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 79 81 } 80 82 } … … 89 91 } 90 92 93 my $out_fh; 94 95 if (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 91 116 foreach $stage (sort (keys %VpN)) { 92 # unless ($stage eq 'RAW') { next; }93 94 117 foreach $state (sort (keys %{ $VpN{$stage} })) { 95 118 unless(exists($count{$stage}{$state})) { … … 124 147 printf("%-8s %-18s %-10s %14.4f %12.6f %9d\n", 125 148 $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 } 126 153 } 127 154 } … … 130 157 $sum += $labels{$l}; 131 158 print STDERR "\t$l \t$labels{$l}\n"; 159 if (exists($opt{N})) { 160 print $out_fh "\t$l \t$labels{$l}\n"; 161 } 132 162 } 133 163 print STDERR "\tTOTAL \t$sum\n"; 134 164 print STDERR "\tEXP_TOT \t$total\n"; 165 166 if (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 } -
trunk/tools/diskspace/nebulous_data.pl
r32233 r32265 52 52 my $nebcon = $ipprc->nebulous(); 53 53 54 my @lt = localtime; 55 $lt[5] += 1900; 56 $lt[4] += 1; 57 $lt[3] -= $lt[6]; 58 my $datestring = sprintf("%04d-%02d-%02d",$lt[5],$lt[4],$lt[3]); 54 my @lt = gmtime; 55 $dt = DateTime->now; 56 $dt->subtract( days => $lt[6]); 57 my $datestring = $dt->ymd; 59 58 my $outfile = "neb:///ipp_diskspace/${datestring}/${neb}.neb_usage.dat"; 60 59 my $out_fh = $ipprc->file_create_open($outfile); -
trunk/tools/diskspace/nebulous_wiki.pl
r32230 r32265 2 2 3 3 use DateTime; 4 $dt = DateTime->now; 4 use Getopt::Std; 5 use PS::IPP::Config; 5 6 6 7 7 @files = sort (<*.size.dat>); 8 $opt{S} = 0; 9 getopts('S',\%opt); 10 11 my $dt = DateTime->now; 12 13 my @lt = gmtime; 14 my $dt_data = DateTime->now; 15 $dt->subtract( days => $lt[6]); 16 my $datestring = $dt->ymd; 17 18 @files = sort ( split /\n/, `neb-ls -p neb:///ipp_diskspace/${datestring}/%neb_usage.dat`); 8 19 9 20 foreach $f (@files) { 10 21 $volume = $f; 11 $volume =~ s/.size.dat//; 22 $volume =~ s/.*://; 23 $volume =~ s/.neb_usage.dat//; 12 24 open(F,$f); 13 25 while(<F>) { … … 37 49 $presep = '||'; 38 50 39 print "${presep}Volume${sep}"; 40 foreach $w (sort (keys %sizes)) { 41 print "$w$sep"; 42 } 43 print "\n"; 44 foreach $v (sort (keys %sum)) { 45 print "${presep}${v}${sep}"; 51 if ($opt{S} == 0) { 52 print "${presep}Volume${sep}"; 46 53 foreach $w (sort (keys %sizes)) { 47 $val = $vol{$v}{$w} / 1024 / 1024 / 1024; 54 print "$w$sep"; 55 } 56 print "\n"; 57 foreach $v (sort (keys %sum)) { 58 print "${presep}${v}${sep}"; 59 foreach $w (sort (keys %sizes)) { 60 $val = $vol{$v}{$w} / 1024 / 1024 / 1024; 61 printf "%.2f%s",$val,$sep; 62 } 63 $val = $sum{$v} / 1024 / 1024 / 1024; 64 printf "%.2f%s",$val,$sep; 65 print "\n"; 66 } 67 $date = $dt->ymd; 68 print "${presep}${date}${sep}"; 69 foreach $w (sort (keys %sizes)) { 70 $val = $sizes{$w} / 1024 / 1024 / 1024; 48 71 printf "%.2f%s",$val,$sep; 49 72 } 50 $val = $sum{$v} / 1024 / 1024 / 1024;51 printf "%.2f%s",$val,$sep;52 73 print "\n"; 53 74 } 54 $date = $dt->ymd; 55 print "${presep}${date}${sep}"; 56 foreach $w (sort (keys %sizes)) { 57 $val = $sizes{$w} / 1024 / 1024 / 1024; 58 printf "%.2f%s",$val,$sep; 75 else { 76 my $ipprc = PS::IPP::Config->new("GPC1"); 77 my $nebcon = $ipprc->nebulous(); 78 79 my $outfile = "neb:///ipp_diskspace/${datestring}/summary.dat"; 80 my $out_fh; 81 if ($ipprc->file_exists($outfile)) { 82 my $S_file = $ipprc->file_resolve($outfile); 83 open($out_fh,">$S_file"); 84 } 85 else { 86 $out_fh = $ipprc->file_create_open($outfile); 87 } 88 foreach $w (sort (keys %sizes)) { 89 $val = $sizes{$w} / 1024 / 1024 / 1024; 90 print $out_fh "$w $val\n"; 91 } 92 close($out_fh); 59 93 } 60 print "\n";61 94 62 95 -
trunk/tools/diskspace/run_counter.pl
r32230 r32265 1 #! /usr/local/bin/perl -w 1 #! /usr/bin/env perl 2 use warnings; 2 3 4 use DateTime; 5 use Sys::Hostname; 6 use PS::IPP::Config; 3 7 use DBI; 4 use Getopt::Std;5 8 6 getopts('I',\%opt);7 9 # Set up the database 8 10 use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock'; … … 41 43 $im_query = 'select data_state,count(data_state) AS N from TABLETABLE GROUP BY data_state'; 42 44 43 if (exists($opt{I})) { 44 foreach $k (keys %im_stages) { 45 $stages{$k} = $im_stages{$k}; 46 } 45 foreach $k (keys %im_stages) { 46 $stages{$k} = $im_stages{$k}; 47 47 } 48 49 my $ipprc = PS::IPP::Config->new("GPC1"); 50 my $nebcon = $ipprc->nebulous(); 51 52 my @lt = gmtime; 53 $dt = DateTime->now; 54 $dt->subtract( days => $lt[6]); 55 my $datestring = $dt->ymd; 56 my $outfile = "neb:///ipp_diskspace/${datestring}/run_im_counts.dat"; 57 my $out_fh = $ipprc->file_create_open($outfile); 48 58 49 59 foreach $s (keys %stages) { 50 60 my $query = $base_query; 51 if (exists($ opt{I}) && exists($im_stages{$s})) {61 if (exists($im_stages{$s})) { 52 62 $query = $im_query; 53 63 } … … 57 67 foreach $rr (@{ $dr }) { 58 68 my ($state,$count) = @{ $rr }; 59 print "$s $state $count\n";69 print $out_fh "$s $state $count\n"; 60 70 } 61 71 } 62 72 close($out_fh); 73
Note:
See TracChangeset
for help on using the changeset viewer.
