/[smecontribs]/rpms/smeserver-zabbix-agent/contribs7/smeserver-zabbix-agent-0.1-mdstat_one_line.patch
ViewVC logotype

Contents of /rpms/smeserver-zabbix-agent/contribs7/smeserver-zabbix-agent-0.1-mdstat_one_line.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Apr 24 12:58:39 2009 UTC (15 years, 7 months ago) by vip-ire
Branch: MAIN
CVS Tags: smeserver-zabbix-agent-0_1-34_el4_sme, smeserver-zabbix-agent-0_1-35_el4_sme, smeserver-zabbix-agent-0_1-46_el4_sme, smeserver-zabbix-agent-0_1-42_el4_sme, smeserver-zabbix-agent-0_1-41_el4_sme, smeserver-zabbix-agent-0_1-49_el4_sme, smeserver-zabbix-agent-0_1-38_el4_sme, smeserver-zabbix-agent-0_1-47_el4_sme, smeserver-zabbix-agent-0_1-30_el4_sme, smeserver-zabbix-agent-0_1-50_el4_sme, smeserver-zabbix-agent-0_1-32_el4_sme, smeserver-zabbix-agent-0_1-39_el4_sme, smeserver-zabbix-agent-0_1-45_el4_sme, smeserver-zabbix-agent-0_1-51_el4_sme, smeserver-zabbix-agent-0_1-29_el4_sme, smeserver-zabbix-agent-0_1-44_el4_sme, smeserver-zabbix-agent-0_1-52_el4_sme, smeserver-zabbix-agent-0_1-28_el4_sme, smeserver-zabbix-agent-0_1-48_el4_sme, smeserver-zabbix-agent-0_1-36_el4_sme, smeserver-zabbix-agent-0_1-37_el4_sme, smeserver-zabbix-agent-0_1-33_el4_sme, smeserver-zabbix-agent-0_1-43_el4_sme, smeserver-zabbix-agent-0_1-31_el4_sme, smeserver-zabbix-agent-0_1-40_el4_sme, HEAD
see changelog

1 --- 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
2 +++ 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
3 @@ -8,11 +8,9 @@
4 # Show Value: As is
5
6 # The value reported is like:
7 -# OK - md3 [UU] has 2 of 2 devices active (active=sdc1,sdd1 failed=none spare=none)
8 -# CRITICAL - md2 [_U] has 1 of 2 devices active (active=sdb2 failed=sda2 spare=none)
9 -# OK - md1 [UU] has 2 of 2 devices active (active=sda1,sdb1 failed=none spare=none)
10 +# OK: md3:raid1:2 drives:931GB:Optimal md2:raid1:2 drives:931GB:Optimal md1:raid1:2 drives:101MB:Optimal
11
12 # Tips: You can add a simple trigger on this check like:
13 -# \{ hostname:raid.sw.status.str( CRITICAL ) \}=1
14 +# \{ hostname:raid.sw.status.str( OK ) \}=0
15 UserParameter=raid.sw.status,/var/lib/zabbix/bin/mdstat-parser.pl
16
17 --- smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mdstat-parser.pl.mdstat_one_line 2009-04-24 15:45:42.000000000 +0200
18 +++ smeserver-zabbix-agent-0.1/root/var/lib/zabbix/bin/mdstat-parser.pl 2009-04-24 18:48:28.000000000 +0200
19 @@ -3,6 +3,10 @@
20 # Get status of Linux software RAID for SNMP / Nagios
21 # Author: Michal Ludvig <michal@logix.cz>
22 # http://www.logix.cz/michal/devel/nagios
23 +
24 +# Slightly modified by Daniel B. for integration on SME Server / Zabbix
25 +# 24 Apr 2009
26 +
27 #
28 # Simple parser for /proc/mdstat that outputs status of all
29 # or some RAID devices. Possible results are OK and CRITICAL.
30 @@ -51,16 +55,20 @@
31 ## This is a global return value - set to the worst result we get overall
32 my $retval = 0;
33
34 -my (%active_devs, %failed_devs, %spare_devs);
35 +my (%active_devs, %failed_devs, %spare_devs, %devs_total, %level, %size, %status);
36 +my @raids;
37 +my $result = 'OK';
38
39 open FILE, "< $file" or die "Can't open $file : $!";
40 while (<FILE>) {
41 next if ! /^(md\d+)+\s*:/;
42 next if $device ne "all" and $device ne $1;
43 my $dev = $1;
44 + push @raids, $dev;
45
46 my @array = split(/ /);
47 for $_ (@array) {
48 + $level{$dev} = $1 if /^(raid\d+)$/;
49 next if ! /(\w+)\[\d+\](\(.\))*/;
50 if ($2 eq "(F)") {
51 $failed_devs{$dev} .= "$1,";
52 @@ -80,18 +88,32 @@
53 else { $failed_devs{$dev} =~ s/,$//; }
54
55 $_ = <FILE>;
56 - /\[(\d+)\/(\d+)\]\s+\[(.*)\]$/;
57 - my $devs_total = $1;
58 - my $devs_up = $2;
59 - my $stat = $3;
60 - my $result = "OK";
61 - if ($devs_total > $devs_up or $failed_devs{$dev} ne "none") {
62 + /(\d+)\ blocks\ \[(\d+)\/(\d+)\]\s+\[(.*)\]$/;
63 + $size{$dev} = int($1/1024);
64 + if ($size{$dev} > 1024){
65 + $size{$dev} = int($size{$dev}/1024)."GB";
66 + }
67 + else{
68 + $size{$dev} .= "MB";
69 + }
70 + $devs_total{$dev} = $2;
71 + my $devs_up = $3;
72 + my $stat = $4;
73 + if ($devs_total{$dev} > $devs_up or $failed_devs{$dev} ne "none") {
74 + $status{$dev} = "Degraded";
75 $result = "CRITICAL";
76 $retval = $ERRORS{"CRITICAL"};
77 }
78 + else{
79 + $status{$dev} = "Optimal";
80 + }
81
82 - 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";
83 }
84 +print "$result: ";
85 +foreach my $raid (@raids){
86 + print "$raid:$level{$raid}:$devs_total{$raid} drives:$size{$raid}:$status{$raid} ";
87 +}
88 +print "\n";
89 close FILE;
90 exit $retval;
91

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed