Without '-p', 'zpool status' shortens the READ, WRITE and CKSUM counters of a vdev to a value with a unit suffix once they reach 1024, for example 1130 read errors are shown as '1.10K'. The parser just adds zero to those values, so the API returned 1.1 read errors in that case and logged a warning like: Argument "1.10K" isn't numeric in addition (+) Request exact values with '-p'. For the non-JSON output of 'zpool status' it only affects those counters, the sizes in the scan line stay human readable. Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
1 parent
e47d23f3c7
commit
6320a3a111
2 files changed
+79
-2
No files matched your search
@@ -217,7 +217,7 @@ __PACKAGE__->register_method({
|
||||
die "zfsutils-linux not installed\n";
|
||||
}
|
||||
|
||||
my $cmd = [$ZPOOL, 'status', '-P', $param->{name}];
|
||||
my $cmd = [$ZPOOL, 'status', '-P', '-p', $param->{name}];
|
||||
|
||||
my $pool = {
|
||||
lvl => 0,
|
||||
|
||||
@@ -18,7 +18,7 @@ $zfs_api_module->mock(
|
||||
|
||||
my $cmdline = join(' ', @$cmd);
|
||||
die "unexpected run_command call: '$cmdline'\n"
|
||||
if $cmdline ne '/sbin/zpool status -P tank';
|
||||
if $cmdline ne '/sbin/zpool status -P -p tank';
|
||||
|
||||
$param{outfunc}->($_) for split(/\n/, $zpool_status_output);
|
||||
|
||||
@@ -148,6 +148,83 @@ EOF
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
description => 'error counters above 1023',
|
||||
status => <<"EOF",
|
||||
pool: tank
|
||||
state: ONLINE
|
||||
status: One or more devices has experienced an unrecoverable error. An
|
||||
\tattempt was made to correct the error. Applications are unaffected.
|
||||
action: Determine if the device needs to be replaced, and clear the errors
|
||||
\tusing 'zpool clear' or replace the device with 'zpool replace'.
|
||||
see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P
|
||||
scan: scrub repaired 1.38M in 00:41:15 with 0 errors on Sun Sep 13 01:05:15 2026
|
||||
config:
|
||||
|
||||
\tNAME STATE READ WRITE CKSUM
|
||||
\ttank ONLINE 0 0 0
|
||||
\t mirror-0 ONLINE 0 0 0
|
||||
\t /dev/disk/by-id/ata-DISK_A-part1 ONLINE 1130 0 0
|
||||
\t /dev/disk/by-id/ata-DISK_B-part1 ONLINE 0 0 15565
|
||||
|
||||
errors: No known data errors
|
||||
EOF
|
||||
expected => {
|
||||
name => 'tank',
|
||||
state => 'ONLINE',
|
||||
status => 'One or more devices has experienced an unrecoverable error. An'
|
||||
. ' attempt was made to correct the error. Applications are unaffected.',
|
||||
action => 'Determine if the device needs to be replaced, and clear the errors'
|
||||
. " using 'zpool clear' or replace the device with 'zpool replace'.",
|
||||
see => 'https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P',
|
||||
scan =>
|
||||
'scrub repaired 1.38M in 00:41:15 with 0 errors on Sun Sep 13 01:05:15 2026',
|
||||
errors => 'No known data errors',
|
||||
leaf => 0,
|
||||
children => [
|
||||
{
|
||||
name => 'tank',
|
||||
state => 'ONLINE',
|
||||
read => 0,
|
||||
write => 0,
|
||||
cksum => 0,
|
||||
msg => '',
|
||||
leaf => 0,
|
||||
children => [
|
||||
{
|
||||
name => 'mirror-0',
|
||||
state => 'ONLINE',
|
||||
read => 0,
|
||||
write => 0,
|
||||
cksum => 0,
|
||||
msg => '',
|
||||
leaf => 0,
|
||||
children => [
|
||||
{
|
||||
name => '/dev/disk/by-id/ata-DISK_A-part1',
|
||||
state => 'ONLINE',
|
||||
read => 1130,
|
||||
write => 0,
|
||||
cksum => 0,
|
||||
msg => '',
|
||||
leaf => 1,
|
||||
},
|
||||
{
|
||||
name => '/dev/disk/by-id/ata-DISK_B-part1',
|
||||
state => 'ONLINE',
|
||||
read => 0,
|
||||
write => 0,
|
||||
cksum => 15565,
|
||||
msg => '',
|
||||
leaf => 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
plan tests => scalar @$tests;
|
||||
|
||||
Reference in new issue
Block a user