Skip to content

Commit

Permalink
mogadm: improve "device list" formatting
Browse files Browse the repository at this point in the history
With multi-terabyte disks being commong nowadays, the formatting of
"mogadm device list" output has become cramped and hard-to-read.
Additionally, right justifying numeric values makes identifying
order-of-magnitude differences between rows easier:

before:
                   used(G) free(G) total(G) weight(%)
 dev11: alive      1267.246 1483.296 2750.542  100
  dev2: alive      1196.321 637.334 1833.655  100
  dev5: alive      1220.643 154.568 1375.211  100
  dev6: alive      2072.875 677.667 2750.542  100
  dev7: alive      995.188 380.022 1375.211  100

after:

                    used(G)    free(G)   total(G)  weight(%)
  dev11:   alive   1267.246   1483.296   2750.542        100
   dev2:   alive   1196.321    637.334   1833.655        100
   dev5:   alive   1220.643    154.568   1375.211        100
   dev6:   alive   2072.875    677.667   2750.542        100
   dev7:   alive    995.188    380.022   1375.211        100
  • Loading branch information
Eric Wong authored and dormando committed Aug 8, 2013
1 parent 7136abc commit fc8994f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mogadm
Original file line number Diff line number Diff line change
Expand Up @@ -824,15 +824,15 @@ sub cmd_device_list {
}
print "$host->{hostname} [$hostid]: $host->{status}\n";

printf "%6s %-10s %7s %7s %7s %7s\n", '', '', 'used(G)', 'free(G)', 'total(G)', 'weight(%)';
printf "%7s %-7s %10s %10s %10s %10s\n", '', '', 'used(G)', 'free(G)', 'total(G)', 'weight(%)';
foreach my $devid (sort keys %{$devs->{$hostid} || {}}) {
my $dev = $devs->{$hostid}->{$devid};
next if $dev->{status} eq "dead" && ! $args->{all};

my $total = $dev->{mb_total} / 1024;
my $used = $dev->{mb_used} / 1024;
my $free = $total - $used;
printf "%6s: %-10s %-7.3f %-7.3f %-7.3f % 3u\n", "dev$devid", $dev->{status}, $used, $free, $total, $dev->{weight};
printf "%7s: %7s %10.3f %10.3f %10.3f %10u\n", "dev$devid", $dev->{status}, $used, $free, $total, $dev->{weight};
}

print "\n";
Expand Down

0 comments on commit fc8994f

Please sign in to comment.