Frequently Asked Questions

Question
Raid monitor в FreeBSD

Answer
Мониторинг рейдов на FreeBSD умолчально отсутствует, если вы не используете родные пакеты от производителя, с его сайта или диска. Но вот такое бывает довольно редко, посему вот отсюда я взял список умных слов:

FreeBSD gmirror software raid 2 скрипта:

#!/bin/sh
#==============================================================================
# Copyright (c) 2007, Netstream AG# Author: Nico Schottelius <nico-freebsd-raid-monitoring <at> schottelius.org># Created: 2007-04-23
# Description: Display state of all gmirror devices# Created-by: /home/user/nico/firmen/netstream/sh/neues_skript.sh
#==============================================================================
gmirror list | \
   awk -F: 'BEGIN { print "gmirror devices";
                    print "---------------";
                  }
            /^Geom name:/ {
               name=$2            }
            /^State:/ {
               print name ":" $2
            }'


И для крона:

#!/bin/sh
#==============================================================================
# Copyright (c) 2007, Netstream AG# Author: Nico Schottelius schottelius.org># Created: 2007-04-23# Description: Report broken devices.# Created-By: /home/user/nico/firmen/netstream/sh/neues_skript.sh
#==============================================================================
check=$(dirname $0)/cfs_gmirror.sh
# Skip first two lines: header
"$check" | awk -F": " 'BEGIN { getline; getline } $2 !~ /COMPLETE/ { print $1 ":" $2 }'


LSI / Symbios Megaraid (amr driver):

Используется 2 утилиты, megarc (закрыт в портах по брокен) и amrstat (sysutils/amrstat)
Скрипт для amrstat не нужен, оно само при запуске выдает все интересующие данные, по второй есть 2 скрипта:

#!/bin/sh -f
#
# Check status of RAID volumes on amr(4) controllers using the LSI MegaRC
# utility. If any logical drive has a status other than OPTIMAL, or any
# physical disks has a status other that ONLINE, display the full status
# for the adapter. If more than one adapter exists, add additional unit
# numbers to $adapters.
#
# $Id$
#

adapters="0"

for adapter in $adapters; do
status=`/usr/local/sbin/megarc -ldinfo -a${ adapter } -Lall -nolog |\
/usr/bin/sed '1,$s/
//' |\
/usr/bin/sed '1,/Information Of Logical Drive/d'` ||\
echo "Failed to get RAID status for AMR adapter ${ adapter }"

echo "${ status }" |\
/usr/bin/egrep '^ Logical Drive : .*: Status: .*$' |\
/usr/bin/egrep -qv 'OPTIMAL$'
drives=$?

echo "${ status }" |\
/usr/bin/egrep '^ [0-9]+' |\
/usr/bin/egrep -qv 'ONLINE$'
disks=$?

if [ ${ drives } -ne 1 -o ${ disks } -ne 1 ]; then
echo ""
echo "AMR RAID status (adapter ${ adapter }):"
echo "${ status }"
fi
done



#!/bin/sh -f
#
# Display status of RAID volumes on amr(4) controllers using the LSI MegaRC
# utility. If more than one adapter exists, add additional unit numbers to
# $adapters.
#
# $Id$
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]; then
. /etc/defaults/periodic.conf
source_periodic_confs
fi

adapters="0"

rc=0
case "${ daily_amr_status_enable:-YES }" in
[Nn][Oo])
;;
*)
for adapter in $adapters; do
echo ""
echo "AMR RAID status (adapter ${ adapter }):"
/usr/local/sbin/megarc -ldinfo -a${ adapter } -Lall -nolog |\
sed '1,/Information Of Logical Drive/d' || rc=$?
done
;;
esac

exit "$rc"


В оригинале присутствует напоминание, что копирование из внешних источников напрямую в файл скрипта на фрях может вызвать установку в конце каждой строки ^M, которую надо убрать, иначе это будет мешать правильной работе скрипта. Вообще-то это надо бы знать задолго до того как займетесь скриптами вообще...

mpt

В оригинальной ссылке написано что поддержки в FreeBSD для этого типа нет, а в линухах это проделывается посредством утилки mpt-status или модуля ядра mptctl. Ну посмотрите, если у вас такой рейд, может поддержка и появилась. Ключевые слова я дал.

ciss

Известные утилиты: camcontrol и hpacucli
По hpacucli идет отправка на сайт, где предлагается и выпасаться дальше, camcontrol описан тут и работает сам по себе командной строкой.

3ware raid: twa/twe

Идете в порты в sysutils/3dm, ставите эту штуку и обнаруживаете что у нее вполне себе веб интерфейс, емейлы и всетакоепрочее. Вполне самодостаточная софтинка.

ataraid

Это драйвер для множества типов рейдов, создает девайсы ar и скрипт к нему вот такой:

#!/bin/sh

# raid_status - check the state of the RAID.

# This script works for various types of RAID devices. (Currently, 3Ware,
# gmirror, BSd 'ar0' raids, zpool)
# WARNING: Install the proper CLI program for your 3ware card, if you use 3ware.

# Set up a cronjob like this:
# */16 * * * * /home/rudy/bin/raid_status CRON

### Copyright (c) 2006, Rudy Rucker All rights reserved.
### Redistribution and use of script, with or without modification, is
### permitted provided that the following condition is met:
### Redistributions of source code must retain the above copyright
### notice, this list of conditions and the following disclaimer.
### THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
### ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
### ARE DISCLAIMED.

