diff options
Diffstat (limited to 'web/attachments/263186-check_linux_raid.pl.diff')
-rw-r--r-- | web/attachments/263186-check_linux_raid.pl.diff | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/web/attachments/263186-check_linux_raid.pl.diff b/web/attachments/263186-check_linux_raid.pl.diff new file mode 100644 index 0000000..0e7861c --- /dev/null +++ b/web/attachments/263186-check_linux_raid.pl.diff | |||
@@ -0,0 +1,77 @@ | |||
1 | --- contrib/check_linux_raid.pl 2007-08-28 04:19:45.000000000 +0100 | ||
2 | +++ contrib/check_linux_raid.pl.new 2008-01-21 17:28:18.000000000 +0000 | ||
3 | @@ -3,6 +3,7 @@ | ||
4 | # Copyright (c) 2002 ISOMEDIA, Inc. | ||
5 | # originally written by Steve Milton | ||
6 | # later updates by sean finney <seanius@seanius.net> | ||
7 | +# bux fixing & usage message by Alain Williams <addw@phcomp.co.uk> | ||
8 | # | ||
9 | # This program is free software; you can redistribute it and/or modify | ||
10 | # it under the terms of the GNU General Public License as published by | ||
11 | @@ -26,6 +27,8 @@ | ||
12 | use lib "/usr/local/nagios/libexec"; | ||
13 | use utils qw(%ERRORS); | ||
14 | |||
15 | +my ($progname) = $0 =~ m|([^/]+)$|; | ||
16 | + | ||
17 | # die with an error if we're not on Linux | ||
18 | if ($^O ne 'linux') { | ||
19 | print "This plugin only applicable on Linux.\n"; | ||
20 | @@ -42,9 +45,22 @@ | ||
21 | return "UNKNOWN"; | ||
22 | } | ||
23 | |||
24 | +sub usage { | ||
25 | + print "Inspect Linux software raid devices and return a status for nagios\n"; | ||
26 | + print "Usage:\n"; | ||
27 | + print "$progname [--help | -h] [md-device ...]\n"; | ||
28 | + print "A md-device might be: md0\n"; | ||
29 | + print "If md-device is not given, all mds will be inspected\n"; | ||
30 | + exit 0; | ||
31 | +} | ||
32 | + | ||
33 | my $nextdev; | ||
34 | -if(defined $ARGV[0]) { $nextdev = shift; } | ||
35 | -else { $nextdev = "md[0-9]"; } | ||
36 | +if(defined $ARGV[0]) { | ||
37 | + $nextdev = shift; | ||
38 | + usage() if($nextdev eq '--help' or $nextdev eq '-h'); | ||
39 | +} else { | ||
40 | + $nextdev = "md[0-9]+"; # All MD devices | ||
41 | +} | ||
42 | |||
43 | my $code = "UNKNOWN"; | ||
44 | my $msg = ""; | ||
45 | @@ -53,6 +69,7 @@ | ||
46 | my %finish; | ||
47 | my %active; | ||
48 | my %devices; | ||
49 | +my $debug; | ||
50 | |||
51 | while(defined $nextdev){ | ||
52 | open (MDSTAT, "< /proc/mdstat") or die "Failed to open /proc/mdstat"; | ||
53 | @@ -60,14 +77,22 @@ | ||
54 | while(<MDSTAT>) { | ||
55 | if (defined $device) { | ||
56 | if (/(\[[_U]+\])/) { | ||
57 | + print "status='$1' device '$device'\n" if($debug); | ||
58 | $status{$device} = $1; | ||
59 | } elsif (/recovery = (.*?)\s/) { | ||
60 | $recovery{$device} = $1; | ||
61 | ($finish{$device}) = /finish=(.*?min)/; | ||
62 | - } elsif (/^\s*$/) { | ||
63 | + } elsif (/^\s*$/) { # Start of another device - blank line. NB: may not be present | ||
64 | + print "undef '$device' _='$_'\n" if($debug); | ||
65 | $device=undef; | ||
66 | + } elsif(/^md[0-9]+\s*:/) { # Start of another device - another way | ||
67 | + print "undef '$device' _='$_'\n" if($debug); | ||
68 | + undef $device; | ||
69 | } | ||
70 | - } elsif (/^($nextdev)\s*:/) { | ||
71 | + } | ||
72 | + | ||
73 | + # No current device and this line matches the device pattern ? | ||
74 | + if ( ! defined($device) and /^($nextdev)\s*:/) { | ||
75 | $device=$1; | ||
76 | $devices{$device}=$device; | ||
77 | if (/active/) { | ||