[pve-devel] [PATCH storage v2 1/4] catch '---' in threshold output of sandisk ssds

Dominik Csapak d.csapak at proxmox.com
Wed Nov 30 16:35:59 CET 2016


sandisk ssds have a default threshold of '---' on nearly all fields,
which prevents our parsing

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes since v1:
 * made the distinction and reason for the --- special case more clear
 PVE/Diskmanage.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index 938d6a4..3433874 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -97,14 +97,21 @@ sub get_smart_data {
 # Data Units Written:                 5,584,952 [2.85 TB]
 # Accumulated start-stop cycles:  34
 
-	    if (defined($type) && $type eq 'ata' && $line =~ m/^([ \d]{2}\d)\s+(\S+)\s+(\S{6})\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(.*)$/) {
+	    if (defined($type) && $type eq 'ata' && $line =~ m/^([ \d]{2}\d)\s+(\S+)\s+(\S{6})\s+(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.*)$/) {
 		my $entry = {};
+
+
 		$entry->{name} = $2 if defined $2;
 		$entry->{flags} = $3 if defined $3;
 		# the +0 makes a number out of the strings
 		$entry->{value} = $4+0 if defined $4;
 		$entry->{worst} = $5+0 if defined $5;
-		$entry->{threshold} = $6+0 if defined $6;
+		# some disks report the default threshold as --- instead of 000
+		if (defined($6) && $6 eq '---') {
+		    $entry->{threshold} = 0;
+		} else {
+		    $entry->{threshold} = $6+0 if defined $6;
+		}
 		$entry->{fail} = $7 if defined $7;
 		$entry->{raw} = $8 if defined $8;
 		$entry->{id} = $1 if defined $1;
-- 
2.1.4





More information about the pve-devel mailing list