diff --git a/README.rpm.md b/README.rpm.md new file mode 100644 index 0000000..b03fdb9 --- /dev/null +++ b/README.rpm.md @@ -0,0 +1,22 @@ +RPM packages +============ + +Currently RPM packaging is only available for: +- *megaclisas-status* +- *sas2ircu* +- *sas2ircu-status* + +To build execute from the top level directory: +```bash +rpmbuild --define "_sourcedir $PWD" \ + -bb packaging/rpm/megaclisas-status/RPM/SPEC + +# sas2ircu has to be downloaded from: +# https://docs.broadcom.com/docs/SAS2IRCU_P20.zip +unzip SAS2IRCU_P20.zip +rpmbuild --define "_sourcedir $PWD" \ + -bb packaging/rpm/sas2ircu/RPM/SPEC + +rpmbuild --define "_sourcedir $PWD" \ + -bb packaging/rpm/sas2ircu-status/RPM/SPEC +``` diff --git a/packaging/rpm/megaclisas-status/README b/packaging/rpm/megaclisas-status/README new file mode 100644 index 0000000..0979ab6 --- /dev/null +++ b/packaging/rpm/megaclisas-status/README @@ -0,0 +1,23 @@ +README for megaclisas-status package +------------------------------------ + +Possible configuration: +---------------------- + +If you want to change the default configuration of the init script you +can create the file /etc/default/megaclisas-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) Tue, 11 Dec 2007 17:06:56 +0100 diff --git a/packaging/rpm/megaclisas-status/RPM/SPEC b/packaging/rpm/megaclisas-status/RPM/SPEC new file mode 100644 index 0000000..206dc3a --- /dev/null +++ b/packaging/rpm/megaclisas-status/RPM/SPEC @@ -0,0 +1,55 @@ +%define name megaclisas-status +%define version 0.17 +%define release 2 + +%define extradir %{_sourcedir}/packaging/rpm/megaclisas-status + +Name: %{name} +Summary: get RAID status out of LSI MegaRAID SAS HW RAID controllers +Version: %{version} +Release: %{release} +License: GPL +Group: Applications/Internet +BuildArch: noarch +BuildRoot: %{_builddir}/%{name}-root +Distribution: whatever +Vendor: Adam Cécile (Le_Vert) +Packager: wilde@intevation.de +Requires: python, bash, MegaCli, daemonize, mailx +BuildRequires: systemd + +%description +The megacli-status software is a query tool to access the running +configuration and status of LSI MegaRAID SAS HBAs. + +It uses LSI MegaCli proprietary command line tool. + +%prep +exit 0 + +%build +exit 0 + +%install +rm -rf %{buildroot} +install -d %{buildroot}%{_sbindir} +install -d %{buildroot}%{_initddir} +install -d %{buildroot}%{_defaultdocdir}/%{name} + +# main package README +install %{_sourcedir}/wrapper-scripts/megaclisas-status \ + %{buildroot}%{_sbindir} +install %{extradir}/megaclisas-status.megaclisas-statusd.init \ + %{buildroot}%{_initddir}/megaclisas-statusd +install -m 644 %{extradir}/README \ + %{buildroot}%{_defaultdocdir}/%{name} + +%clean +exit 0 + +%files +%{_sbindir}/megaclisas-status +%{_initddir}/megaclisas-statusd +%doc %{_defaultdocdir}/%{name}/README + +# vim: ft=spec: diff --git a/packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init b/packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init new file mode 100644 index 0000000..36802cc --- /dev/null +++ b/packaging/rpm/megaclisas-status/megaclisas-status.megaclisas-statusd.init @@ -0,0 +1,200 @@ +#! /bin/bash + +# Author: Petter Reinholdtsen +# Adapted for CentOS by: Sascha Wilde +# License: GNU General Public License v2 or later +# +# chkconfig: - 50 50 +# description: Check megaclisas-status values in the background. +# config: /etc/default/megaclisas-statusd +# +### BEGIN INIT INFO +# Provides: megaclisas-statusd +# Description: Check megaclisas-status values in the background. +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Check megaclisas-status values in the background. +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DESC="megaclisas-status monitor" +NAME=megaclisas-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/megaclisas-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/megaclisas-statusd ] && . /etc/default/megaclisas-statusd + +# Gracefully exit if the package has been removed. +test -x /usr/sbin/megaclisas-status || exit 0 + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ $RUN_DAEMON = "no" ] ; then + echo >&2 "megaclisas-statusd is disabled in /etc/default/megaclisas-statusd, not starting." + exit 0 +fi + +check_megaclisas() { + 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 (megaclisas-status --notemp); then + BADRAID=false + else + BADRAID=true + logger -t megaclisas-statusd "detected non-optimal RAID status" + fi + STATUSCHANGE=false + if [ true = "$BADRAID" ] ; then + # RAID not OK + (megaclisas-status --notemp) > $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 <&2 "Daemon already running. Refusing to start another" + return 0 + elif check_daemon ; then + # Use the daemon package to turn this script into a daemon + daemon --pidfile $PIDFILE \ + /usr/sbin/daemonize $SCRIPTNAME check_megaclisas + return 0 + else + echo >&2 "Daemon is already running. Refusing to start another" + return 0 + fi +} + +# +# Function that stops the daemon/service. +# +d_stop() { + if [ -f $PIDFILE ] ; then + killproc -p $PIDFILE /usr/sbin/daemonize + rm -f $PIDFILE + else + echo >&2 "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 + killproc -p $PIDFILE /usr/sbin/daemonize + rm -f $PIDFILE + else + echo >&2 "Daemon is already stopped." + fi +} + +case "$1" in + start) + echo -n "" + echo >&2 "Starting $DESC: $NAME" + d_start ; CODE=$? + ;; + stop) + echo >&2 "Stopping $DESC: $NAME" + d_stop ; CODE=$? + ;; + check_megaclisas) + check_megaclisas + ;; + status) + status -p $PIDFILE /usr/sbin/daemonize + exit $? + ;; + restart|force-reload) + echo >&2 "Restarting $DESC: $NAME" + d_stop_by_restart + sleep 1 + d_start || 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/rpm/sas2ircu-status/README b/packaging/rpm/sas2ircu-status/README new file mode 100644 index 0000000..01c262f --- /dev/null +++ b/packaging/rpm/sas2ircu-status/README @@ -0,0 +1,23 @@ +README for sas2ircu-status package +---------------------------------- + +Possible configuration: +---------------------- + +If you want to change the default configuration of the init script you +can create the file /etc/default/sas2ircu-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/rpm/sas2ircu-status/RPM/SPEC b/packaging/rpm/sas2ircu-status/RPM/SPEC new file mode 100644 index 0000000..45ae601 --- /dev/null +++ b/packaging/rpm/sas2ircu-status/RPM/SPEC @@ -0,0 +1,58 @@ +%define name sas2ircu-status +%define version 0.8 +%define release 1 + +%define extradir %{_sourcedir}/packaging/rpm/sas2ircu-status + +Name: %{name} +Summary: get RAID status out of LSI Fusion MPT SAS2 HW RAID controllers +Version: %{version} +Release: %{release} +License: GPL +Group: Applications/Internet +BuildArch: noarch +BuildRoot: %{_builddir}/%{name}-root +Distribution: whatever +Vendor: Adam Cécile (Le_Vert) +Packager: wilde@intevation.de +Requires: python, bash, daemonize, mailx, sas2ircu +BuildRequires: systemd + +%description +The sas2ircu-status software is a query tool to access the running +configuration and status of LSI Fusion MPT SAS2 HBAs. sas2ircu-status allows +you to monitor the health and status of your RAID setup. + +%prep +exit 0 + +%build +exit 0 + +%install +rm -rf %{buildroot} +install -d %{buildroot}%{_sbindir} +install -d %{buildroot}%{_initddir} +install -d %{buildroot}%{_mandir}/man8 +install -d %{buildroot}%{_defaultdocdir}/%{name} + +# main package README +install %{_sourcedir}/wrapper-scripts/sas2ircu-status \ + %{buildroot}%{_sbindir} +install %{extradir}/sas2ircu-status.sas2ircu-statusd.init \ + %{buildroot}%{_initddir}/sas2ircu-statusd +install -m 644 %{extradir}/sas2ircu-status.8 \ + %{buildroot}%{_mandir}/man8 +install -m 644 %{extradir}/README \ + %{buildroot}%{_defaultdocdir}/%{name} + +%clean +exit 0 + +%files +%{_sbindir}/sas2ircu-status +%{_initddir}/sas2ircu-statusd +%doc %{_mandir}/man8/sas2ircu-status.8.gz +%doc %{_defaultdocdir}/%{name}/README + +# vim: ft=spec: diff --git a/packaging/rpm/sas2ircu-status/sas2ircu-status.8 b/packaging/rpm/sas2ircu-status/sas2ircu-status.8 new file mode 100644 index 0000000..92653a9 --- /dev/null +++ b/packaging/rpm/sas2ircu-status/sas2ircu-status.8 @@ -0,0 +1,68 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" (C) Copyright 2013 Adam Cécile (Le_Vert) , +.\" +.TH SAS2IRCU-STATUS 8 "2014-01-26" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +sas2ircu-status \- display RAID status of LSI FusionMPT2 adapters in a human-readable way +.SH SYNOPSIS +.B sas2ircu-status +.RI [ --nagios ] +.SH DESCRIPTION +This wrapper will call LSI proprietary "sas2ircu" command-line tool to display +status of all your +.B disks/arrays connected +to an +.B LSI FusionMPT2 adapter. +.br +It will also run +.B periodic checks +and notify the +.B root user (by mail) +if anything goes wrong. Reminders will be sent every two hours until the +status goes back to normal. +.sp +Here is an output example: +.sp +.br +-- Controller informations -- +.br +-- ID | Model +.br +c0 | SAS2008 +.sp +-- Arrays informations -- +.br +-- ID | Type | Size | Status +.br +c0u0 | RAID1 | 1800G | Okay (OKY) +.sp +-- Disks informations +.br +-- ID | Model | Status +.br +c0u0p0 | Hitachi HUA72202 (JK1151YAHUYAZZ) | Optimal (OPT) +.br +c0u0p1 | Hitachi HUA72202 (JK1151YAHUW1DZ) | Optimal (OPT) +.SH OPTIONS +.TP +.B \-\-nagios +Use nagios compatible output (and return code for OK/WARNING/CRITICAL states) +.sp +Example: +.br +RAID OK - Arrays: OK:1 Bad:0 - Disks: OK:2 Bad:0 +.SH SEE ALSO +More information about this adapters family: +.B http://hwraid.le-vert.net/wiki/LSIFusionMPTSAS2 diff --git a/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init b/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init new file mode 100644 index 0000000..186000b --- /dev/null +++ b/packaging/rpm/sas2ircu-status/sas2ircu-status.sas2ircu-statusd.init @@ -0,0 +1,195 @@ +#! /bin/bash + +# Author: Petter Reinholdtsen +# Adapted for CentOS by: Sascha Wilde +# License: GNU General Public License v2 or later +# +# chkconfig: - 50 50 +# description: Check sas2ircu-status values in the background. +# config: /etc/default/sas2ircu-statusd +# +### BEGIN INIT INFO +# Provides: sas2ircu-statusd +# Description: Check sas2ircu-status values in the background. +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Check sas2ircu-status values in the background. +### END INIT INFO + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +DESC="sas2ircu-status monitor" +NAME=sas2ircu-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/sas2ircu-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/sas2ircu-statusd ] && . /etc/default/sas2ircu-statusd + +# Gracefully exit if the package has been removed. +test -x /usr/sbin/sas2ircu-status || exit 0 + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ $RUN_DAEMON = "no" ] ; then + echo >&2 "sas2ircu-statusd is disabled in /etc/default/sas2ircu-statusd, not starting." + exit 0 +fi + +check_sas2ircu() { + 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 (sas2ircu-status) |grep -q 'NOT OPTIMAL' ; then + BADRAID=true + logger -t sas2ircu-statusd "detected non-optimal RAID status" + else + BADRAID=false + fi + STATUSCHANGE=false + if [ true = "$BADRAID" ] ; then + # RAID not OK + (sas2ircu-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 <&2 "Daemon already running. Refusing to start another" + return 0 + elif check_daemon ; then + # Use the daemon package to turn this script into a daemon + daemon --pidfile $PIDFILE \ + /usr/sbin/daemonize $SCRIPTNAME check_sas2ircu + return 0 + else + echo >&2 "Daemon is already running. Refusing to start another" + return 0 + fi +} + +# +# Function that stops the daemon/service. +# +d_stop() { + if [ -f $PIDFILE ] ; then + killproc -p $PIDFILE /usr/sbin/daemonize + rm -f $PIDFILE + else + echo >&2 "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 + killproc -p $PIDFILE /usr/sbin/daemonize + rm -f $PIDFILE + else + echo >&2 "Daemon is already stopped." + fi +} + +case "$1" in + start) + echo -n "" + echo >&2 "Starting $DESC: $NAME" + d_start ; CODE=$? + ;; + stop) + echo >&2 "Stopping $DESC: $NAME" + d_stop ; CODE=$? + ;; + check_sas2ircu) + check_sas2ircu + ;; + status) + status -p $PIDFILE /usr/sbin/daemonize + exit $? + ;; + restart|force-reload) + echo >&2 "Restarting $DESC: $NAME" + d_stop_by_restart + sleep 1 + d_start || 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/rpm/sas2ircu/RPM/SPEC b/packaging/rpm/sas2ircu/RPM/SPEC new file mode 100644 index 0000000..2216cba --- /dev/null +++ b/packaging/rpm/sas2ircu/RPM/SPEC @@ -0,0 +1,41 @@ +%define name sas2ircu +%define version 20.00.00.00 +%define release 1 + +Name: %{name} +Summary: LSI Logic Fusion MPT SAS2 command line management tool +Version: %{version} +Release: %{release} +License: LSI Corporation, All Rights Reserved. +Group: Applications/Internet +BuildArch: x86_64 +BuildRoot: %{_builddir}/%{name}-root +Distribution: whatever +Vendor: LSI Corporation +Packager: wilde@intevation.de + +%description +Tool to read and setup LSI Logic Fusion MTP SAS2 HW RAID HBAs (mpt2sas +driver). + +%prep +exit 0 + +%build +exit 0 + +%install +rm -rf %{buildroot} +install -d %{buildroot}%{_sbindir} + +# main package +install %{_sourcedir}/SAS2IRCU_P20/sas2ircu_linux_x86_rel/sas2ircu \ + %{buildroot}%{_sbindir} + +%clean +exit 0 + +%files +%{_sbindir}/sas2ircu + +# vim: ft=spec: