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