--- smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/90UserParameters_swRaid.mdstat_one_line 2009-04-24 15:45:42.000000000 +0200 +++ smeserver-zabbix-agent-0.1/root/etc/e-smith/templates/etc/zabbix/zabbix_agentd.conf/90UserParameters_swRaid 2009-04-24 18:53:03.000000000 +0200 @@ -8,11 +8,9 @@ # Show Value: As is # The value reported is like: -# OK - md3 [UU] has 2 of 2 devices active (active=sdc1,sdd1 failed=none spare=none) -# CRITICAL - md2 [_U] has 1 of 2 devices active (active=sdb2 failed=sda2 spare=none) -# OK - md1 [UU] has 2 of 2 devices active (active=sda1,sdb1 failed=none spare=none) +# OK: md3:raid1:2 drives:931GB:Optimal md2:raid1:2 drives:931GB:Optimal md1:raid1:2 drives:101MB:Optimal # Tips: You can add a simple trigger on this check like: -# \{ hostname:raid.sw.status.str( CRITICAL ) \}=1 +# \{ hostname:raid.sw.status.str( OK ) \}=0 UserParameter=raid.sw.status,/var/lib/zabbix/bin/mdstat-parser.pl --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mdstat-parser.pl.mdstat_one_line 2009-04-24 15:45:42.000000000 +0200 +++ smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mdstat-parser.pl 2009-04-24 18:48:28.000000000 +0200 @@ -3,6 +3,10 @@ # Get status of Linux software RAID for SNMP / Nagios # Author: Michal Ludvig # http://www.logix.cz/michal/devel/nagios + +# Slightly modified by Daniel B. for integration on SME Server / Zabbix +# 24 Apr 2009 + # # Simple parser for /proc/mdstat that outputs status of all # or some RAID devices. Possible results are OK and CRITICAL. @@ -51,16 +55,20 @@ ## This is a global return value - set to the worst result we get overall my $retval = 0; -my (%active_devs, %failed_devs, %spare_devs); +my (%active_devs, %failed_devs, %spare_devs, %devs_total, %level, %size, %status); +my @raids; +my $result = 'OK'; open FILE, "< $file" or die "Can't open $file : $!"; while () { next if ! /^(md\d+)+\s*:/; next if $device ne "all" and $device ne $1; my $dev = $1; + push @raids, $dev; my @array = split(/ /); for $_ (@array) { + $level{$dev} = $1 if /^(raid\d+)$/; next if ! /(\w+)\[\d+\](\(.\))*/; if ($2 eq "(F)") { $failed_devs{$dev} .= "$1,"; @@ -80,18 +88,32 @@ else { $failed_devs{$dev} =~ s/,$//; } $_ = ; - /\[(\d+)\/(\d+)\]\s+\[(.*)\]$/; - my $devs_total = $1; - my $devs_up = $2; - my $stat = $3; - my $result = "OK"; - if ($devs_total > $devs_up or $failed_devs{$dev} ne "none") { + /(\d+)\ blocks\ \[(\d+)\/(\d+)\]\s+\[(.*)\]$/; + $size{$dev} = int($1/1024); + 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") { + $status{$dev} = "Degraded"; $result = "CRITICAL"; $retval = $ERRORS{"CRITICAL"}; } + else{ + $status{$dev} = "Optimal"; + } - print "$result - $dev [$stat] has $devs_up of $devs_total devices active (active=$active_devs{$dev} failed=$failed_devs{$dev} spare=$spare_devs{$dev})\n"; } +print "$result: "; +foreach my $raid (@raids){ + print "$raid:$level{$raid}:$devs_total{$raid} drives:$size{$raid}:$status{$raid} "; +} +print "\n"; close FILE; exit $retval;