-
Notifications
You must be signed in to change notification settings - Fork 9
/
megarpt
executable file
·66 lines (54 loc) · 1.22 KB
/
megarpt
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#
# megarpt
#
# Emails a message to root with megaraid configuration and any
# output from a health check. Useful as a nightly cron job.
#
# Author: Jefferson Ogata (JO317) <[email protected]>
# Date: 2007/08/20
VERSION='0.3'
MEGACTL=/root/megactl
DEVICE=/dev/megadev0
DEVICENAME=megadev
DEVICEPERM=644
ME=`basename $0`
if [ -x $MEGACTL ]; then
MEGACTLVERSION=`$MEGACTL -V`
else
echo "No megactl program in $MEGACTL" >&2
exit 1
fi
MAJOR=`grep "$DEVICENAME" /proc/devices | awk '{print $1}'`
if [ -n "$MAJOR" -a ! -e "$DEVICE" ]; then
mknod "$DEVICE" c "$MAJOR" 0
chmod "$DEVICEPERM" "$DEVICE"
fi
if [ -e "$DEVICE" ]; then
WARN=
HOST=`/bin/uname -n`
DATE=`/bin/date '+%Y/%m/%d %H:%M:%S %Z'`
HC=/tmp/megactl.$$
$MEGACTL -vH > $HC 2>/dev/null
if [ -s $HC ]; then
WARN=' **WARNING**'
fi
(
if [ -s $HC ]; then
echo "megaraid health check"
echo "---------------------"
cat $HC
echo
echo
fi
echo "megaraid configuration"
echo "----------------------"
$MEGACTL -vp
echo
echo "--------------"
echo "$ME version: $VERSION"
echo "megactl version: $MEGACTLVERSION"
) 2>/dev/null |
/bin/mail -s "RAID report:$WARN $HOST $DATE" root
rm -f $HC
fi