#!/bin/sh # a script to setup MPT status monitoring # 2008, Michael Shigorin (mike altlinux org) # NB: tested against a single SAS1068 HBA only warning() { echo $0: $* >&2; } error() { warning $*; exit 1; } [ -d /proc/scsi/mptspi/ -o -d /proc/scsi/mptsas/ ] || \ error "you don't seem to have MPT-based RAID controller available" echo "Setting up MPT status monitoring..." lsmod | grep -q ^mptctl || modprobe mptctl [ -f /etc/modules ] && { grep -q ^mptctl /etc/modules || echo mptctl >> /etc/modules } DEVICE_ID="`mpt-status -p | sed -n 's/^Found SCSI id=\([0-9]\+\).*$/\1/p'`" || \ error "mpt-status -p failed, please check by hand" CONFIG="/etc/sysconfig/mpt-status" MPT_ID= MPT_ARGS= MAILTO= touch "$CONFIG" . "$CONFIG" [ -n "$DEVICE_ID" ] || error "No device id detected" [ -n "$MPT_ID" ] && { [ "$MPT_ID" = "$DEVICE_ID" ] || { warning "MPT_ID in /etc/sysconfig/mpt-status differs from mpt-status report;" warning "not touching anything" } # otherwise it's already there and the same } || { echo "Writing device id: $DEVICE_ID to $CONFIG" echo "MPT_ID=$DEVICE_ID" >> "$CONFIG" } # enable monitoring cronjob unless specifically disabled [ -n "$MAILTO" ] || echo 'MAILTO="root@localhost"' >> "$CONFIG"