summaryrefslogtreecommitdiffstats
path: root/contrib/check_linux_raid.pl
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-08-14 19:01:58 (GMT)
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-08-14 19:01:58 (GMT)
commit005a4281f4272114a7c2c56bc48d9640b3a47531 (patch)
treee376a2f622822fc46353536a9aeac763cb74520d /contrib/check_linux_raid.pl
parent9e3002c652b8e2e59f99e115e458c3f3bc738d59 (diff)
downloadmonitoring-plugins-005a4281f4272114a7c2c56bc48d9640b3a47531.tar.gz
new plugins
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@73 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_linux_raid.pl')
-rw-r--r--contrib/check_linux_raid.pl80
1 files changed, 80 insertions, 0 deletions
diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl
new file mode 100644
index 0000000..44f166b
--- /dev/null
+++ b/contrib/check_linux_raid.pl
@@ -0,0 +1,80 @@
1#!/usr/bin/perl -w
2
3# Copyright (c) 2002 ISOMEDIA, Inc.
4# Written by Steve Milton
5# Released under the GNU Public License
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20#
21# Usage: check_raid <raid-name>
22# Example: check_raid md0
23# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min
24
25use strict;
26
27my %ERRORS=('DEPENDENT'=>4,'UNKNOWN'=>3,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2);
28
29open (MDSTAT, "</proc/mdstat") or die "Failed to open /proc/mdstat";
30my $found = 0;
31my $status = "";
32my $recovery = "";
33my $finish = "";
34my $active = "";
35while(<MDSTAT>) {
36 if ($found) {
37 if (/(\[[_U]+\])/) {
38 $status = $1;
39 } elsif (/recovery = (.*?)\s/) {
40 $recovery = $1;
41 ($finish) = /finish=(.*?min)/;
42 }
43 } else {
44 if (/$ARGV[0]/) {
45 $found = 1;
46 if (/active/) {
47 $active = 1;
48 }
49 }
50 }
51}
52
53my $msg = "FAILURE";
54my $code = "UNKNOWN";
55if ($status =~ /_/) {
56 if ($recovery) {
57 $msg = sprintf "%s status=%s, recovery=%s, finish=%s\n",
58 $ARGV[0], $status, $recovery, $finish;
59 $code = "WARNING";
60 } else {
61 $msg = sprintf "%s status=%s\n", $ARGV[0], $status;
62 $code = "CRITICAL";
63 }
64} elsif ($status =~ /U+/) {
65 $msg = sprintf "%s status=%s\n", $ARGV[0], $status;
66 $code = "OK";
67} else {
68 if ($active) {
69 $msg = sprintf "%s active with no status information.\n",
70 $ARGV[0];
71 $code = "OK";
72 } else {
73 $msg = sprintf "%s does not exist.\n", $ARGV[0];
74 $code = "CRITICAL";
75 }
76}
77
78print $code, " ", $msg;
79exit ($ERRORS{$code});
80