]> git.proxmox.com Git - pve-storage.git/commitdiff
fix nvme wearout parsing
authorDominik Csapak <d.csapak@proxmox.com>
Tue, 14 Apr 2020 14:17:33 +0000 (16:17 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 15 Apr 2020 10:54:10 +0000 (12:54 +0200)
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>
PVE/Diskmanage.pm

index abb90a79d93038cf470fe45ba1c7168c8d0f40a5..13e7cd89b346487f1e44ea85ce9b6801fff1a957 100644 (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/) {