1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00

Merge pull request #271 from fbourqui/fix-useSN

Smart: fix useSN, selftest when disk is defined as a full argument to smartctl (arg after space)
This commit is contained in:
Zane C. Bowers-Hadley
2020-02-03 01:09:18 -06:00
committed by GitHub

View File

@ -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',
@ -387,7 +385,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);
@ -401,7 +399,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;
}