aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils
diff options
context:
space:
mode:
authorsem <sem@FreeBSD.org>2006-04-20 21:57:05 +0800
committersem <sem@FreeBSD.org>2006-04-20 21:57:05 +0800
commitd9b30738581ea71532670087f75e0856cc206942 (patch)
treea83ff5bcb96dc211492930ff0493c7d20c2897e2 /sysutils
parent54e3da37d35c23659e335bc75774dac1c120db0b (diff)
downloadfreebsd-ports-gnome-d9b30738581ea71532670087f75e0856cc206942.tar.gz
freebsd-ports-gnome-d9b30738581ea71532670087f75e0856cc206942.tar.zst
freebsd-ports-gnome-d9b30738581ea71532670087f75e0856cc206942.zip
- Add daily periodic script to report RAID status and alarms
- PORTREVISION bumb PR: ports/96085 Submitted by: maintainer
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/tw_cli/Makefile9
-rw-r--r--sysutils/tw_cli/files/407.status-3ware-raid.in92
2 files changed, 100 insertions, 1 deletions
diff --git a/sysutils/tw_cli/Makefile b/sysutils/tw_cli/Makefile
index 21ffbf8ca5bc..b70ca960e74f 100644
--- a/sysutils/tw_cli/Makefile
+++ b/sysutils/tw_cli/Makefile
@@ -7,6 +7,7 @@
PORTNAME= tw_cli
PORTVERSION= 9.3.0.3
+PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= http://3ware.com/download/Escalade9000Series/${PORTVERSION}/
DISTNAME= ${PORTNAME}-freebsd_5.4-${DIST_ARCH}-${PORTVERSION}
@@ -22,7 +23,10 @@ ONLY_FOR_ARCHS= i386 amd64 ia64
WRKSRC= ${WRKDIR}
NO_BUILD= yes
STRIP= # empty
-PLIST_FILES= sbin/tw_cli sbin/tw_sched
+SUB_FILES+= 407.status-3ware-raid
+PLIST_FILES= sbin/tw_cli sbin/tw_sched \
+ etc/periodic/daily/407.status-3ware-raid
+PLIST_DIRS= etc/periodic/daily etc/periodic
PORTDOCS= tw_cli.8.html tw_sched.8.html
MAN8+= tw_cli.8 tw_sched.8
@@ -38,6 +42,9 @@ do-install:
${INSTALL_PROGRAM} ${WRKSRC}/tw_cli ${WRKSRC}/tw_sched ${PREFIX}/sbin/
${INSTALL_MAN} ${WRKSRC}/tw_cli.8.nroff ${MANPREFIX}/man/man8/tw_cli.8
${INSTALL_MAN} ${WRKSRC}/tw_sched.8.nroff ${MANPREFIX}/man/man8/tw_sched.8
+ @${MKDIR} ${PREFIX}/etc/periodic/daily
+ ${INSTALL_SCRIPT} ${WRKDIR}/407.status-3ware-raid \
+ ${PREFIX}/etc/periodic/daily/
post-install:
.if !defined(NOPORTDOCS)
diff --git a/sysutils/tw_cli/files/407.status-3ware-raid.in b/sysutils/tw_cli/files/407.status-3ware-raid.in
new file mode 100644
index 000000000000..28ea731089bf
--- /dev/null
+++ b/sysutils/tw_cli/files/407.status-3ware-raid.in
@@ -0,0 +1,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