Date: Thu, 13 Nov 2008 17:02:54 GMT From: Sean McAfee <smcafee@collaborativefusion.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/128846: New port: sysutils/linux-megacli2 - LSI MegaRAID SAS controller management utility (2.x branch) Message-ID: <200811131702.mADH2soL010755@www.freebsd.org> Resent-Message-ID: <200811131710.mADHA3bM098576@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 128846 >Category: ports >Synopsis: New port: sysutils/linux-megacli2 - LSI MegaRAID SAS controller management utility (2.x branch) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Nov 13 17:10:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Sean McAfee >Release: >Organization: Collaborative Fusion, Inc. >Environment: >Description: LSI has released a new major revision (2.x) of their MegaCLI tool. I've submitted it as a new port instead of an update since, officially, they support different sets of devices. >How-To-Repeat: >Fix: shar file attached. Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # linux-megacli2 # linux-megacli2/files # linux-megacli2/files/407.status-mfi-raid.in # linux-megacli2/files/README-status-mfi-raid.txt # linux-megacli2/files/megacli.sh.in # linux-megacli2/files/mfi_tty_log.in # linux-megacli2/Makefile # linux-megacli2/distinfo # linux-megacli2/pkg-descr # linux-megacli2/pkg-message # linux-megacli2/pkg-plist # echo c - linux-megacli2 mkdir -p linux-megacli2 > /dev/null 2>&1 echo c - linux-megacli2/files mkdir -p linux-megacli2/files > /dev/null 2>&1 echo x - linux-megacli2/files/407.status-mfi-raid.in sed 's/^X//' >linux-megacli2/files/407.status-mfi-raid.in << 'END-of-linux-megacli2/files/407.status-mfi-raid.in' X#!/bin/sh X# X# Show status of LSI Logic's MegaRAID SAS RAID controllers. X# X# $FreeBSD: ports/sysutils/linux-megacli/files/407.status-mfi-raid.in,v 1.5 2008/10/13 17:22:20 stefan Exp $ X# X X# If there is a global system configuration file, suck it in. X# Xif test -r /etc/defaults/periodic.conf; then X . /etc/defaults/periodic.conf X source_periodic_confs Xfi X X# Defaults. X: ${daily_status_mfi_raid_enable:=NO} X: ${daily_status_mfi_raid_verbose:=NO} X: ${daily_status_mfi_raid_persist_logs:=YES} X: ${daily_status_mfi_raid_tty_log:=NO} X Xmegacli=${megacli:-%%PREFIX%%/sbin/megacli} Xlogdir=${logdir:-/var/log} X Xcase "$daily_status_mfi_raid_enable" in X [Yy][Ee][Ss]) X echo X echo 'Checking status of MFI RAID controllers:' X ;; X *) X exit 0 X ;; Xesac X Xif test `id -u` -ne 0; then X echo "You must be root to run `basename $0`." >&2 X exit 1 Xfi X XADPCOUNT=$(${megacli} -adpCount | \ X awk '/Controller Count:/ { gsub("\\.", ""); print $3 }') X Xcase ${ADPCOUNT} in X 0) echo "Error: Cannot find an adapter." >&2 X exit 1 X ;; X [1-9]|[1-9][0-9]|[1-2][0-9][0-9]) X ;; X *) X echo "Error: Cannot get the number of adapters: ${ADPCOUNT}" >&2 X exit 1 X ;; Xesac X XADPMINIDX=0 XADPMAXIDX=`expr ${ADPCOUNT} - 1` X Xrc=0 Xfor ctrl in `jot ${ADPCOUNT} ${ADPMINIDX} ${ADPMAXIDX}`; do X echo "Adapter: ${ctrl}" X X # Print summary information. X echo "------------------------------------------------------------------------" X echo "Physical Drive Information:" X echo "ENC SLO DEV SEQ MEC OEC PFC LPF STATE" X ${megacli} -PDList -a${ctrl} | \ X awk ' X BEGIN { X E=-1; S=-1; D=-1; s=-1; mec=-1; oec=-1; pfc=-1; lpfeqn=-1; X state=""; X } X /^Enclosure (Number:/ { E=$3; } X /^Enclosure Device ID:/ { E=$4; } X /^Slot Number:/ { S=$3; } X /^Device Id:/ { D=$3; } X /^Sequence Number:/ { s=$3; } X /^Media Error Count:/ { mec=$4; } X /^Other Error Count:/ { oec=$4; } X /^Predictive Failure Count:/ { pfc=$4; } X /^Last Predictive Failure Event Seq Number:/ { lpfeqn=$7 } X /^Firmware state:/ { state=$3; } X /^$/ { X if (E!=-1 && S!=-1 && D!=-1) { X printf "%-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d %s\n", X E, S, D, s, mec, oec, pfc, lpfeqn, state; X } X E=-1; S=-1; D=-1; s=-1; mec=-1; oec=-1; pfc=-1; lpfeqn=-1; X state=""; X } X ' | sort -n -k1 -k2 -k3 X echo X echo "Virtual Drive Information:" X ${megacli} -LDInfo -lall -a${ctrl} | \ X awk ' X BEGIN { X drvs=-1; vd=-1; state=""; name=""; s=-1; strs=-1; X rlp=-1; rls=-1; rlq=-1; X printf "VD DRV RLP RLS RLQ STS SIZE STATE NAME\n"; X } X /^Name:/ { sub("^Name:", ""); name=$0; } X /^RAID Level:/ { X #Primary-1, Secondary-0, RAID Level Qualifier-0 X _p=_s=_q=$0; X sub(".*Primary-", "", _p); X sub(", Secondary.*", "", _p); X rlp=_p; X sub(".*Secondary-", "", _s); X sub(", RAID Level.*", "", _s); X rls=_s; X sub(".*Qualifier-", "", _q); X rlq=_q; X } X /^Size:/ { sub("^Size:", ""); s=$0; } X /^State:/ { state=$2; } X /^Stripe Size:/ { strs=$3; } X /^Number Of Drives:/ { sub("Drives:", "", $3); drvs=$3; } X /^Virtual Disk:/ { X if (vd!=-1) { X printf "%-3d %-3d %-3d %-3d %-3d %-6s %-11s %-13s %s\n", X vd, drvs, rlp, rls, rlq, strs, s, state, name; X } X drvs=-1; vd=-1; state=""; name=""; s=-1; strs=-1; X rlp=-1; rls=-1; rlq=-1; X vd=$3; X } X END { X if (vd!=-1) { X printf "%-3d %-3d %-3d %-3d %-3d %-6s %-11s %-13s %s\n", X vd, drvs, rlp, rls, rlq, strs, s, state, name; X } X } X ' X # Print BBU Information, if we found something X ${megacli} -AdpBbuCmd -a${ctrl} | \ X awk ' X BEGIN { X type=""; temp=-1; isok="-"; rsoc=-1; asoc=-1; X rc=-1; cc=-1; me=-1; X } X /^BatteryType:/ { type=$2; } X /^Temperature:/ { temp=$2; } X /^isSOHGood:/ { isok=$2; } X /^Relative State of Charge:/ { rsoc=$5; } X /^Absolute State of charge:/ { asoc=$5; } X /^Remaining Capacity:/ { rc=$3; } X /^Cycle Count:/ { cc=$3; } X /^Max Error:/ { me=$3; } X END { X if (type == "") { exit 0 }; X printf "\nBBU Information:\n" X printf "TYPE TEMP OK RSOC ASOC RC CC ME\n"; X printf "%-5s %2dC %-3s %4d%% %4d%% %4dmAh %4d %2d%%\n", X type, temp, isok, rsoc, asoc, rc, cc, me; X X } X ' X echo X X # Give very long outputs. X case "$daily_status_mfi_raid_verbose" in X [Yy][Ee][Ss]) X ${megacli} -AdpAllInfo -a${ctrl} X ${megacli} -EncInfo -a${ctrl} X ${megacli} -PDList -a${ctrl} X ${megacli} -LDGetNUm -a${ctrl} X ${megacli} -LDInfo -Lall -a${ctrl} X ${megacli} -AdpBbuCmd -GetBbuStatus -a${ctrl} X ;; X *) X ;; X esac X X # Diff daily logs. X echo "Controller Logs:" X ctrl_log=${logdir}/mfi_raid_${ctrl} X case "$daily_status_mfi_raid_persist_logs" in X [Yy][Ee][Ss]) X if test ! -f ${ctrl_log}.today; then X touch ${ctrl_log}.today X fi X mv -f ${ctrl_log}.today ${ctrl_log}.yesterday X ;; X *) X ;; X esac X ${megacli} -AdpEventLog -GetEvents -f ${ctrl_log}.tmp -a${ctrl} X awk ' X BEGIN { X inrecord=0; X } X printed=0; X /^seqNum: / { X inrecord=0; X print ""; X print "====================================" \ X "===================================="; X } X /^Event Data:/ { inrecord=1; printed=1; } X /^seqNum: /, /^Event Data:/ X /^===========/ { printed=1; } X /^$/ { printed=1; } X { if (inrecord && !printed) { printf "\t%s\n", $0; } } X ' < ${ctrl_log}.tmp > ${ctrl_log}.today X rm -f ${ctrl_log}.tmp X # Now show the differences or the entire log. X case "$daily_status_mfi_raid_persist_logs" in X [Yy][Ee][Ss]) X cmp -s ${ctrl_log}.yesterday ${ctrl_log}.today X raid_rc=$? X if test $raid_rc -ne 0; then X diff -u ${ctrl_log}.yesterday ${ctrl_log}.today | \ X grep -v '^-\|^$' X fi X ;; X *) X # XXX we might consider clearing the logs here X # ${megacli} -AdpEventLog -Clear -a${ctrl} X raid_rc=0 X lines=`wc -l ${ctrl_log}.today | awk '{ print $1 }'` X if test $lines -gt 4; then X cat ${ctrl_log}.today X raid_rc=1 X fi X esac X if test $raid_rc -eq 0; then X echo " No new log messages." X fi X X # TTY Log X echo "TTY Log:" X tty_log=${logdir}/mfi_raid_${ctrl}_tty X tty_rc=0 X case "$daily_status_mfi_raid_tty_log" in X [Yy][Ee][Ss]) X if test ! -f ${tty_log}.today; then X touch ${tty_log}.today X fi X mv -f ${tty_log}.today ${tty_log}.yesterday X ${megacli} -FwTermLog Dsply -a${ctrl} > ${tty_log}.today X cmp -s ${tty_log}.yesterday ${tty_log}.today X tty_rc=$? X if test $tty_rc -ne 0; then X diff -u ${tty_log}.yesterday ${tty_log}.today | \ X grep -v '^-\|^$' X else X echo " No new TTY log messages." X fi X ;; X *) X ;; X esac X [ $rc -eq 0 ] && [ $raid_rc -ne 0 -o $tty_rc -ne 0 ] && rc=3 Xdone X Xexit ${rc} X X# end END-of-linux-megacli2/files/407.status-mfi-raid.in echo x - linux-megacli2/files/README-status-mfi-raid.txt sed 's/^X//' >linux-megacli2/files/README-status-mfi-raid.txt << 'END-of-linux-megacli2/files/README-status-mfi-raid.txt' X# $FreeBSD: ports/sysutils/linux-megacli/files/README-status-mfi-raid.txt,v 1.2 2007/12/27 00:15:48 bsam Exp $ X XThe output of periodic/daily/407.status-mfi-raid uses several Xabbreviations. This document maps the abbreviations to the Xnames MegaCli uses, which were just too long for summary mails. X XSection 'Physical Drive Information:' X-------------------------------------------------- XENC Enclosure Number XSLO Slot Number XDEV Device Id XSEQ Sequence Number XMEC Media Error Count XOEC Other Error Count XPFC Predictive Failure Count XLPF Last Predictive Failure Event Seq Number XSTATE Firmware state X XSection 'Virtual Drive Information:' X-------------------------------------------------- XVD Virtual Disk XDRV Number Of Drives XRLP RAID Level: Primary XRLS RAID Level: Secondary XRLQ RAID Level: RAID Level Qualifier XSTS Stripe Size XSIZE Size XSTATE State XNAME Name X XSection 'BBU Information:' X-------------------------------------------------- XTYPE BatteryType XTEMP Temperature XOK isSOHGood XRSOC Relative State of Charge XASOC Absolute State of charge XRC Remaining Capacity XCC Cycle Count XME Max Error X X# end END-of-linux-megacli2/files/README-status-mfi-raid.txt echo x - linux-megacli2/files/megacli.sh.in sed 's/^X//' >linux-megacli2/files/megacli.sh.in << 'END-of-linux-megacli2/files/megacli.sh.in' X#!/bin/sh X X# check for root user X# Xif [ `id -u` -ne 0 ] Xthen X echo "You must be root to run `basename $0`." >&2 X exit 1 Xfi X Xosrelease=`sysctl -n compat.linux.osrelease` X Xcase $osrelease in X 2.6.*) X if [ `echo $osrelease | cut -d . -f 3` -lt 12 ]; then X osrelease=TOOLOW X fi X ;; X 2.*) X if [ `echo $osrelease | cut -d . -f 2` -lt 6 ]; then X osrelease=TOOLOW X fi X ;; X *) X if [ `echo $osrelease | cut -d . -f 1` -lt 2 ]; then X osrelease=TOOLOW X fi X ;; Xesac X Xif [ $osrelease = "TOOLOW" ]; then X echo "You need to set compat.linux.osrelease to atleast 2.6.12 to run `basename $0`." >&2 X exit 1 Xfi X X Xlpfs=`mount -t linprocfs | awk 'END{ print NR }'` Xif [ ${lpfs} -le 0 ]; then X echo "You need to mount linprocfs to run `basename $0`." >&2 X exit 1 Xfi Xlsfs=`mount -t linsysfs | awk 'END{ print NR }'` Xif [ ${lsfs} -le 0 ]; then X echo "You need to mount linsysfs to run `basename $0`." >&2 X exit 1 Xfi X X# check for active mfi_linux.ko X# Xif ! kldstat -q -m mfi_linux Xthen X if kldload mfi_linux X then X echo 'mfi_linux module loaded.' >&2 X else X echo 'mfi_linux module failed to load.' >&2 X exit 1 X fi Xfi X Xif [ $# -le 0 ]; then X echo "usage: `basename $0` [options]" >&2 X exec %%PREFIX%%/libexec/MegaCli -h Xfi X Xexec %%PREFIX%%/libexec/MegaCli ${*} END-of-linux-megacli2/files/megacli.sh.in echo x - linux-megacli2/files/mfi_tty_log.in sed 's/^X//' >linux-megacli2/files/mfi_tty_log.in << 'END-of-linux-megacli2/files/mfi_tty_log.in' X#!/bin/sh X# X# $FreeBSD: ports/sysutils/linux-megacli/files/mfi_tty_log.in,v 1.1 2008/10/13 17:22:20 stefan Exp $ X# X X# PROVIDE: mfi_tty_log X# REQUIRE: abi X# KEYWORD: nojail X X: ${rc_mfi_raid_tty_log:=NO} X X. /etc/rc.subr X Xname="mfi_tty_log" Xstart_cmd="${name}_start" Xstop_cmd=":" X Xmfi_tty_log_start() X{ X megacli=${megacli:-%%PREFIX%%/sbin/megacli} X logdir=${logdir:-/var/log} X X case "$rc_mfi_raid_tty_log" in X [Yy][Ee][Ss]) X echo X echo 'Checking for TTY logs of MFI(4) RAID controllers:' X ;; X *) X return 0 X ;; X esac X X if test `id -u` -ne 0; then X echo "You must be root to run `basename $0`." >&2 X return 1 X fi X X ADPCOUNT=$(${megacli} -adpCount | \ X awk '/Controller Count:/ { gsub("\\.", ""); print $3 }') X X case ${ADPCOUNT} in X 0) echo "Error: Cannot find an adapter." >&2 X return 1 X ;; X [1-9]|[1-9][0-9]|[1-2][0-9][0-9]) X ;; X *) X echo "Error: Cannot get the number of adapters: ${ADPCOUNT}" >&2 X return 1 X ;; X esac X X ADPMINIDX=0 X ADPMAXIDX=`expr ${ADPCOUNT} - 1` X X for ctrl in `jot ${ADPCOUNT} ${ADPMINIDX} ${ADPMAXIDX}`; do X tty_log=${logdir}/mfi_raid_${ctrl}_tty.boot X echo " Adapter: ${ctrl} - TTY log saved to ${tty_log}" X ${megacli} -FwTermLog Dsply -a${ctrl} > ${tty_log} X done X} X Xrun_rc_command "$1" END-of-linux-megacli2/files/mfi_tty_log.in echo x - linux-megacli2/Makefile sed 's/^X//' >linux-megacli2/Makefile << 'END-of-linux-megacli2/Makefile' X# Ports collection makefile for: linux-megacli X# Date created: Wed, Nov 29th, 2006 X# Whom: Ruben van Staveren (ruben@verweg.com) X# X# $FreeBSD: ports/sysutils/linux-megacli/Makefile,v 1.9 2008/10/18 08:42:33 stefan Exp $ X# X XPORTNAME= megacli XPORTVERSION= 2.00.15 XCATEGORIES= sysutils linux XMASTER_SITES= http://www.lsi.com/support/downloads/megaraid/miscellaneous/linux/ XPKGNAMEPREFIX= linux- XDISTNAME= ${PORTVERSION}_Linux_MegaCLI X XMAINTAINER= ruben@verweg.com XCOMMENT= LSI MegaRAID SAS controller management utility X XNO_WRKSUBDIR= yes XUSE_ZIP= yes XRESTRICTED= Redistribution prohibited, see: http://lsi.com/cm/License.do XONLY_FOR_ARCHS= i386 amd64 XUSE_LINUX= yes XSUB_FILES= megacli.sh XSUB_FILES+= 407.status-mfi-raid XSUB_FILES+= mfi_tty_log X XCONFLICTS= linux-megacli-1* X X# From bsd.linux.rpm.mk XRPM2CPIO?= ${LOCALBASE}/bin/rpm2cpio XEXTRACT_DEPENDS+= ${RPM2CPIO}:${PORTSDIR}/archivers/rpm X Xpost-extract: X cd ${WRKSRC} && \ X ${UNZIP_CMD} -qo MegaCliLin.zip && \ X ${RPM2CPIO} MegaCli-${PORTVERSION}-1.i386.rpm | ${CPIO} -id --quiet X Xdo-build: X @${BRANDELF} -t Linux ${WRKSRC}/opt/MegaRAID/MegaCli/MegaCli X Xdo-install: X ${INSTALL_SCRIPT} ${WRKSRC}/megacli.sh ${PREFIX}/sbin/megacli X ${MKDIR} ${PREFIX}/etc/periodic/daily X ${INSTALL_SCRIPT} ${WRKSRC}/407.status-mfi-raid ${PREFIX}/etc/periodic/daily X ${INSTALL_SCRIPT} ${WRKSRC}/mfi_tty_log ${PREFIX}/etc/rc.d X ${INSTALL_PROGRAM} ${WRKSRC}/opt/MegaRAID/MegaCli/MegaCli ${PREFIX}/libexec X Xpost-install: X.if !defined(NOPORTDOCS) X ${MKDIR} ${DOCSDIR} X ${INSTALL_MAN} ${WRKSRC}/${PORTVERSION}_Linux_MegaCLI.txt ${DOCSDIR}/readme.txt X ${INSTALL_MAN} ${FILESDIR}/README-status-mfi-raid.txt ${DOCSDIR}/README-status-mfi-raid.txt X.endif X @${CAT} ${PKGMESSAGE} X X.include <bsd.port.pre.mk> X X.if ${OSVERSION} < 602000 XIGNORE= needs at least FreeBSD 6.2 and mfi_linux.ko X.endif X X.include <bsd.port.post.mk> END-of-linux-megacli2/Makefile echo x - linux-megacli2/distinfo sed 's/^X//' >linux-megacli2/distinfo << 'END-of-linux-megacli2/distinfo' XMD5 (2.00.15_Linux_MegaCLI.zip) = 5ae84202ffa13f6daa12619a49004d0d XSHA256 (2.00.15_Linux_MegaCLI.zip) = 11d93efc59307ac3321c187d01b86511839ddb33ead8567783d877fff3f7284e XSIZE (2.00.15_Linux_MegaCLI.zip) = 1373388 END-of-linux-megacli2/distinfo echo x - linux-megacli2/pkg-descr sed 's/^X//' >linux-megacli2/pkg-descr << 'END-of-linux-megacli2/pkg-descr' XLSI Logic MegaRAID SAS MegaCLI Release X XThis is the Linux console based management utility for the LSI XMegaRAID SAS family of controllers. X XFreeBSD >= 6.1 supports running this tool by the means of the Xmfi_linux.ko kernel module and the /dev/mfi0 device. X XAuthor: LSI Logic Corporation XWWW: http://www.lsi.com/ END-of-linux-megacli2/pkg-descr echo x - linux-megacli2/pkg-message sed 's/^X//' >linux-megacli2/pkg-message << 'END-of-linux-megacli2/pkg-message' X X=================================================================== XThis port installed a commercial software product with a restricted Xlicense. Please review the license terms at this URL: X X http://www.lsi.com/cm/License.do X X=================================================================== X XAdd the following to /boot/loader.conf X X # For MegaCLi X mfi_linux_load="YES" X XAdd the following to /etc/sysctl.conf X X # For MegaCLi X compat.linux.osrelease=2.6.12 X XAdd the following to /etc/fstab X X # For MegaCLi X linproc /compat/linux/proc linprocfs rw 0 0 X linsys /compat/linux/sys linsysfs rw 0 0 X XAdd the following to /etc/periodic.conf X X # !!! Warning: test before running on a production system !!! X # !!! Warning: might hang your system !!! X # For daily summary mails and log diffs: X daily_status_mfi_raid_enable="YES" X # In case you want really lots of details enable this: X daily_status_mfi_raid_verbose="YES" X # In case you want the tty logs from the controller X daily_status_mfi_raid_tty_log="YES" X XAdd the following to /etc/rc.conf X X# Save tty log on reboot (you want this) Xrc_mfi_raid_tty_log="YES" X X XIf you find mfi(4) too verbose, see mfi_evt_class_t in X/usr/src/sys/dev/mfi/mfireg.h for values you can use in the X hw.mfi.event_class Xsysctl variable. X END-of-linux-megacli2/pkg-message echo x - linux-megacli2/pkg-plist sed 's/^X//' >linux-megacli2/pkg-plist << 'END-of-linux-megacli2/pkg-plist' Xsbin/megacli Xlibexec/MegaCli Xetc/periodic/daily/407.status-mfi-raid Xetc/rc.d/mfi_tty_log X%%PORTDOCS%%%%DOCSDIR%%/readme.txt X%%PORTDOCS%%%%DOCSDIR%%/README-status-mfi-raid.txt X%%PORTDOCS%%@dirrm %%DOCSDIR%% X@dirrmtry etc/periodic/daily X@dirrmtry etc/periodic END-of-linux-megacli2/pkg-plist exit >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811131702.mADH2soL010755>