|
|
@ -6,6 +6,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
# Slightly modified by Daniel B. for integration on SME Server / Zabbix |
|
|
|
# Slightly modified by Daniel B. for integration on SME Server / Zabbix |
|
|
|
# 24 Apr 2009 |
|
|
|
# 24 Apr 2009 |
|
|
|
|
|
|
|
# - One line Repport |
|
|
|
|
|
|
|
# - Support RAID 0 Array |
|
|
|
|
|
|
|
# - Repport Warning if an array is rebuilding |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# |
|
|
|
# |
|
|
|
# Simple parser for /proc/mdstat that outputs status of all |
|
|
|
# Simple parser for /proc/mdstat that outputs status of all |
|
|
@ -67,9 +71,13 @@ while (<FILE>) { |
|
|
|
push @raids, $dev; |
|
|
|
push @raids, $dev; |
|
|
|
|
|
|
|
|
|
|
|
my @array = split(/ /); |
|
|
|
my @array = split(/ /); |
|
|
|
|
|
|
|
$devs_total{$dev} = 0; |
|
|
|
|
|
|
|
my $devs_up = 0; |
|
|
|
|
|
|
|
my $missing = 0; |
|
|
|
for $_ (@array) { |
|
|
|
for $_ (@array) { |
|
|
|
$level{$dev} = $1 if /^(raid\d+)$/; |
|
|
|
$level{$dev} = $1 if /^(raid\d+)$/; |
|
|
|
next if ! /(\w+)\[\d+\](\(.\))*/; |
|
|
|
next if ! /(\w+)\[\d+\](\(.\))*/; |
|
|
|
|
|
|
|
$devs_total{$dev}++; |
|
|
|
if ($2 eq "(F)") { |
|
|
|
if ($2 eq "(F)") { |
|
|
|
$failed_devs{$dev} .= "$1,"; |
|
|
|
$failed_devs{$dev} .= "$1,"; |
|
|
|
} |
|
|
|
} |
|
|
@ -78,6 +86,7 @@ while (<FILE>) { |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
$active_devs{$dev} .= "$1,"; |
|
|
|
$active_devs{$dev} .= "$1,"; |
|
|
|
|
|
|
|
$devs_up++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (! defined($active_devs{$dev})) { $active_devs{$dev} = "none"; } |
|
|
|
if (! defined($active_devs{$dev})) { $active_devs{$dev} = "none"; } |
|
|
@ -88,25 +97,33 @@ while (<FILE>) { |
|
|
|
else { $failed_devs{$dev} =~ s/,$//; } |
|
|
|
else { $failed_devs{$dev} =~ s/,$//; } |
|
|
|
|
|
|
|
|
|
|
|
$_ = <FILE>; |
|
|
|
$_ = <FILE>; |
|
|
|
/(\d+)\ blocks\ \[(\d+)\/(\d+)\]\s+\[(.*)\]$/; |
|
|
|
/(\d+)\ blocks\ (.*)(\[.*\])\s?$/; |
|
|
|
$size{$dev} = int($1/1024); |
|
|
|
$size{$dev} = int($1/1024); |
|
|
|
|
|
|
|
#print "$3\n"; |
|
|
|
|
|
|
|
$missing = 1 if ($3 =~ m/_/); |
|
|
|
if ($size{$dev} > 1024){ |
|
|
|
if ($size{$dev} > 1024){ |
|
|
|
$size{$dev} = int($size{$dev}/1024)."GB"; |
|
|
|
$size{$dev} = int($size{$dev}/1024)."GB"; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else{ |
|
|
|
$size{$dev} .= "MB"; |
|
|
|
$size{$dev} .= "MB"; |
|
|
|
} |
|
|
|
} |
|
|
|
$devs_total{$dev} = $2; |
|
|
|
$_ = <FILE>; |
|
|
|
my $devs_up = $3; |
|
|
|
if (($devs_total{$dev} > $devs_up) || ($failed_devs{$dev} ne "none") || (($missing) && (!/recovery/))) { |
|
|
|
my $stat = $4; |
|
|
|
|
|
|
|
if ($devs_total{$dev} > $devs_up or $failed_devs{$dev} ne "none") { |
|
|
|
|
|
|
|
$status{$dev} = "Degraded"; |
|
|
|
$status{$dev} = "Degraded"; |
|
|
|
$result = "CRITICAL"; |
|
|
|
$result = "CRITICAL"; |
|
|
|
$retval = $ERRORS{"CRITICAL"}; |
|
|
|
$retval = $ERRORS{"CRITICAL"}; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
else { |
|
|
|
$status{$dev} = "Optimal"; |
|
|
|
$status{$dev} = "Optimal"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (/recovery/){ |
|
|
|
|
|
|
|
$status{$dev} = "Rebuilding"; |
|
|
|
|
|
|
|
if ($result eq "OK"){ |
|
|
|
|
|
|
|
$result = "WARNING"; |
|
|
|
|
|
|
|
$retval = $ERRORS{"WARNING"}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
print "$result: "; |
|
|
|
print "$result: "; |
|
|
@ -125,6 +142,7 @@ Check status of Linux SW RAID |
|
|
|
|
|
|
|
|
|
|
|
Author: Michal Ludvig <michal\@logix.cz> (c) 2006 |
|
|
|
Author: Michal Ludvig <michal\@logix.cz> (c) 2006 |
|
|
|
http://www.logix.cz/michal/devel/nagios |
|
|
|
http://www.logix.cz/michal/devel/nagios |
|
|
|
|
|
|
|
Modified by Daniel B. <daniel\@firewall-services.com>: |
|
|
|
|
|
|
|
|
|
|
|
Usage: mdstat-parser.pl [options] |
|
|
|
Usage: mdstat-parser.pl [options] |
|
|
|
|
|
|
|
|
|
|
|