File: softraid.monitor

package info (click to toggle)
mon-contrib 1.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 892 kB
  • sloc: perl: 5,510; sh: 383; python: 118; makefile: 72
file content (47 lines) | stat: -rwxr-xr-x 1,393 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# softraid.monitor
# Linux Software RAID check with mon compatible output/return values
# Call without arguments.
# The reference file $md_ref must exist. To generate it:
#   softraid.monitor learn
#   [ cat /proc/mdstat > /path/to/dir/mdstat.reference ]
# no administrative permissions needed for this script.
# Return values: 3 /proc/mdstat missing, no Software RAID?
#                2 reference file missing
#                1 RAID not okay
#                0 alles okay
#
# Date: Thu, 07 Apr 2005 17:28:02 +0200
# From: Kevin Ivory <Ivory@SerNet.de>
# To: mon@linux.kernel.org
# Subject: Re: Monitoring software raid?
#

mdstat="/proc/mdstat"
# THIS NEEDS TO BE SOMEWHERE THE CHECKING USER CAN WRITE
md_ref="/var/something/mdstat.reference"
if [ ! -r "$mdstat" ]; then
  echo -e "$HOSTNAME:$0
        Missing RAID status file: $mdstat
        Perhaps no software RAID?"
  exit 3
fi
if [ "$1" = "learn" ]; then
  cat "$mdstat" > "$md_ref"
fi
if [ ! -r "$md_ref" ]; then
  echo -e "$HOSTNAME:$0
        Missing RAID reference file: $md_ref
        Generate with: $0 learn > $md_ref"
  exit 2
fi
md_out="Complete contents of $mdstat:\n\n$(cat $mdstat)"
diff=$(diff -u -U 0 $md_ref $mdstat)
stat=$?
if [ $stat -eq 0 ]; then
  echo -e "$HOSTNAME\nSoftware RAID ok:\n$md_out"
else
  echo -e "$HOSTNAME\nSoftware RAID not ok:\n$diff\n\n$md_out"
  exit 1
fi
# end of softraid.monitor