diff --git a/root/var/lib/zabbix/bin/mdstat-parser.pl b/root/var/lib/zabbix/bin/mdstat-parser.pl old mode 100644 new mode 100755 index 250ad02..fa11a20 --- a/root/var/lib/zabbix/bin/mdstat-parser.pl +++ b/root/var/lib/zabbix/bin/mdstat-parser.pl @@ -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 () { 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 () { } else { $active_devs{$dev} .= "$1,"; + $devs_up++; } } if (! defined($active_devs{$dev})) { $active_devs{$dev} = "none"; } @@ -88,25 +97,33 @@ while () { else { $failed_devs{$dev} =~ s/,$//; } $_ = ; - /(\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") { + $_ = ; + 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: "; @@ -125,6 +142,7 @@ Check status of Linux SW RAID Author: Michal Ludvig (c) 2006 http://www.logix.cz/michal/devel/nagios +Modified by Daniel B. : Usage: mdstat-parser.pl [options]