my $ZFS = '/sbin/zfs';
sub get_pool_data {
- if (!-f $ZPOOL) {
- die "zfsutils-linux not installed\n";
- }
+ die "zfsutils-linux not installed\n" if ! -f $ZPOOL;
my $propnames = [qw(name size alloc free frag dedup health)];
my $numbers = {
dedup => 1,
};
- my $cmd = [$ZPOOL,'list', '-HpPLo', join(',', @$propnames)];
-
my $pools = [];
-
- run_command($cmd, outfunc => sub {
+ run_command([$ZPOOL, 'list', '-HpPLo', join(',', @$propnames)], outfunc => sub {
my ($line) = @_;
- my @props = split('\s+', trim($line));
- my $pool = {};
- for (my $i = 0; $i < scalar(@$propnames); $i++) {
- if ($numbers->{$propnames->[$i]}) {
- $pool->{$propnames->[$i]} = $props[$i] + 0;
- } else {
- $pool->{$propnames->[$i]} = $props[$i];
- }
+ my @props = split('\s+', trim($line));
+ my $pool = {};
+ for (my $i = 0; $i < scalar(@$propnames); $i++) {
+ if ($numbers->{$propnames->[$i]}) {
+ $pool->{$propnames->[$i]} = $props[$i] + 0;
+ } else {
+ $pool->{$propnames->[$i]} = $props[$i];
}
+ }
- push @$pools, $pool;
+ push @$pools, $pool;
});
return $pools;