#!/bin/bash # # # Copyright Toby Sears 2012 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script to remotely check the status of a raid # - Requires that the server has the "megaclisas-status --nagios" application available # - Requires passwordless login via SSH (key auth) # - Syntax: check_raid HOSTNAME USERNAME # if [ $1 == "-h" ] then echo " Script to remotely check the status of a raid. - Requires that the server has the \"megaclisas-status --nagios\" application available - Requires passwordless login via SSH (key auth) Useage: check_raid [HOSTNAME] [USERNAME] " exit 0 elif [ -z "$1" ] then echo "UNKNOWN: Missing argument HOSTNAME" exit 3 elif [ -z "$2" ] then echo "UNKNOWN: Missing argument USERNAME" exit 3 fi HOST=$1 USER=$2 RAID_STATUS=$(ssh -q $USER@$HOST "sudo megaclisas-status --nagios") if [ -z "$RAID_STATUS" ] then echo "WARNING: megasas-status not responding" exit 1 fi if [[ "$RAID_STATUS" == "RAID OK"* ]] then STATUS="OK: " EX=0 else STATUS="CRITICAL: " EX=2 fi echo "$STATUS $RAID_STATUS" exit $EX