blob: 44d881f669bef9b44e3487b8afb9247b8f52bae8 (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/bin/sh
#
# Shows status of 3ware RAID controllers: twa(4), twe(4)
#
# Authors: Bjoern A. Zeeb, Dmitry Frolov
#
# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi
# Defaults.
: ${daily_status_3ware_raid_enable:=NO}
# Alarms persist between "tw_cli alarms" invocation?
# Set to YES for twa(4) and to NO for twe(4).
: ${daily_status_3ware_raid_persist_alarms:=YES}
tw_cli=${tw_cli:-%%PREFIX%%/sbin/tw_cli}
logdir=${logdir:-/var/log}
case "$daily_status_3ware_raid_enable" in
[Yy][Ee][Ss])
echo
echo 'Checking status of 3ware RAID controllers:'
rc=0
# Checking each controller.
for ctrl in `${tw_cli} info | awk '/^c/ { print $1 }'`
do
echo ""
echo "Controller ${ctrl}:"
ctrl_log=${logdir}/3ware_raid_${ctrl}
if test ! -f ${ctrl_log}.today; then
touch ${ctrl_log}.today
fi
mv -f ${ctrl_log}.today ${ctrl_log}.yesterday
${tw_cli} info ${ctrl} > ${ctrl_log}.today
lines=`wc -l ${ctrl_log}.today | awk '{ print $1 }'`
diff -U $lines ${ctrl_log}.yesterday ${ctrl_log}.today
raid_rc=$?
if test $raid_rc -eq 0; then
cat ${ctrl_log}.today
fi
[ $rc -eq 0 ] && [ $raid_rc -ne 0 ] && rc=3
done
# Checking alarms.
echo "Alarms (most recent first):"
alarms_log=${logdir}/3ware_raid_alarms
case "$daily_status_3ware_raid_persist_alarms" in
[Yy][Ee][Ss])
if test ! -f ${alarms_log}.today; then
touch ${alarms_log}.today
fi
mv -f ${alarms_log}.today ${alarms_log}.yesterday
${tw_cli} alarms > ${alarms_log}.today
cmp -zs ${alarms_log}.yesterday ${alarms_log}.today
raid_rc=$?
if test $raid_rc -ne 0; then
diff -u ${alarms_log}.yesterday ${alarms_log}.today | \
grep -v '^-\|^$'
fi
;;
*)
raid_rc=0
${tw_cli} alarms > ${alarms_log}.today
lines=`wc -l ${alarms_log}.today | awk '{ print $1 }'`
if test $lines -gt 4; then
cat ${alarms_log}.today
raid_rc=1
fi
;;
esac
if test $raid_rc -eq 0; then
echo " No new alarms."
fi
[ $rc -eq 0 ] && [ $raid_rc -ne 0 ] && rc=3
;;
*) rc=0;;
esac
exit $rc
# end
|