diff options
author | pav <pav@FreeBSD.org> | 2007-12-16 02:37:59 +0800 |
---|---|---|
committer | pav <pav@FreeBSD.org> | 2007-12-16 02:37:59 +0800 |
commit | 76ebb7b45848b93e172f668365afa6ce6144baa4 (patch) | |
tree | 4221f395d5ce671a57b2ca2f5c7b987ddbe03c96 | |
parent | a91b150cea86de8c9a178c891e17f1f26278ec20 (diff) | |
download | freebsd-ports-gnome-76ebb7b45848b93e172f668365afa6ce6144baa4.tar.gz freebsd-ports-gnome-76ebb7b45848b93e172f668365afa6ce6144baa4.tar.zst freebsd-ports-gnome-76ebb7b45848b93e172f668365afa6ce6144baa4.zip |
- Add periodic daily script
PR: ports/117848
Submitted by: bz
Approved by: rink (maintainer)
-rw-r--r-- | sysutils/areca-cli/Makefile | 7 | ||||
-rw-r--r-- | sysutils/areca-cli/files/407.status-areca-raid.in | 143 | ||||
-rw-r--r-- | sysutils/areca-cli/pkg-plist | 4 |
3 files changed, 153 insertions, 1 deletions
diff --git a/sysutils/areca-cli/Makefile b/sysutils/areca-cli/Makefile index c9fbc0153d92..f71c52342292 100644 --- a/sysutils/areca-cli/Makefile +++ b/sysutils/areca-cli/Makefile @@ -7,6 +7,7 @@ PORTNAME= areca-cli PORTVERSION= ${CLI_VER}.${CLI_REV} +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= ftp://ftp.unnet.nl/pub/areca/RaidCards/AP_Drivers/FreeBSD/CLI/ \ ftp://ftp.areca.com.tw/RaidCards/AP_Drivers/FreeBSD/CLI/ @@ -17,7 +18,7 @@ COMMENT= Command Line Interface for the Areca ARC-xxxx RAID controllers ONLY_FOR_ARCHS= i386 amd64 -PLIST_FILES= sbin/areca-cli +PERIODICSCRIPT= 407.status-areca-raid USE_ZIP= yes NO_BUILD= yes @@ -25,7 +26,11 @@ NO_BUILD= yes CLI_VER= 1.5 CLI_REV= 50930 +SUB_FILES+= ${PERIODICSCRIPT} + do-install: ${INSTALL_PROGRAM} ${WRKSRC}/cli32 ${PREFIX}/sbin/areca-cli + @${MKDIR} ${PREFIX}/etc/periodic/daily + ${INSTALL_SCRIPT} ${WRKDIR}/${PERIODICSCRIPT} ${PREFIX}/etc/periodic/daily .include <bsd.port.mk> diff --git a/sysutils/areca-cli/files/407.status-areca-raid.in b/sysutils/areca-cli/files/407.status-areca-raid.in new file mode 100644 index 000000000000..8276457ed8b4 --- /dev/null +++ b/sysutils/areca-cli/files/407.status-areca-raid.in @@ -0,0 +1,143 @@ +#!/bin/sh +# +# Shows status of areca RAID controllers: arcmsr(4) +# +# Authors: Bjoern A. Zeeb +# +# $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_arcmsr_raid_enable:=NO} +# Verbose. +: ${daily_status_arcmsr_raid_verbose:=YES} +# SMART. +: ${daily_status_arcmsr_raid_smart:=YES} +# Logs persist between "areca-cli event info" invocation? +: ${daily_status_arcmsr_raid_persist_logs:=YES} + +areca_cli=${areca_cli:-%%PREFIX%%/sbin/areca-cli} +logdir=${logdir:-/var/log} + +verbose() +{ + local cmd + local scmd + local log + cmd=$1 + scmd=$2 + log=$3 + + case ${daily_status_arcmsr_raid_verbose} in + [Nn][Oo]) + return + ;; + *) ;; + esac + + ${areca_cli} ${cmd} ${scmd} >> ${log} +} + +smart() +{ + local log + local disk + log=$1 + + case ${daily_status_arcmsr_raid_smart} in + [Nn][Oo]) + return + ;; + *) ;; + esac + + for disk in `${areca_cli} disk info | awk ' + BEGIN { run=0 } + { if (/^=======/) { + if (run==0) { run=1; } else { run=0; } } + else { if (run==1) { printf "%d ", $1; } } };'`; do + echo "SMART data for disk ${disk}" >> ${log} + ${areca_cli} disk smart drv=${disk} >> ${log} + done +} + +case "$daily_status_arcmsr_raid_enable" in + [Yy][Ee][Ss]) + echo + echo 'Checking status of Areca RAID controllers:' + + rc=0 + + # Checking the currently selected (1st) controller. + # XXX TODO set curctrl=[1..4]; along with that + # XXX TODO try to only call areca-cli once (per ctrl). + echo "" + echo "Controller ${ctrl}:" + ctrl_log=${logdir}/arcmsr_raid_${ctrl} + if test ! -f ${ctrl_log}.today; then + touch ${ctrl_log}.today + fi + mv -f ${ctrl_log}.today ${ctrl_log}.yesterday + # Not too efficient to call areca_cli lots of times. + verbose sys info ${ctrl_log}.today + ${areca_cli} rsf info >> ${ctrl_log}.today + verbose vsf info ${ctrl_log}.today + verbose disk info ${ctrl_log}.today + smart ${ctrl_log}.today + verbose hw info ${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 + + # Checking logs. + echo "Logs (most recent first):" + logs_log=${logdir}/arcmsr_log_${ctrl} + case "$daily_status_arcmsr_raid_persist_logs" in + [Yy][Ee][Ss]) + if test ! -f ${logs_log}.today; then + touch ${logs_log}.today + fi + mv -f ${logs_log}.today ${logs_log}.yesterday + ${areca_cli} event info > ${logs_log}.today + cmp -zs ${logs_log}.yesterday ${logs_log}.today + raid_rc=$? + if test $raid_rc -ne 0; then + diff -u ${logs_log}.yesterday ${logs_log}.today | \ + grep -v '^-\|^$' + fi + ;; + *) + raid_rc=0 + ${areca_cli} event info > ${logs_log}.today + ${areca_cli} event clear >> ${logs_log}.today + lines=`wc -l ${logs_log}.today | awk '{ print $1 }'` + if test $lines -gt 4; then + cat ${logs_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 diff --git a/sysutils/areca-cli/pkg-plist b/sysutils/areca-cli/pkg-plist new file mode 100644 index 000000000000..8ddb507b84a2 --- /dev/null +++ b/sysutils/areca-cli/pkg-plist @@ -0,0 +1,4 @@ +etc/periodic/daily/407.status-areca-raid +sbin/areca-cli +@dirrmtry etc/periodic/daily +@dirrmtry etc/periodic |