Changeset 31871
- Timestamp:
- Jul 13, 2011, 2:00:06 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous/bin/neb-stat (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/bin/neb-stat
r24644 r31871 16 16 use Pod::Usage qw( pod2usage ); 17 17 18 my ($server); 18 use Digest::MD5; 19 use URI; 20 21 my ($validate,$server); 19 22 20 23 $server = $ENV{'NEB_SERVER'} unless $server; … … 22 25 GetOptions( 23 26 'server|s=s' => \$server, 27 'validate' => \$validate, 24 28 ) || pod2usage( 2 ); 25 29 … … 44 48 die "no instances found" unless $instances; 45 49 50 my $user_copies = $neb->getxattr($key, "user.copies"); 51 unless(defined($user_copies)) { 52 $user_copies = 1; 53 } 54 55 my @validation; 56 my %md5sum_uniq; 57 my $existing_copies = 0; 58 if (defined $validate) { 59 my @existance; 60 my @md5sums; 61 my @files = map {URI->new($_)->file if $_} @$instances; 62 63 for (my $i = 0; $i <= $#files; $i++) { 64 if (-e $files[$i]) { 65 $existance[$i] = 1; 66 $existing_copies++; 67 my $fh; 68 open($fh,$files[$i]); 69 $md5sums[$i] = Digest::MD5->new->addfile($fh)->hexdigest; 70 $md5sum_uniq{$md5sums[$i]} = 1; 71 close($fh); 72 } 73 else { 74 $existance[$i] = 0; 75 $md5sums[$i] = 'NON-EXISTANT'; 76 $md5sum_uniq{$md5sums[$i]} = 1; 77 } 78 $validation[$i] = sprintf("% 3d %32s %s", 79 $existance[$i], 80 $md5sums[$i], 81 ${ $instances }[$i]); 82 } 83 } 84 46 85 no warnings qw(uninitialized); 47 print 48 "object id: ", @$stat[0], "\n", 49 "key: ", @$stat[1], "\n", 50 "read lock: ", @$stat[2], "\n", 51 "write lock: ", @$stat[3], "\n", 52 "epoch: ", @$stat[4], "\n", 53 "mtime: ", @$stat[5], "\n", 54 "available instances: ", @$stat[6], "\n", 55 "total instances: ", @$stat[7], "\n", 56 "instance location:\n", " " x 4, 57 join("\n" . " " x 4, @$instances), "\n"; 86 if (defined $validate) { 87 print 88 "object id: ", @$stat[0], "\n", 89 "key: ", @$stat[1], "\n", 90 "read lock: ", @$stat[2], "\n", 91 "write lock: ", @$stat[3], "\n", 92 "epoch: ", @$stat[4], "\n", 93 "mtime: ", @$stat[5], "\n", 94 "md5sum count: ", scalar(keys %md5sum_uniq), "\n", 95 "requested instances: ", $user_copies, "\n", 96 "available instances: ", @$stat[6], "\n", 97 "existing instances: ", $existing_copies, "\n", 98 "total instances: ", @$stat[7], "\n", 99 100 "instance location:\n", " " x 4, 101 join("\n" . " " x 4, @validation), "\n"; 102 } 103 else { 104 print 105 "object id: ", @$stat[0], "\n", 106 "key: ", @$stat[1], "\n", 107 "read lock: ", @$stat[2], "\n", 108 "write lock: ", @$stat[3], "\n", 109 "epoch: ", @$stat[4], "\n", 110 "mtime: ", @$stat[5], "\n", 111 "available instances: ", @$stat[6], "\n", 112 "requested instances: ", $user_copies, "\n", 113 "total instances: ", @$stat[7], "\n", 114 115 "instance location:\n", " " x 4, 116 join("\n" . " " x 4, @$instances), "\n"; 117 } 118 58 119 59 120 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
