fix nvme wearout parsing
the '.*' was greedy, also consuming all but one digits of the real percentage Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> switch to \s* instead of .*?, to prevent mis-interpreting potential strings like '< 50%' or '0-50%' Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
413862d2cb
commit
ce73713ef7
@ -134,7 +134,7 @@ sub get_smart_data {
|
|||||||
$smartdata->{text} = '' if !defined $smartdata->{text};
|
$smartdata->{text} = '' if !defined $smartdata->{text};
|
||||||
$smartdata->{text} .= "$line\n";
|
$smartdata->{text} .= "$line\n";
|
||||||
# extract wearout from nvme text, allow for decimal values
|
# extract wearout from nvme text, allow for decimal values
|
||||||
if ($line =~ m/Percentage Used:.*(\d+(?:\.\d+)?)\%/i) {
|
if ($line =~ m/Percentage Used:\s*(\d+(?:\.\d+)?)\%/i) {
|
||||||
$smartdata->{wearout} = 100 - $1;
|
$smartdata->{wearout} = 100 - $1;
|
||||||
}
|
}
|
||||||
} elsif ($line =~ m/SMART Disabled/) {
|
} elsif ($line =~ m/SMART Disabled/) {
|
||||||
|
|||||||
Reference in New Issue
Block a user