3
# Copyright (c) 2002 ISOMEDIA, Inc.
4
# Written by Steve Milton
5
# Released under the GNU Public License
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.
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.
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
21
# Usage: check_raid <raid-name>
22
# Example: check_raid md0
23
# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min
27
my %ERRORS=('DEPENDENT'=>4,'UNKNOWN'=>3,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2);
29
open (MDSTAT, "</proc/mdstat") or die "Failed to open /proc/mdstat";
39
} elsif (/recovery = (.*?)\s/) {
41
($finish) = /finish=(.*?min)/;
57
$msg = sprintf "%s status=%s, recovery=%s, finish=%s\n",
58
$ARGV[0], $status, $recovery, $finish;
61
$msg = sprintf "%s status=%s\n", $ARGV[0], $status;
64
} elsif ($status =~ /U+/) {
65
$msg = sprintf "%s status=%s\n", $ARGV[0], $status;
69
$msg = sprintf "%s active with no status information.\n",
73
$msg = sprintf "%s does not exist.\n", $ARGV[0];
78
print $code, " ", $msg;
79
exit ($ERRORS{$code});