[pve-devel] applied: [PATCH storage 2/2] fix nvme wearout parsing

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Apr 15 13:00:02 CEST 2020


with switch to \s* instead of .*?, as discussed.

On April 14, 2020 4:17 pm, Dominik Csapak wrote:
> the '.*' was greedy, also consuming all but one digits of the real percentage
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/Diskmanage.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
> index abb90a7..e9036fe 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:.*?(\d+(?:\.\d+)?)\%/i) {
>  		    $smartdata->{wearout} = 100 - $1;
>  		}
>  	    } elsif ($line =~ m/SMART Disabled/) {
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




More information about the pve-devel mailing list