From 3b886908f1d0d2a543bf6afc2f067389a573801c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20C=C3=A9cile=20=28Le=5FVert=29?= Date: Wed, 14 Aug 2013 23:03:24 +0200 Subject: [PATCH] Import megaraid-status --- .../debian/megaraid-status/README.Debian | 26 +++ packaging/debian/megaraid-status/changelog | 66 ++++++ packaging/debian/megaraid-status/compat | 1 + packaging/debian/megaraid-status/control | 14 ++ packaging/debian/megaraid-status/copyright | 26 +++ packaging/debian/megaraid-status/dirs | 1 + packaging/debian/megaraid-status/install | 2 + .../megaraid-status.megaraid-statusd.init | 194 ++++++++++++++++++ .../megaraid-status.megaraidsas-statusd.init | 194 ++++++++++++++++++ packaging/debian/megaraid-status/rules | 41 ++++ wrapper-scripts/megaraid-status | 105 ++++++++++ wrapper-scripts/megaraidsas-status | 105 ++++++++++ 12 files changed, 775 insertions(+) create mode 100644 packaging/debian/megaraid-status/README.Debian create mode 100644 packaging/debian/megaraid-status/changelog create mode 100644 packaging/debian/megaraid-status/compat create mode 100644 packaging/debian/megaraid-status/control create mode 100644 packaging/debian/megaraid-status/copyright create mode 100644 packaging/debian/megaraid-status/dirs create mode 100644 packaging/debian/megaraid-status/install create mode 100644 packaging/debian/megaraid-status/megaraid-status.megaraid-statusd.init create mode 100644 packaging/debian/megaraid-status/megaraid-status.megaraidsas-statusd.init create mode 100755 packaging/debian/megaraid-status/rules create mode 100644 wrapper-scripts/megaraid-status create mode 100644 wrapper-scripts/megaraidsas-status diff --git a/packaging/debian/megaraid-status/README.Debian b/packaging/debian/megaraid-status/README.Debian new file mode 100644 index 0000000..1f0b48a --- /dev/null +++ b/packaging/debian/megaraid-status/README.Debian @@ -0,0 +1,26 @@ +README.Debian for aacraid-status package +---------------------------------------- + +Before you can use the aacraid-status tool you have to make sure that the +/dev/afa0 device node exists. + +Possible configuration: +---------------------- + +If you want to change the default configuration of the init script you +can create the file /etc/default/aacraid-statusd and specify the following +values. + +MAILTO= +PERIOD= +REMIND= + +Use MAILTO to specify which user shall get the status mails +(default is root). + +With PERIOD you can fix the seconds between each check. + +And REMIND specifies the seconds between each reminder. + + + -- Adam Cécile (Le_Vert) Mon, 24 Sep 2007 15:55:09 +0200 diff --git a/packaging/debian/megaraid-status/changelog b/packaging/debian/megaraid-status/changelog new file mode 100644 index 0000000..d2cfcf9 --- /dev/null +++ b/packaging/debian/megaraid-status/changelog @@ -0,0 +1,66 @@ +megaraid-status (0.10) unstable; urgency=low + + * Update initscript from mpt-status 1.2.0-7 package (Closes: #79). + * Hardcode binary path and exit with error if unavailable (Closes: #16). + + -- Adam Cécile (Le_Vert) Wed, 22 Feb 2012 22:12:56 +0100 + +megaraid-status (0.9) unstable; urgency=low + + * Do not fail with HotSpare disks. + + -- Adam Cécile (Le_Vert) Mon, 16 Aug 2010 10:35:39 +0200 + +megaraid-status (0.8) unstable; urgency=low + + * Fix megaraid initscript card detection for recent kernels. + + -- Adam Cécile (Le_Vert) Mon, 20 Apr 2009 15:25:24 +0200 + +megaraid-status (0.7) unstable; urgency=low + + * Fix parsing issues with disk vendor/model containing spaces. + * Now display SMART warnings coming from the disk. + * Most of the output parser has been re-written to be more robust. + + -- Adam Cécile (Le_Vert) Fri, 10 Oct 2008 10:54:56 +0200 + +megaraid-status (0.6) unstable; urgency=low + + * All adapter/logical/physical IDs should are now handled as [0-9]+ + instead of [0-9]. + + -- Adam Cécile (Le_Vert) Thu, 09 Oct 2008 10:04:29 +0200 + +megaraid-status (0.5) unstable; urgency=low + + * Initscripts shouldn't rely on device nodes. Use /proc/devices to check + available cards instead. + + -- Adam Cécile (Le_Vert) Fri, 22 Aug 2008 13:55:05 +0200 + +megaraid-status (0.4) unstable; urgency=low + + * Packaging cleanup. + * Don't use custom runlevel priority anymore, thanks to megactl packaging + improvment. + + -- Adam Cécile (Le_Vert) Thu, 21 Aug 2008 15:32:11 +0200 + +megaraid-status (0.3) unstable; urgency=low + + * Return 1 if something wrong is detected. + + -- Adam Cécile (Le_Vert) Tue, 09 Oct 2007 16:50:53 +0200 + +megaraid-status (0.2) unstable; urgency=low + + * Improve regex. + + -- Adam Cécile (Le_Vert) Wed, 26 Sep 2007 18:09:01 +0200 + +megaraid-status (0.1) unstable; urgency=low + + * Initial release. + + -- Adam Cécile (Le_Vert) Mon, 24 Sep 2007 15:55:09 +0200 diff --git a/packaging/debian/megaraid-status/compat b/packaging/debian/megaraid-status/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/packaging/debian/megaraid-status/compat @@ -0,0 +1 @@ +5 diff --git a/packaging/debian/megaraid-status/control b/packaging/debian/megaraid-status/control new file mode 100644 index 0000000..c8db806 --- /dev/null +++ b/packaging/debian/megaraid-status/control @@ -0,0 +1,14 @@ +Source: megaraid-status +Section: admin +Priority: optional +Maintainer: Adam Cécile (Le_Vert) +Build-Depends: debhelper (>= 5) +Standards-Version: 3.9.2 + +Package: megaraid-status +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, python, lsb-base, daemon, bsd-mailx | mailx, megactl +Description: get RAID status out of LSI MegaRAID SCSI/SAS HW RAID controllers + The megaraid-status software is a query tool to access the running + configuration and status of LSI MegaRAID SCSI/SAS HBAs. aacraid-status allows + you to monitor the health and status of your RAID setup. diff --git a/packaging/debian/megaraid-status/copyright b/packaging/debian/megaraid-status/copyright new file mode 100644 index 0000000..079d2ee --- /dev/null +++ b/packaging/debian/megaraid-status/copyright @@ -0,0 +1,26 @@ +This package was debianized by Adam Cécile (Le_Vert) on +Mon, 24 Sep 2007 15:55:09 +0200. + +It was downloaded from http://hwraid.le-vert.net + +Copyright Holder: + + Copyright (C) 2007-2012 Adam Cécile (Le_Vert) + +License: + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License, version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANDABILITY of FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for details. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL-2'. + +This package is highly based on Steffen Joeris works done +for the mpt-status package. +Thanks a lot Steffen! diff --git a/packaging/debian/megaraid-status/dirs b/packaging/debian/megaraid-status/dirs new file mode 100644 index 0000000..236670a --- /dev/null +++ b/packaging/debian/megaraid-status/dirs @@ -0,0 +1 @@ +usr/sbin diff --git a/packaging/debian/megaraid-status/install b/packaging/debian/megaraid-status/install new file mode 100644 index 0000000..7c9bd83 --- /dev/null +++ b/packaging/debian/megaraid-status/install @@ -0,0 +1,2 @@ +megaraid-status usr/sbin +megaraidsas-status usr/sbin diff --git a/packaging/debian/megaraid-status/megaraid-status.megaraid-statusd.init b/packaging/debian/megaraid-status/megaraid-status.megaraid-statusd.init new file mode 100644 index 0000000..252f6e4 --- /dev/null +++ b/packaging/debian/megaraid-status/megaraid-status.megaraid-statusd.init @@ -0,0 +1,194 @@ +#! /bin/sh + +# Author: Petter Reinholdtsen +# License: GNU General Public License v2 or later +# +### BEGIN INIT INFO +# Provides: megaraid-statusd +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Check megaraid-status values in the background. +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DESC="megaraid-status monitor" +NAME=megaraid-statusd +PIDFILE=/var/run/$NAME.pid +STATUSFILE=/var/run/$NAME.status +SCRIPTNAME=/etc/init.d/$NAME + + +# Do not touch you can configure this in /etc/default/megaraid-statusd +MAILTO=root # Where to report problems +PERIOD=600 # Seconds between each check (default 10 minutes) +REMIND=7200 # Seconds between each reminder (default 2 hours) +RUN_DAEMON=yes + +[ -e /etc/default/megaraid-statusd ] && . /etc/default/megaraid-statusd + +# Gracefully exit if the package has been removed. +test -x /usr/sbin/megaraid-status || exit 0 + +# Exit if we can't find a loaded megaraid card +(grep -q 'megadev$' /proc/devices || test -e /dev/megadev0) || exit 0 + +. /lib/lsb/init-functions +[ -e /etc/default/rcS ] && . /etc/default/rcS + +if [ $RUN_DAEMON = "no" ] ; then + log_begin_msg "megaraid-statusd is disabled in /etc/default/megaraid-statusd, not starting." + log_end_msg 0 + exit 0 +fi + +check_megaraid() { + echo $$ > $PIDFILE.new && mv $PIDFILE.new $PIDFILE + while true ; do + # Check ever $PERIOD seconds, send email on every status + # change and repeat ever $REMIND seconds if the raid is still + # bad. + if (megaraid-status) |grep -q 'NOT OPTIMAL' ; then + BADRAID=true + logger -t megaraid-statusd "detected non-optimal RAID status" + else + BADRAID=false + fi + STATUSCHANGE=false + if [ true = "$BADRAID" ] ; then + # RAID not OK + (megaraid-status) > $STATUSFILE.new + if [ ! -f $STATUSFILE ] ; then # RAID just became broken + STATUSCHANGE=true + mv $STATUSFILE.new $STATUSFILE + elif cmp -s $STATUSFILE $STATUSFILE.new ; then + # No change. Should we send reminder? + LASTTIME="`stat -c '%Z' $STATUSFILE`" + NOW="`date +%s`" + SINCELAST="`expr $NOW - $LASTTIME`" + if [ $REMIND -le "$SINCELAST" ]; then + # Time to send reminder + STATUSCHANGE=true + mv $STATUSFILE.new $STATUSFILE + else + rm $STATUSFILE.new + fi + else + STATUSCHANGE=true + mv $STATUSFILE.new $STATUSFILE + fi + else + # RAID OK + if [ -f $STATUSFILE ] ; then + rm $STATUSFILE + STATUSCHANGE=true + fi + fi + + if [ true = "$STATUSCHANGE" ]; then + hostname="`uname -n`" + ( + cat < /dev/null 2>&1 + rm -f $PIDFILE + else + log_progress_msg "Daemon is already stopped." + return 0 + fi +} + +# This is a workaround function which does not directly exit and +# therefore can be used by a restart +d_stop_by_restart() { + if [ -f $PIDFILE ] ; then + start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE + rm -f $PIDFILE + log_end_msg 0 + else + log_progress_msg "Daemon is already stopped." + log_end_msg 0 + fi +} + +case "$1" in + start) + echo -n "" + log_begin_msg "Starting $DESC: $NAME" + d_start ; CODE=$? + log_end_msg $CODE + ;; + stop) + log_begin_msg "Stopping $DESC: $NAME" + d_stop ; CODE=$? + log_end_msg $CODE + ;; + check_megaraid) + check_megaraid + ;; + restart|force-reload) + log_begin_msg "Restarting $DESC: $NAME" + d_stop_by_restart + sleep 1 + d_start || CODE=$? + log_end_msg $CODE + ;; + *) + # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/packaging/debian/megaraid-status/megaraid-status.megaraidsas-statusd.init b/packaging/debian/megaraid-status/megaraid-status.megaraidsas-statusd.init new file mode 100644 index 0000000..9e53d7d --- /dev/null +++ b/packaging/debian/megaraid-status/megaraid-status.megaraidsas-statusd.init @@ -0,0 +1,194 @@ +#! /bin/sh + +# Author: Petter Reinholdtsen +# License: GNU General Public License v2 or later +# +### BEGIN INIT INFO +# Provides: megaraidsas-statusd +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Check megaraidsas-status values in the background. +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DESC="megaraidsas-status monitor" +NAME=megaraidsas-statusd +PIDFILE=/var/run/$NAME.pid +STATUSFILE=/var/run/$NAME.status +SCRIPTNAME=/etc/init.d/$NAME + + +# Do not touch you can configure this in /etc/default/megaraidsas-statusd +MAILTO=root # Where to report problems +PERIOD=600 # Seconds between each check (default 10 minutes) +REMIND=7200 # Seconds between each reminder (default 2 hours) +RUN_DAEMON=yes + +[ -e /etc/default/megaraidsas-statusd ] && . /etc/default/megaraidsas-statusd + +# Gracefully exit if the package has been removed. +test -x /usr/sbin/megaraidsas-status || exit 0 + +# Exit if we can't find a loaded megaraidsas card +grep -q 'megaraid_sas_ioctl$' /proc/devices || exit 0 + +. /lib/lsb/init-functions +[ -e /etc/default/rcS ] && . /etc/default/rcS + +if [ $RUN_DAEMON = "no" ] ; then + log_begin_msg "megaraidsas-statusd is disabled in /etc/default/megaraidsas-statusd, not starting." + log_end_msg 0 + exit 0 +fi + +check_megaraidsas() { + echo $$ > $PIDFILE.new && mv $PIDFILE.new $PIDFILE + while true ; do + # Check ever $PERIOD seconds, send email on every status + # change and repeat ever $REMIND seconds if the raid is still + # bad. + if (megaraidsas-status) |grep -q 'NOT OPTIMAL' ; then + BADRAID=true + logger -t megaraidsas-statusd "detected non-optimal RAID status" + else + BADRAID=false + fi + STATUSCHANGE=false + if [ true = "$BADRAID" ] ; then + # RAID not OK + (megaraidsas-status) > $STATUSFILE.new + if [ ! -f $STATUSFILE ] ; then # RAID just became broken + STATUSCHANGE=true + mv $STATUSFILE.new $STATUSFILE + elif cmp -s $STATUSFILE $STATUSFILE.new ; then + # No change. Should we send reminder? + LASTTIME="`stat -c '%Z' $STATUSFILE`" + NOW="`date +%s`" + SINCELAST="`expr $NOW - $LASTTIME`" + if [ $REMIND -le "$SINCELAST" ]; then + # Time to send reminder + STATUSCHANGE=true + mv $STATUSFILE.new $STATUSFILE + else + rm $STATUSFILE.new + fi + else + STATUSCHANGE=true + mv $STATUSFILE.new $STATUSFILE + fi + else + # RAID OK + if [ -f $STATUSFILE ] ; then + rm $STATUSFILE + STATUSCHANGE=true + fi + fi + + if [ true = "$STATUSCHANGE" ]; then + hostname="`uname -n`" + ( + cat < /dev/null 2>&1 + rm -f $PIDFILE + else + log_progress_msg "Daemon is already stopped." + return 0 + fi +} + +# This is a workaround function which does not directly exit and +# therefore can be used by a restart +d_stop_by_restart() { + if [ -f $PIDFILE ] ; then + start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE + rm -f $PIDFILE + log_end_msg 0 + else + log_progress_msg "Daemon is already stopped." + log_end_msg 0 + fi +} + +case "$1" in + start) + echo -n "" + log_begin_msg "Starting $DESC: $NAME" + d_start ; CODE=$? + log_end_msg $CODE + ;; + stop) + log_begin_msg "Stopping $DESC: $NAME" + d_stop ; CODE=$? + log_end_msg $CODE + ;; + check_megaraidsas) + check_megaraidsas + ;; + restart|force-reload) + log_begin_msg "Restarting $DESC: $NAME" + d_stop_by_restart + sleep 1 + d_start || CODE=$? + log_end_msg $CODE + ;; + *) + # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/packaging/debian/megaraid-status/rules b/packaging/debian/megaraid-status/rules new file mode 100755 index 0000000..661db13 --- /dev/null +++ b/packaging/debian/megaraid-status/rules @@ -0,0 +1,41 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-indep build-arch +build-indep: +build-arch: + +clean: + dh_testdir + dh_testroot + dh_clean + +install: + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + +binary-arch: build install +binary-indep: build install + dh_testdir -i + dh_testroot -i + dh_installchangelogs -i + dh_installdocs -i + dh_install -i + dh_installinit -i --name megaraid-statusd + dh_installinit -i --name megaraidsas-statusd + dh_link -i + dh_strip -i + dh_compress -i + dh_fixperms -i + dh_installdeb -i + dh_shlibdeps -i + dh_gencontrol -i + dh_md5sums -i + dh_builddeb -i + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/wrapper-scripts/megaraid-status b/wrapper-scripts/megaraid-status new file mode 100644 index 0000000..c98dcb3 --- /dev/null +++ b/wrapper-scripts/megaraid-status @@ -0,0 +1,105 @@ +#!/usr/bin/python + +import os +import re +import sys + +binarypath = "/usr/sbin/megactl" + +if len(sys.argv) > 2: + print 'Usage: megaraid-status [-d]' + sys.exit(1) + +printarray = True +if len(sys.argv) > 1: + if sys.argv[1] == '-d': + printarray = False + else: + print 'Usage: megaraid-status [-d]' + sys.exit(1) + +# Check binary exists (and +x), if not print an error message +if os.path.exists(binarypath) and os.access(binarypath, os.X_OK): + pass +else: + sys.exit(3) + +# Get command output +def getOutput(cmd): + output = os.popen(cmd) + lines = [] + for line in output: + if not re.match(r'^$',line.strip()): + lines.append(line.strip()) + return lines + +def returnDiskList(output): + lines = [] + for line in output: + if re.match(r'^[a-z][0-9]+[a-z][0-9]+[a-z][0-9]+\s.*$',line.strip()): + list = line.split() + # Let's hack... Some disk may report smart error after status + # Get theses errors, join them into one list item and place it + # before status + errindex = False + try: + errindex = list.index('errs:') + except ValueError: + pass + if errindex: + list.insert(errindex-1, ' '.join(list[errindex:])) + list = list[:errindex+1] + lines.append(list) + if fake_failure: + lines[0][-1] = 'BAD' + return lines + +def returnArrayList(output): + lines = [] + for line in output: + if re.match(r'^[a-z][0-9]+[a-z][0-9]+\s.*$',line.strip()): + lines.append(line.split()) + if fake_failure: + lines[0][-1] = 'DEGRADED' + return lines + +# A way to force a fake failure +fake_failure = False +if os.path.exists('/root/fake_megaraid_failure'): + fake_failure = True + +cmd = binarypath+' -v' +output = getOutput(cmd) +disklist = returnDiskList(output) +arraylist = returnArrayList(output) + +if printarray: + print '-- Arrays informations --' + print '-- ID | Type | Size | Status' + for array in arraylist: + print array[0]+' | '+array[2]+' '+array[3]+' | '+array[1]+' | '+array[-1] + print '' + +print '-- Disks informations' +print '-- ID | Model | Status | Warnings' +for disk in disklist: + # Check if there's some smart non critical warnings + if re.match(r'^errs:.*$', disk[-2]): + # Some disk may have vendor or model containing spaces + print disk[0]+' | '+' '.join(disk[1:-3])+' | '+disk[-1]+' | '+disk[-2] + else: + print disk[0]+' | '+' '.join(disk[1:-2])+' | '+disk[-1] + +# Check if there's a bad disk +bad = False +for array in arraylist: + if not array[-1] == 'optimal': + bad = True + +for disk in disklist: + if not disk[-1] == 'online' and not disk[-1] == 'hotspare': + bad = True + +if bad: + print '\nThere is at least one disk/array in a NOT OPTIMAL state.' + sys.exit(1) diff --git a/wrapper-scripts/megaraidsas-status b/wrapper-scripts/megaraidsas-status new file mode 100644 index 0000000..5e5498b --- /dev/null +++ b/wrapper-scripts/megaraidsas-status @@ -0,0 +1,105 @@ +#!/usr/bin/python + +import os +import re +import sys + +binarypath = "/usr/sbin/megasasctl" + +if len(sys.argv) > 2: + print 'Usage: megaraidsas-status [-d]' + sys.exit(1) + +printarray = True +if len(sys.argv) > 1: + if sys.argv[1] == '-d': + printarray = False + else: + print 'Usage: megaraidsas-status [-d]' + sys.exit(1) + +# Check binary exists (and +x), if not print an error message +if os.path.exists(binarypath) and os.access(binarypath, os.X_OK): + pass +else: + sys.exit(3) + +# Get command output +def getOutput(cmd): + output = os.popen(cmd) + lines = [] + for line in output: + if not re.match(r'^$',line.strip()): + lines.append(line.strip()) + return lines + +def returnDiskList(output): + lines = [] + for line in output: + if re.match(r'^[a-z][0-9]+[a-z][0-9]+[a-z][0-9]+\s.*$',line.strip()): + list = line.split() + # Let's hack... Some disk may report smart error after status + # Get theses errors, join them into one list item and place it + # before status + errindex = False + try: + errindex = list.index('errs:') + except ValueError: + pass + if errindex: + list.insert(errindex-1, ' '.join(list[errindex:])) + list = list[:errindex+1] + lines.append(list) + if fake_failure: + lines[0][-1] = 'BAD' + return lines + +def returnArrayList(output): + lines = [] + for line in output: + if re.match(r'^[a-z][0-9]+[a-z][0-9]+\s.*$',line.strip()): + lines.append(line.split()) + if fake_failure: + lines[0][-1] = 'DEGRADED' + return lines + +# A way to force a fake failure +fake_failure = False +if os.path.exists('/root/fake_megaraid_failure'): + fake_failure = True + +cmd = binarypath+' -v' +output = getOutput(cmd) +disklist = returnDiskList(output) +arraylist = returnArrayList(output) + +if printarray: + print '-- Arrays informations --' + print '-- ID | Type | Size | Status' + for array in arraylist: + print array[0]+' | '+array[2]+' '+array[3]+' | '+array[1]+' | '+array[-1] + print '' + +print '-- Disks informations' +print '-- ID | Model | Status | Warnings' +for disk in disklist: + # Check if there's some smart non critical warnings + if re.match(r'^errs:.*$', disk[-2]): + # Some disk may have vendor or model containing spaces + print disk[0]+' | '+' '.join(disk[1:-3])+' | '+disk[-1]+' | '+disk[-2] + else: + print disk[0]+' | '+' '.join(disk[1:-2])+' | '+disk[-1] + +# Check if there's a bad disk +bad = False +for array in arraylist: + if not array[-1] == 'optimal': + bad = True + +for disk in disklist: + if not disk[-1] == 'online' and not disk[-1] == 'hotspare': + bad = True + +if bad: + print '\nThere is at least one disk/array in a NOT OPTIMAL state.' + sys.exit(1)