diff options
author | Rong-En Fan <rafan@FreeBSD.org> | 2007-03-09 13:15:02 +0000 |
---|---|---|
committer | Rong-En Fan <rafan@FreeBSD.org> | 2007-03-09 13:15:02 +0000 |
commit | e2b088f90ea75342c266dd80949956b3d96ca068 (patch) | |
tree | b4d09d82ba8bc101a5e69eebd21b86e0259724e2 /sysutils/linux-megacli2 | |
parent | 348d4cbac58e7136b8e231ded77ce79fc314e91c (diff) |
Notes
Diffstat (limited to 'sysutils/linux-megacli2')
-rw-r--r-- | sysutils/linux-megacli2/Makefile | 6 | ||||
-rw-r--r-- | sysutils/linux-megacli2/files/407.status-mfi-raid.in | 227 | ||||
-rw-r--r-- | sysutils/linux-megacli2/files/README-status-mfi-raid.txt | 42 | ||||
-rw-r--r-- | sysutils/linux-megacli2/files/megacli.sh.in | 23 | ||||
-rw-r--r-- | sysutils/linux-megacli2/pkg-message | 17 | ||||
-rw-r--r-- | sysutils/linux-megacli2/pkg-plist | 4 |
6 files changed, 309 insertions, 10 deletions
diff --git a/sysutils/linux-megacli2/Makefile b/sysutils/linux-megacli2/Makefile index c94a0cf7bff8..6b2caf83d8cb 100644 --- a/sysutils/linux-megacli2/Makefile +++ b/sysutils/linux-megacli2/Makefile @@ -7,6 +7,7 @@ PORTNAME= megacli PORTVERSION= 1.01.09 +PORTREVISION= 1 CATEGORIES= sysutils linux MASTER_SITES= http://lsi.com/files/support/rsa/MR_SAS_1.0/ PKGNAMEPREFIX= linux- @@ -21,11 +22,13 @@ RESTRICTED= Redistribution prohibited, see: http://lsi.com/cm/License.do ONLY_FOR_ARCHS= i386 amd64 USE_LINUX= yes SUB_FILES= megacli.sh +SUB_FILES+= 407.status-mfi-raid # From bsd.linux.rpm.mk RPM2CPIO?= ${LOCALBASE}/bin/rpm2cpio EXTRACT_DEPENDS+= ${RPM2CPIO}:${PORTSDIR}/archivers/rpm + post-extract: @cd ${WRKSRC} && \ ${UNZIP_CMD} MegaCliLin.zip && \ @@ -36,12 +39,15 @@ do-build: do-install: ${INSTALL_SCRIPT} ${WRKSRC}/megacli.sh ${PREFIX}/sbin/megacli + ${MKDIR} -p ${PREFIX}/etc/periodic/daily + ${INSTALL_SCRIPT} ${WRKSRC}/407.status-mfi-raid ${PREFIX}/etc/periodic/daily ${INSTALL_PROGRAM} ${WRKSRC}/usr/sbin/MegaCli ${PREFIX}/libexec post-install: .if !defined(NOPORTDOCS) ${MKDIR} ${DOCSDIR} ${INSTALL_MAN} ${WRKSRC}/Read-me.txt ${DOCSDIR}/readme.txt + ${INSTALL_MAN} ${FILESDIR}/README-status-mfi-raid.txt ${DOCSDIR}/README-status-mfi-raid.txt .endif @${CAT} ${PKGMESSAGE} diff --git a/sysutils/linux-megacli2/files/407.status-mfi-raid.in b/sysutils/linux-megacli2/files/407.status-mfi-raid.in new file mode 100644 index 000000000000..609709797071 --- /dev/null +++ b/sysutils/linux-megacli2/files/407.status-mfi-raid.in @@ -0,0 +1,227 @@ +#!/bin/sh +# +# Show status of LSI Logic's MegaRAID SAS RAID controllers. +# +# $FreeBSD$ +# + +# If there is a global system configuration file, suck it in. +# +if test -r /etc/defaults/periodic.conf; then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +# Defaults. +: ${daily_status_mfi_raid_enable:=NO} +: ${daily_status_mfi_raid_verbose:=NO} +: ${daily_status_mfi_raid_persist_logs:=YES} + +megacli=${megacli:-%%PREFIX%%/sbin/megacli} +logdir=${logdir:-/var/log} + +case "$daily_status_mfi_raid_enable" in + [Yy][Ee][Ss]) + ;; + *) + exit 0 + ;; +esac + +if test `id -u` -ne 0; then + echo "You must be root to run `basename $0`." >&2 + exit 1 +fi + +ADPCOUNT=$(${megacli} -adpCount | \ + awk '/Controller Count:/ { gsub("\\.", ""); print $3 }') + +case ${ADPCOUNT} in + 0) echo "Error: Cannot find an adapter." >&2 + exit 1 + ;; + [1-9]|[1-9][0-9]|[1-2][0-9][0-9]) + ;; + *) + echo "Error: Cannot get the number of adapters: ${ADPCOUNT}" >&2 + exit 1 + ;; +esac + +ADPMINIDX=0 +ADPMAXIDX=`expr ${ADPCOUNT} - 1` + +rc=0 +for ctrl in `jot ${ADPCOUNT} ${ADPMINIDX} ${ADPMAXIDX}`; do + echo "Adpater: ${ctrl}" + + # Print summary information. + echo "------------------------------------------------------------------------" + echo "Physical Drive Information:" + ${megacli} -PDList -a${ctrl} | \ + awk ' + BEGIN { + E=-1; S=-1; D=-1; s=-1; mec=-1; oec=-1; pfc=-1; lpfeqn=-1; + state=""; + printf "ENC SLO DEV SEQ MEC OEC PFC LPF STATE\n"; + } + /^Enclosure Number:/ { E=$3; } + /^Slot Number:/ { S=$3; } + /^Device Id:/ { D=$3; } + /^Sequence Number:/ { s=$3; } + /^Media Error Count:/ { mec=$4; } + /^Other Error Count:/ { oec=$4; } + /^Predictive Failure Count:/ { pfc=$4; } + /^Last Predictive Failure Event Seq Number:/ { lpfeqn=$7 } + /^Firmware state:/ { state=$3; } + /^$/ { + if (E!=-1 && S!=-1 && D!=-1) { + printf "%-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d %s\n", + E, S, D, s, mec, oec, pfc, lpfeqn, state; + } + E=-1; S=-1; D=-1; s=-1; mec=-1; oec=-1; pfc=-1; lpfeqn=-1; + state=""; + } + ' | sort -n -k1 -k2 -k3 + echo + echo "Virtual Drive Information:" + ${megacli} -LDInfo -lall -a${ctrl} | \ + awk ' + BEGIN { + drvs=-1; vd=-1; state=""; name=""; s=-1; strs=-1; + rlp=-1; rls=-1; rlq=-1; + printf "VD DRV RLP RLS RLQ STS SIZE STATE NAME\n"; + } + /^Name:/ { sub("^Name:", ""); name=$0; } + /^RAID Level:/ { + #Primary-1, Secondary-0, RAID Level Qualifier-0 + _p=_s=_q=$0; + sub(".*Primary-", "", _p); + sub(", Secondary.*", "", _p); + rlp=_p; + sub(".*Secondary-", "", _s); + sub(", RAID Level.*", "", _s); + rls=_s; + sub(".*Qualifier-", "", _q); + rlq=_q; + } + /^Size:/ { sub("^Size:", ""); s=$0; } + /^State:/ { state=$2; } + /^Stripe Size:/ { strs=$3; } + /^Number Of Drives:/ { sub("Drives:", "", $3); drvs=$3; } + /^Virtual Disk:/ { + if (vd!=-1) { + printf "%-3d %-3d %-3d %-3d %-3d %-6s %-11s %-13s %s\n", + vd, drvs, rlp, rls, rlq, strs, s, state, name; + } + drvs=-1; vd=-1; state=""; name=""; s=-1; strs=-1; + rlp=-1; rls=-1; rlq=-1; + vd=$3; + } + END { + if (vd!=-1) { + printf "%-3d %-3d %-3d %-3d %-3d %-6s %-11s %-13s %s\n", + vd, drvs, rlp, rls, rlq, strs, s, state, name; + } + } + ' + echo + echo "BBU Information:" + ${megacli} -AdpBbuCmd -a${ctrl} | \ + awk ' + BEGIN { + type=""; temp=-1; isok=-1; rsoc=-1; asoc=-1; + rc=-1; cc=-1; me=-1; + } + /^BatteryType:/ { type=$2; } + /^Temperature:/ { temp=$2; } + /^isSOHGood:/ { isok=$2; } + /^Relative State of Charge:/ { rsoc=$5; } + /^Absolute State of charge:/ { asoc=$5; } + /^Remaining Capacity:/ { rc=$3; } + /^Cycle Count:/ { cc=$3; } + /^Max Error:/ { me=$3; } + END { + printf "TYPE TEMP OK RSOC ASOC RC CC ME\n"; + printf "%-4s %-2d C %-4s %-5d %-5d %-5d %-5d %-2d\n", + type, temp, isok, rsoc, asoc, rc, cc, me; + + } + ' + echo + + # Give very long outputs. + case "$daily_status_mfi_raid_verbose" in + [Yy][Ee][Ss]) + ${megacli} -AdpAllInfo -a${ctrl} + ${megacli} -EncInfo -a${ctrl} + ${megacli} -PDList -a${ctrl} + ${megacli} -LDGetNUm -a${ctrl} + ${megacli} -LDInfo -Lall -a${ctrl} + ${megacli} -AdpBbuCmd -GetBbuStatus -a${ctrl} + ;; + *) + ;; + esac + + # Diff daily logs. + echo "Controller Logs:" + ctrl_log=${logdir}/mfi_raid_${ctrl} + case "$daily_status_mfi_raid_persist_logs" in + [Yy][Ee][Ss]) + if test ! -f ${ctrl_log}.today; then + touch ${ctrl_log}.today + fi + mv -f ${ctrl_log}.today ${ctrl_log}.yesterday + ;; + *) + ;; + esac + ${megacli} -AdpEventLog -GetEvents -f ${ctrl_log}.tmp -a${ctrl} + awk ' + BEGIN { + inrecord=0; + } + printed=0; + /^seqNum: / { + inrecord=0; + print ""; + print "====================================" \ + "===================================="; + } + /^Event Data:/ { inrecord=1; printed=1; } + /^seqNum: /, /^Event Data:/ + /^===========/ { printed=1; } + /^$/ { printed=1; } + { if (inrecord && !printed) { printf "\t%s\n", $0; } } + ' < ${ctrl_log}.tmp > ${ctrl_log}.today + rm -f ${ctrl_log}.tmp + # Now show the differences or the entire log. + case "$daily_status_mfi_raid_persist_logs" in + [Yy][Ee][Ss]) + cmp -zs ${ctrl_log}.yesterday ${ctrl_log}.today + raid_rc=$? + if test $raid_rc -ne 0; then + diff -u ${ctrl_log}.yesterday ${ctrl_log}.today | \ + grep -v '^-\|^$' + fi + ;; + *) + # XXX we might consider clearing the logs here + # ${megacli} -AdpEventLog -Clear -a${ctrl} + raid_rc=0 + lines=`wc -l ${ctrl_log}.today | awk '{ print $1 }'` + if test $lines -gt 4; then + cat ${ctrl_log}.today + raid_rc=1 + fi + esac + if test $raid_rc -eq 0; then + echo " No new log messages." + fi + [ $rc -eq 0 ] && [ $raid_rc -ne 0 ] && rc=3 +done + +exit ${rc} + +# end diff --git a/sysutils/linux-megacli2/files/README-status-mfi-raid.txt b/sysutils/linux-megacli2/files/README-status-mfi-raid.txt new file mode 100644 index 000000000000..3dae7a7da976 --- /dev/null +++ b/sysutils/linux-megacli2/files/README-status-mfi-raid.txt @@ -0,0 +1,42 @@ +# $FreeBSD$ + +The output of periodic/daily/407.status-mfi-raid uses several +abbreviations. This documents maps the abbreviations to the +names MegaCli uses, which were just too long for summary mails. + +Section 'Physical Drive Information:' +-------------------------------------------------- +ENC Enclosure Number +SLO Slot Number +DEV Device Id +SEQ Sequence Number +MEC Media Error Count +OEC Other Error Count +PFC Predictive Failure Count +LPF Last Predictive Failure Event Seq Number +STATE Firmware state + +Section 'Virtual Drive Information:' +-------------------------------------------------- +VD Virtual Disk +DRV Number Of Drives +RLP RAID Level: Primary +RLS RAID Level: Secondary +RLQ RAID Level: RAID Level Qualifier +STS Stripe Size +SIZE Size +STATE State +NAME Name + +Section 'BBU Information:' +-------------------------------------------------- +TYPE BatteryType +TEMP Temperature +OK isSOHGood +RSOC Relative State of Charge +ASOC Absolute State of charge +RC Remaining Capacity +CC Cycle Count +ME Max Error + +# end diff --git a/sysutils/linux-megacli2/files/megacli.sh.in b/sysutils/linux-megacli2/files/megacli.sh.in index 51aa7aba9b29..f28e45bc8a97 100644 --- a/sysutils/linux-megacli2/files/megacli.sh.in +++ b/sysutils/linux-megacli2/files/megacli.sh.in @@ -4,17 +4,23 @@ # if [ `id -u` -ne 0 ] then - echo You must be root to run `basename $0`. + echo "You must be root to run `basename $0`." >&2 exit 1 fi if ! [ `sysctl -n compat.linux.osrelease` = "2.6.12" ]; then - echo You need to set compat.linux.osrelease to 2.6.12 to run `basename $0`. + echo "You need to set compat.linux.osrelease to 2.6.12 to run `basename $0`." >&2 exit 1 fi -if ! [ -d /usr/compat/linux/sys ]; then - echo You need to mount linsysfs to run `basename $0`. +lpfs=`mount -t linprocfs | wc -l | awk '{ print $1 }'` +if [ ${lpfs} -le 0 ]; then + echo "You need to mount linprocfs to run `basename $0`." >&2 + exit 1 +fi +lsfs=`mount -t linsysfs | wc -l | awk '{ print $1 }'` +if [ ${lsfs} -le 0 ]; then + echo "You need to mount linsysfs to run `basename $0`." >&2 exit 1 fi @@ -24,11 +30,16 @@ if ! kldstat -q -m mfi_linux then if kldload mfi_linux then - echo 'mfi_linux module loaded.' + echo 'mfi_linux module loaded.' >&2 else - echo 'mfi_linux module failed to load.' + echo 'mfi_linux module failed to load.' >&2 exit 1 fi fi +if [ $# -le 0 ]; then + echo "usage: `basename $0` [options]" >&2 + exec %%PREFIX%%/libexec/MegaCli -h +fi + exec %%PREFIX%%/libexec/MegaCli ${*} diff --git a/sysutils/linux-megacli2/pkg-message b/sysutils/linux-megacli2/pkg-message index 08da2f475d0d..e9927447136f 100644 --- a/sysutils/linux-megacli2/pkg-message +++ b/sysutils/linux-megacli2/pkg-message @@ -20,11 +20,20 @@ Add the following to /etc/sysctl.conf Add the following to /etc/fstab # For MegaCLi - linsys /compat/linux/sys linsysfs rw 0 0 + linproc /compat/linux/proc linprocfs rw 0 0 + linsys /compat/linux/sys linsysfs rw 0 0 + +Add the following to /etc/periodic.conf + + # !!! Warning: test before running on a production system !!! + # !!! Warning: might hang your system !!! + # For daily summary mails and log diffs: + daily_status_mfi_raid_enable="YES" + # In case you want really lots of details enable this: + daily_status_mfi_raid_verbose="NO" If you find mfi(4) too verbose, see mfi_evt_class_t in /usr/src/sys/dev/mfi/mfireg.h for values you can use in the + hw.mfi.event_class +sysctl variable. -hw.mfi.event_class - -sysctl variable diff --git a/sysutils/linux-megacli2/pkg-plist b/sysutils/linux-megacli2/pkg-plist index 7c80232bf065..83ab15aabd3b 100644 --- a/sysutils/linux-megacli2/pkg-plist +++ b/sysutils/linux-megacli2/pkg-plist @@ -1,4 +1,8 @@ sbin/megacli libexec/MegaCli +etc/periodic/daily/407.status-mfi-raid %%PORTDOCS%%%%DOCSDIR%%/readme.txt +%%PORTDOCS%%%%DOCSDIR%%/README-status-mfi-raid.txt %%PORTDOCS%%@dirrm %%DOCSDIR%% +@dirrmtry etc/periodic/daily +@dirrmtry etc/periodic |