mirror of
https://github.com/eLvErDe/hwraid.git
synced 2025-07-27 07:44:01 +02:00
Import megaraid-status
This commit is contained in:
parent
977a77db2e
commit
3b886908f1
26
packaging/debian/megaraid-status/README.Debian
Normal file
26
packaging/debian/megaraid-status/README.Debian
Normal file
@ -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) <gandalf@le-vert.net> Mon, 24 Sep 2007 15:55:09 +0200
|
66
packaging/debian/megaraid-status/changelog
Normal file
66
packaging/debian/megaraid-status/changelog
Normal file
@ -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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> 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) <gandalf@le-vert.net> Tue, 09 Oct 2007 16:50:53 +0200
|
||||||
|
|
||||||
|
megaraid-status (0.2) unstable; urgency=low
|
||||||
|
|
||||||
|
* Improve regex.
|
||||||
|
|
||||||
|
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Wed, 26 Sep 2007 18:09:01 +0200
|
||||||
|
|
||||||
|
megaraid-status (0.1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initial release.
|
||||||
|
|
||||||
|
-- Adam Cécile (Le_Vert) <gandalf@le-vert.net> Mon, 24 Sep 2007 15:55:09 +0200
|
1
packaging/debian/megaraid-status/compat
Normal file
1
packaging/debian/megaraid-status/compat
Normal file
@ -0,0 +1 @@
|
|||||||
|
5
|
14
packaging/debian/megaraid-status/control
Normal file
14
packaging/debian/megaraid-status/control
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Source: megaraid-status
|
||||||
|
Section: admin
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
|
||||||
|
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.
|
26
packaging/debian/megaraid-status/copyright
Normal file
26
packaging/debian/megaraid-status/copyright
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
This package was debianized by Adam Cécile (Le_Vert) <gandalf@le-vert.net> 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) <gandalf@le-vert.net>
|
||||||
|
|
||||||
|
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 <white@debian.org> works done
|
||||||
|
for the mpt-status package.
|
||||||
|
Thanks a lot Steffen!
|
1
packaging/debian/megaraid-status/dirs
Normal file
1
packaging/debian/megaraid-status/dirs
Normal file
@ -0,0 +1 @@
|
|||||||
|
usr/sbin
|
2
packaging/debian/megaraid-status/install
Normal file
2
packaging/debian/megaraid-status/install
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
megaraid-status usr/sbin
|
||||||
|
megaraidsas-status usr/sbin
|
@ -0,0 +1,194 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Author: Petter Reinholdtsen <pere@hungry.com>
|
||||||
|
# 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 <<EOF
|
||||||
|
This is a RAID status update from megaraid-statusd. The megaraid-status
|
||||||
|
program reports that one of the RAIDs changed state:
|
||||||
|
|
||||||
|
EOF
|
||||||
|
if [ -f $STATUSFILE ] ; then
|
||||||
|
cat $STATUSFILE
|
||||||
|
else
|
||||||
|
(megaraid-status)
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
echo "Report from $0 on $hostname"
|
||||||
|
) | mail -s "info: MegaRAID raid status change on $hostname" $MAILTO
|
||||||
|
fi
|
||||||
|
sleep $PERIOD
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_daemon() {
|
||||||
|
# Let's check if there is a daemon which is really running and not timing out
|
||||||
|
DAEMON_RUN=`ps aux | grep "/etc/init.d/megaraid-statusd check_megaraid" | grep -v grep | grep -v daemon`
|
||||||
|
if [ -n "$DAEMON_RUN" ] ; then
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Function that starts the daemon/service.
|
||||||
|
#
|
||||||
|
d_start() {
|
||||||
|
[ -f $PIDFILE ] && PID="`cat $PIDFILE`"
|
||||||
|
if [ "$PID" ] ; then
|
||||||
|
log_progress_msg "Daemon already running. Refusing to start another"
|
||||||
|
return 0
|
||||||
|
elif check_daemon ; then
|
||||||
|
# Use the daemon package to turn this script into a daemon
|
||||||
|
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
||||||
|
--oknodo --exec /usr/bin/daemon /usr/bin/daemon $SCRIPTNAME check_megaraid
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log_progress_msg "Daemon is already running. Refusing to start another"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Function that stops the daemon/service.
|
||||||
|
#
|
||||||
|
d_stop() {
|
||||||
|
if [ -f $PIDFILE ] ; then
|
||||||
|
start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE > /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
|
@ -0,0 +1,194 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Author: Petter Reinholdtsen <pere@hungry.com>
|
||||||
|
# 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 <<EOF
|
||||||
|
This is a RAID status update from megaraidsas-statusd. The megaraidsas-status
|
||||||
|
program reports that one of the RAIDs changed state:
|
||||||
|
|
||||||
|
EOF
|
||||||
|
if [ -f $STATUSFILE ] ; then
|
||||||
|
cat $STATUSFILE
|
||||||
|
else
|
||||||
|
(megaraidsas-status)
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
echo "Report from $0 on $hostname"
|
||||||
|
) | mail -s "info: MegaRAID raid status change on $hostname" $MAILTO
|
||||||
|
fi
|
||||||
|
sleep $PERIOD
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_daemon() {
|
||||||
|
# Let's check if there is a daemon which is really running and not timing out
|
||||||
|
DAEMON_RUN=`ps aux | grep "/etc/init.d/megaraidsas-statusd check_megaraidsas" | grep -v grep | grep -v daemon`
|
||||||
|
if [ -n "$DAEMON_RUN" ] ; then
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Function that starts the daemon/service.
|
||||||
|
#
|
||||||
|
d_start() {
|
||||||
|
[ -f $PIDFILE ] && PID="`cat $PIDFILE`"
|
||||||
|
if [ "$PID" ] ; then
|
||||||
|
log_progress_msg "Daemon already running. Refusing to start another"
|
||||||
|
return 0
|
||||||
|
elif check_daemon ; then
|
||||||
|
# Use the daemon package to turn this script into a daemon
|
||||||
|
start-stop-daemon --start --quiet --pidfile $PIDFILE \
|
||||||
|
--oknodo --exec /usr/bin/daemon /usr/bin/daemon $SCRIPTNAME check_megaraidsas
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log_progress_msg "Daemon is already running. Refusing to start another"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Function that stops the daemon/service.
|
||||||
|
#
|
||||||
|
d_stop() {
|
||||||
|
if [ -f $PIDFILE ] ; then
|
||||||
|
start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE > /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
|
41
packaging/debian/megaraid-status/rules
Executable file
41
packaging/debian/megaraid-status/rules
Executable file
@ -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
|
105
wrapper-scripts/megaraid-status
Normal file
105
wrapper-scripts/megaraid-status
Normal file
@ -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)
|
105
wrapper-scripts/megaraidsas-status
Normal file
105
wrapper-scripts/megaraidsas-status
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user