From 3ae29bb40ea5460968cc881234ce66d54f9b89af Mon Sep 17 00:00:00 2001 From: fbourqui Date: Wed, 22 Jan 2020 11:35:58 +0100 Subject: [PATCH] fix useSN, selftest with disk defined as argument was resulting in /dev/dev.... parameter to smartctl -l and -i --- snmp/smart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/snmp/smart b/snmp/smart index 75a02ff..3d8befd 100755 --- a/snmp/smart +++ b/snmp/smart @@ -260,13 +260,11 @@ foreach my $line ( @disks ){ $disk=$line; $name=$line; } - my $disk_sn=$disk; my $output; - if ( $disk =~ /\// ){ - $output=`$smartctl -A $disk`; - }else{ - $output=`$smartctl -A /dev/$disk`; + if ( $disk !~ /\// ){ + $disk = '/dev/'.$disk; } + $output=`$smartctl -A $disk`; my %IDs=( '5'=>'null', '10'=>'null', '173'=>'null', @@ -381,7 +379,7 @@ foreach my $line ( @disks ){ } #get the selftest logs - $output=`$smartctl -l selftest /dev/$disk`; + $output=`$smartctl -l selftest $disk`; @outputA=split( /\n/, $output ); my $completed=scalar grep(/Completed without error/, @outputA); my $interrupted=scalar grep(/Interrupted/, @outputA); @@ -395,7 +393,7 @@ foreach my $line ( @disks ){ # get the drive serial number, if needed my $disk_id=$name; if ( $useSN ){ - while (`$smartctl -i /dev/$disk` =~ /Serial Number:(.*)/g) { + while (`$smartctl -i $disk` =~ /Serial Number:(.*)/g) { $disk_id = $1; $disk_id =~ s/^\s+|\s+$//g; }