Slackware provides all that is needed to create and use RAID arrays (basically, a RAID-enabled kernel and the mdadm(8) tool), but does nothing to monitor the arrays.
Fortunately, the mdadm tool itself provides the monitoring feature, and it’s very easy to benefit from it.
Ensure that the /etc/mdadm.conf
file describes the RAID
array(s) to monitor:
# mdadm --examine --scan > /etc/mdadm.conf
Complete the file with the MAILADDR and MAILFROM fields:
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=... ARRAY /dev/md1 level=raid1 num-devices=2 UUID=... MAILADDR admin@example.com MAILFROM raid monitoring daemon <raid@example.com>
All you have to do next is launch mdadm in monitor mode,
possibly using the following control script
/etc/rc.d/rc.mdadm
:
#!/bin/bash PIDFILE=/var/run/mdadm.pid case "$1" in start) /sbin/mdadm --monitor --scan --syslog --delay=900 --daemonize --pid-file=$PIDFILE --test ;; stop) if [ -f $PIDFILE ]; then kill $(cat $PIDFILE) rm -f $PIDFILE fi ;; restart) $0 stop sleep 1 $0 start :: status) if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE) ; then echo "mdadm is monitoring." else echo "mdadm is stopped." fi ;; *) echo "usage: $0 {start|stop|restart|status}" exit 1 ;; esac
(Refer to mdadm(8) for details on mdadm command-line options.)
Make the control script executable and add the appropriate stanza in
/etc/rc.d/rc.local
to have it executed when the system starts.