Skip to content
Snippets Groups Projects
Commit 3fee32b1 authored by root's avatar root Committed by Sergey Joseph Ivanov
Browse files

Megaraid support to go to Core::SMART module

parent 6a9ea86e
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ For more information on smartctl, see http://smartmontools.sourceforge.net/ ...@@ -35,6 +35,8 @@ For more information on smartctl, see http://smartmontools.sourceforge.net/
This indicates the disk argument to be given to smartctl. Expects the basename This indicates the disk argument to be given to smartctl. Expects the basename
of the device, not the full path, e.g. "sda" not "/dev/sda". of the device, not the full path, e.g. "sda" not "/dev/sda".
Check names having "/" and a nubmer after it are considered to be physical parts of
megaraid arrays.
=item smartctl_cmd =item smartctl_cmd
...@@ -87,24 +89,49 @@ The raw value of the attribute, expected to be an integer. ...@@ -87,24 +89,49 @@ The raw value of the attribute, expected to be an integer.
sub handler { sub handler {
my $self = shift; my $self = shift;
my $config = $self->{config}; my $config = $self->{config};
my ($disk_name,$megaraid_number) = split('/',$self->{check_name}),
my $disk; my $disk;
$disk = "/dev/$self->{check_name}" if ($^O eq "linux") || ($^O =~ /bsd/) ; $disk = "/dev/$disk_name" if ($^O eq "linux") || ($^O =~ /bsd/) ;
$disk = "/dev/rdsk/$self->{check_name}" if $^O eq "solaris"; $disk = "/dev/rdsk/$disk_name" if $^O eq "solaris";
my $smartctl_cmd = $config->{smartctl_cmd} || "/usr/sbin/smartctl"; my $smartctl_cmd = $config->{smartctl_cmd} || "/usr/sbin/smartctl";
my $smartctl_args = "-i -A"; my $smartctl_args = "-i";
if (defined ($megaraid_number)) {
$smartctl_args .= " -a -H -d megaraid,$megaraid_number";
}
else {
$smartctl_args .= " -A";
}
$smartctl_args = "$smartctl_args $config->{smartctl_args}" if $config->{smartctl_args}; $smartctl_args = "$smartctl_args $config->{smartctl_args}" if $config->{smartctl_args};
my $smartdata = {}; my $smartdata = {};
my $output = run_command("$smartctl_cmd $smartctl_args $disk"); my $output = run_command("$smartctl_cmd $smartctl_args $disk");
foreach my $line (split(/\n/, $output)) { foreach my $line (split(/\n/, $output)) {
if ($line =~ /^Device Model:\s+(.+)$/) { if ( ($line =~ /^Device Model:\s+(.+)$/)
||($line =~ /^Product:\s+(.+)$/) )
{
$smartdata->{"model"} = [$1, "s"]; $smartdata->{"model"} = [$1, "s"];
} }
elsif ($line =~ /^Serial Number:\s+(.+)$/) { elsif ($line =~ /^Serial Number:\s+(.+)$/i) {
$smartdata->{"serial"} = [$1, "s"]; $smartdata->{"serial"} = [$1, "s"];
} }
elsif ($line =~ /^Firmware Version:\s+(.+)$/) { elsif ($line =~ /^SMART Health Status:\s+(.+)$/i) {
$smartdata->{"fw"} = [$1, "s"]; $smartdata->{"health"} = [$1, "s"];
}
elsif ( ($line =~ /^Firmware Version:\s+(.+)$/)
||($line =~ /^Revision:\s+(.+)$/) )
{
$smartdata->{"firmware_version"} = [$1, "s"];
}
elsif ($line =~ /^Elements in grown defect list:\s+(.+)$/) {
$smartdata->{"elements_in_defect_list"} = [$1, "i"];
}
elsif ($line =~ /^(read|write|verify):\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\d+)$/) {
print STDERR "$1 $1_errors_corrected $5 $1_errors_uncorrected $8\n";
$smartdata->{"$1_errors_corrected"} = [$5, "i"];
$smartdata->{"$1_errors_uncorrected"} = [$8, "i"];
}
elsif ($line =~ /^Non-medium error count:\s+(.+)$/) {
$smartdata->{"non_medium_errors"} = [$1, "i"];
} }
# Capture id, attribute_name, threshold, fail, raw_value (columns 1,2,6,7,8) # Capture id, attribute_name, threshold, fail, raw_value (columns 1,2,6,7,8)
=pod =pod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment