more robust zpool list parsing
This commit is contained in:
parent
c0f1131fa6
commit
9c3bf32fa5
|
@ -1,3 +1,5 @@
|
||||||
|
1.4.1 updated check_zpool() in sanoid to parse zpool list properly both pre- and post- ZoL v0.6.4
|
||||||
|
|
||||||
1.4.0 added findoid tool - find and list all versions of a given file in all available ZFS snapshots. use: findoid /path/to/file
|
1.4.0 added findoid tool - find and list all versions of a given file in all available ZFS snapshots. use: findoid /path/to/file
|
||||||
|
|
||||||
1.3.1 whoops - prevent process_children_only from getting set from blank value in defaults
|
1.3.1 whoops - prevent process_children_only from getting set from blank value in defaults
|
||||||
|
|
2
findoid
2
findoid
|
@ -11,7 +11,7 @@ use warnings;
|
||||||
my $zfs = '/sbin/zfs';
|
my $zfs = '/sbin/zfs';
|
||||||
my %args = getargs(@ARGV);
|
my %args = getargs(@ARGV);
|
||||||
|
|
||||||
my $progversion = '1.4.0';
|
my $progversion = '1.4.1';
|
||||||
|
|
||||||
if ($args{'version'}) { print "$progversion\n"; exit 0; }
|
if ($args{'version'}) { print "$progversion\n"; exit 0; }
|
||||||
|
|
||||||
|
|
19
sanoid
19
sanoid
|
@ -4,7 +4,7 @@
|
||||||
# from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this
|
# from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this
|
||||||
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
|
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
|
||||||
|
|
||||||
my $version = '1.4.0';
|
my $version = '1.4.1';
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Config::IniFiles; # read samba-style conf file
|
use Config::IniFiles; # read samba-style conf file
|
||||||
|
@ -741,23 +741,28 @@ sub check_zpool() {
|
||||||
exit $ERRORS{$state};
|
exit $ERRORS{$state};
|
||||||
}
|
}
|
||||||
|
|
||||||
my $statcommand="/sbin/zpool list $pool";
|
my $statcommand="/sbin/zpool list -o name,size,cap,health,free $pool";
|
||||||
|
|
||||||
if (! open STAT, "$statcommand|") {
|
if (! open STAT, "$statcommand|") {
|
||||||
print ("$state '$statcommand' command returns no result! NOTE: This plugin needs OS support for ZFS, and execution with root privileges.\n");
|
print ("$state '$statcommand' command returns no result! NOTE: This plugin needs OS support for ZFS, and execution with root privileges.\n");
|
||||||
exit $ERRORS{$state};
|
exit $ERRORS{$state};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# chuck the header line
|
||||||
|
my $header = <STAT>;
|
||||||
|
|
||||||
|
# find and parse the line with values for the pool
|
||||||
while(<STAT>) {
|
while(<STAT>) {
|
||||||
chomp;
|
chomp;
|
||||||
next if (/^NAME\s+SIZE\s+USED\s+AVAIL\s+CAP\s+HEALTH\s+ALTROOT/);
|
|
||||||
if (/^${pool}\s+/) {
|
if (/^${pool}\s+/) {
|
||||||
($size, $used, $avail, $cap, $dedup, $health) = /^${pool}\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/;
|
my @row = split (/ +/);
|
||||||
|
my $name;
|
||||||
|
($name, $size, $cap, $health, $avail) = @row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tony: Debuging
|
# Tony: Debuging
|
||||||
#print "Size: $size \t Used: $used \t Avai: $avail \t Cap: $cap \t Health: $health\n";
|
# print "Size: $size \t Used: $used \t Avai: $avail \t Cap: $cap \t Health: $health\n";
|
||||||
|
|
||||||
close(STAT);
|
close(STAT);
|
||||||
|
|
||||||
|
@ -869,7 +874,7 @@ sub check_zpool() {
|
||||||
|
|
||||||
## calling all goats!
|
## calling all goats!
|
||||||
|
|
||||||
$msg = sprintf "ZPOOL %s : %s {Size:%s Used:%s Avail:%s Cap:%s} %s\n", $pool, $health, $size, $used, $avail, $cap, $dmge;
|
$msg = sprintf "ZPOOL %s : %s {Size:%s Free:%s Cap:%s} %s\n", $pool, $health, $size, $avail, $cap, $dmge;
|
||||||
$msg = "$state $msg";
|
$msg = "$state $msg";
|
||||||
return ($ERRORS{$state},$msg);
|
return ($ERRORS{$state},$msg);
|
||||||
} # end check_zpool()
|
} # end check_zpool()
|
||||||
|
|
2
syncoid
2
syncoid
|
@ -4,7 +4,7 @@
|
||||||
# from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this
|
# from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this
|
||||||
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
|
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
|
||||||
|
|
||||||
my $version = '1.4.0';
|
my $version = '1.4.1';
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
Loading…
Reference in New Issue