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:
Dominik Csapak
2020-04-14 16:17:33 +02:00
committed by Fabian Grünbichler
parent 413862d2cb
commit ce73713ef7

View File

@ -134,7 +134,7 @@ sub get_smart_data {
$smartdata->{text} = '' if !defined $smartdata->{text};
$smartdata->{text} .= "$line\n";
# 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;
}
} elsif ($line =~ m/SMART Disabled/) {