From ce73713ef7cb65228555ac19fe0bfbd1453adc2b Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 14 Apr 2020 16:17:33 +0200 Subject: [PATCH] fix nvme wearout parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit the '.*' was greedy, also consuming all but one digits of the real percentage Signed-off-by: Dominik Csapak switch to \s* instead of .*?, to prevent mis-interpreting potential strings like '< 50%' or '0-50%' Signed-off-by: Fabian Grünbichler --- PVE/Diskmanage.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index abb90a7..13e7cd8 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -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/) { -- 2.39.2