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:
12
snmp/smart
12
snmp/smart
@@ -260,13 +260,11 @@ foreach my $line ( @disks ){
|
|||||||
$disk=$line;
|
$disk=$line;
|
||||||
$name=$line;
|
$name=$line;
|
||||||
}
|
}
|
||||||
my $disk_sn=$disk;
|
|
||||||
my $output;
|
my $output;
|
||||||
if ( $disk =~ /\// ){
|
if ( $disk !~ /\// ){
|
||||||
$output=`$smartctl -A $disk`;
|
$disk = '/dev/'.$disk;
|
||||||
}else{
|
|
||||||
$output=`$smartctl -A /dev/$disk`;
|
|
||||||
}
|
}
|
||||||
|
$output=`$smartctl -A $disk`;
|
||||||
my %IDs=( '5'=>'null',
|
my %IDs=( '5'=>'null',
|
||||||
'10'=>'null',
|
'10'=>'null',
|
||||||
'173'=>'null',
|
'173'=>'null',
|
||||||
@@ -387,7 +385,7 @@ foreach my $line ( @disks ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#get the selftest logs
|
#get the selftest logs
|
||||||
$output=`$smartctl -l selftest /dev/$disk`;
|
$output=`$smartctl -l selftest $disk`;
|
||||||
@outputA=split( /\n/, $output );
|
@outputA=split( /\n/, $output );
|
||||||
my $completed=scalar grep(/Completed without error/, @outputA);
|
my $completed=scalar grep(/Completed without error/, @outputA);
|
||||||
my $interrupted=scalar grep(/Interrupted/, @outputA);
|
my $interrupted=scalar grep(/Interrupted/, @outputA);
|
||||||
@@ -401,7 +399,7 @@ foreach my $line ( @disks ){
|
|||||||
# get the drive serial number, if needed
|
# get the drive serial number, if needed
|
||||||
my $disk_id=$name;
|
my $disk_id=$name;
|
||||||
if ( $useSN ){
|
if ( $useSN ){
|
||||||
while (`$smartctl -i /dev/$disk` =~ /Serial Number:(.*)/g) {
|
while (`$smartctl -i $disk` =~ /Serial Number:(.*)/g) {
|
||||||
$disk_id = $1;
|
$disk_id = $1;
|
||||||
$disk_id =~ s/^\s+|\s+$//g;
|
$disk_id =~ s/^\s+|\s+$//g;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user