# ----------- Change Log ------------
# Mon Oct 11 15:20:37 PDT 2004 - rudy
# Original script.
# Tue Feb 7 01:28:07 PST 2006 - rudy
# Added 9500 and 9550 support
# Fri Jun 9 10:38:33 PDT 2006 - rudy
# works for 'ar' and 'tw' mirrored arrays
# Tue Sep 12 10:23:13 PDT 2006 - rudy
# Added gmirror and realized that not all 3ware's are the same...
# Fri Jan 18 00:46:13 PST 2008 - rudy
# going to add support for multiple geom mirrors. gm0s1, gm0s2, etc...
# Fri Jan 18 01:03:25 PST 2008 - rudy
# added zpool status checking. untested
# Fri Jan 18 01:23:54 PST 2008
# can check machines with multiple array types... got zfs and gmirror?
# tested a machine with zfs and gmirror
# ---------------------------------------------------------------------

MODE=$1

TWCLI="/usr/local/bin/tw_cli"
GMIRROR="/sbin/gmirror"
ATACONTROL="/sbin/atacontrol"

AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
MAIL="/usr/bin/mail"
SORT="/usr/bin/sort"
ZPOOL="/sbin/zpool"

EMAIL="noc@example.com"

STATUS="none_tested"

report_status () {
# Okay, we checked the raid status and know what the return code should be.
if [ "$STATUS" = "$VALID" ]; then
if [ "$MODE" != "CRON" ]; then
echo "OK condition";
$ESTATUS_CMD
echo
fi
else
# ERROR! Either print to TTY or send an email, based on MODE (which is arg[1])
if [ "$MODE" = "CRON" ]; then
$ESTATUS_CMD | $MAIL -s "[ERROR] Raid array on $HOST returned $STATUS" $EMAIL
else
echo "ERROR condition"
$ESTATUS_CMD
fi
fi
STATUS="UNKNOWN"
}

# if this is not a 3ware card, check the atacontol
if [ -c /dev/twed0 ] && [ -x $TWCLI ]; then
# Tested: 3ware card ... 8000 series
STATUS=`$TWCLI info c0 u0 | $GREP "^Status" | $AWK { 'print $2' }`;
VALID='OK'
ESTATUS_CMD="$TWCLI info c0 u0";
# double check the 3ware output incase it returned nada...
# Umm... this is the only raid card I have witness this bug
if [ "X$STATUS" = "X" ]; then
sleep 1;
STATUS=`$TWCLI info c0 u0 | $GREP "^Status" | $AWK { 'print $2' }`;
fi
report_status
elif [ -c /dev/da0 ] && [ -x $TWCLI ]; then
# Note, there are plenty of other device names that use da0...
# if you have the TWCLI installed, assume da0 is a RAID.
# Tested: 3ware 9550SX, 9500S, 9650
STATUS=`$TWCLI info c0 | $GREP "^u0" | $AWK '{ print $3 }'`;
VALID='OK'
ESTATUS_CMD="$TWCLI info c0 u0"
report_status
fi
if [ -d /dev/mirror ] && [ -x $GMIRROR ]; then
# gmirror /dev/mirror/gm0 gm0s1 gm0s2 etc...
# the 'sort -u' allows this to test multiple arrays. Neat hack.
STATUS=`$GMIRROR status | $GREP "^mirror" | $AWK { 'print $2' } | $SORT -u`;
VALID='COMPLETE'
ESTATUS_CMD="$GMIRROR list";
report_status
fi
if [ -c /dev/ar0 ] && [ -x $ATACONTROL ]; then
# Motherboard promise and others
STATUS=`$ATACONTROL status ar0 | $GREP "status" | $AWK -F 'status: ' '{ print $2 }'`;
VALID='READY'
ESTATUS_CMD="/sbin/atacontrol status ar0"
report_status
fi
if [ -c /dev/zfs ] && [ -x $ZPOOL ]; then
# Tested: zpool mirror on FreeBSD 7.0
STATUS=`$ZPOOL status -x`;
VALID='all pools are healthy'
ESTATUS_CMD="$ZPOOL status -v";
report_status
fi
if [ "$STATUS" = "none_tested" ]; then
echo "Unknown Raid type.... ";
if [ -x $TWCLI ]; then
echo " + found $TWCLI";
else
echo " - can't exec $TWCLI";
fi
if [ -x $ATACONTROL ]; then
echo " + found $ATACONTROL";
else
echo " - can't exec $ATACONTROL";
fi
if [ -x $ZPOOL ]; then
echo " + found $ZPOOL";
else
echo " - can't exec $ZPOOL";
fi
if [ -x $GMIRROR ]; then
echo " + found $GMIRROR";
else
echo " - can't exec $GMIRROR";
fi
exit;
fi



Areca: arcmsr

Эта штука имеет свой RG45 порт по мнению автора статьи и не может мониториться никак, кроме закрытого софта, который выкачивается с http://areca.com

asr

Мониторинг осуществляется при помощи asr-utils которые находятся на фрешпортах вот тут.

Собственно, по той статье и все, мне пока было тоже достаточно перечисленного списка.


Details
Info Sunday 14 March 2010 - 16:44:40 by




Vampyr`s House!


Protected by Copyscape DMCA Plagiarism Check