Skip to content

Commit

Permalink
Display sums of stored file lengths
Browse files Browse the repository at this point in the history
git-svn-id: http://code.sixapart.com/svn/mogilefs/trunk@1409 f67b2e87-0811-0410-a7e0-dd94e48410d6
  • Loading branch information
dormando committed Mar 24, 2010
1 parent e5d384b commit 6c612d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Updates to mogstats (dormando, Barry Abrahamson)

2.15 -- 2009-12-05

* Standalone mogstats utility (dormando)
Expand Down
19 changes: 12 additions & 7 deletions mogstats
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,21 @@ sub cmd_stats {

if ($args{files} || $args{all}) {
print "\nStatistics for files...\n";
printf " %-20s %-10s %10s\n", 'domain', 'class', 'files';
printf " -------------------- ----------- ----------\n";
printf " %-20s %-10s %10s %11s %13s\n", 'domain', 'class', 'files',
'size (m)', 'fullsize (m)';
printf " -------------------- ----------- ---------- ----------- -------------\n";
foreach my $domain (sort keys %{$stats->{files}}) {
my $classes = $stats->{files}->{$domain};
foreach my $class (sort keys %$classes) {
my $files = $classes->{$class};
printf " %-20s %-10s %10s\n", $domain, $class, $files;
my $stat = $classes->{$class};
my $files = $stat->[2];
my $size = int($stat->[3] / 1024 / 1024);
my $total = int($stat->[4] / 1024 / 1024);
printf " %-20s %-10s %10s %11s %13s\n", $domain, $class,
$files, $size, $total;
}
}
printf " -------------------- ----------- ----------\n";
printf " -------------------- ----------- ---------- ----------- -------------\n";
}

if ($args{replication} || $args{all}) {
Expand Down Expand Up @@ -285,12 +290,12 @@ sub stats_for_files {
my $dbh = get_dbh() or die "Could not get database handle";

verbose("... files stats...");
my $stats = $dbh->selectall_arrayref('SELECT dmid, classid, COUNT(classid) FROM file GROUP BY 1, 2');
my $stats = $dbh->selectall_arrayref('SELECT dmid, classid, COUNT(classid), sum(length), sum(length * devcount) FROM file GROUP BY 1, 2');
my $files = {};
for my $stat (@$stats) {
my $domain = $classes{$stat->[0]}->{name};
my $class = $classes{$stat->[0]}->{classes}->{$stat->[1]};
$files->{$domain}->{$class} = $stat->[2];
$files->{$domain}->{$class} = $stat;
}
verbose("... done");
return $files;
Expand Down

0 comments on commit 6c612d1

Please sign in to comment.