Pull to refresh

Мониторинг состояния дисков на контроллерах adaptec через zabbix

Добрый день. Возникла ситуация, когда выпал диск из raid массива. Пришло уведомление от Zabbix о том, что 1 диск выпал, но без пояснения, какой, не очень информативно, пришлось лезть на сервер и смотреть, какой же диск выпал.

Небольшой скрипт на python который парсит вывод arcconf и сопоставляет диск в рейде с реальным диском(позиция на backplane).

#!/usr/bin/python

import os
import re
from subprocess import Popen, PIPE
import json
import sys

stat_file='/etc/adaptec_state.json'

def init():
    array_disks={}
    stream_pd = Popen('/usr/bin/arcconf getconfig 1 pd',shell=True, stdout=PIPE)
    for line in stream_pd.stdout:
        if re.search('Reported Channel', line)!= None:
            channel = line.split(" : ")[1].rstrip()
        if re.search('Reported Location', line)!= None:
            location = line.split(" : ")[1].rstrip().replace(" ",":").replace(",:",", ").replace("(Connector:2)", " ").rstrip(" \n")
            array_disks[location]=channel

    stream_ld = Popen('/usr/bin/arcconf getconfig 1 ld',shell=True, stdout=PIPE)
    array_present={}
    for line in stream_ld.stdout:
        if re.search('Logical Device name',line) != None:
            logical_dev_name = ''.join(line.split(" : ")[1].rsplit())
        if re.search('Segment', line)!= None:
            segment_id,segment_disk = line.split(" : ")
            segment_disk=' '.join(segment_disk.split())
            segments=segment_disk.split(" ")
            if segments[0] == "Present":
                array_present["%s %s"%(logical_dev_name,' '.join(segment_id.split()))]=array_disks["%s %s"%(segments[4],segments[5].replace(")",""))]
    with open(stat_file, 'w') as outfile:
        json.dump(array_present, outfile, indent=4)

def check():
    array_disks=json.loads(open(stat_file).read())
    stream_ld = Popen('/usr/bin/arcconf getconfig 1 ld',shell=True, stdout=PIPE)
    array_present={}
    for line in stream_ld.stdout:
        if re.search('Logical Device name',line) != None:
            logical_dev_name = ''.join(line.split(" : ")[1].rsplit())
        if re.search('Segment', line)!= None:
            segment_id,segment_disk = line.split(" : ")
            segment_disk=' '.join(segment_disk.split())
            segments=segment_disk.split(" ")
            if segments[0] != "Present":
                print array_disks["%s %s"%(logical_dev_name,' '.join(segment_id.split()))]

if sys.argv[1] == 'check':
    check()
else:
    if sys.argv[1] == 'init':
        init()

Инициализируем нормальную работу рейда в виде шаблона:
adaptec_state.py init

В результате у нас будет файл /etc/adaptec_state.json:
{
    "hdd_mirror Segment 1": "0,3(3:0)",
    "hdd_mirror Segment 0": "0,2(2:0)",
    "ssd_mirror Segment 1": "0,1(1:0)",
    "ssd_mirror Segment 0": "0,0(0:0)",
    "san01_raid10_01 Group 0, Segment 1": "0,16(16:0)",
    "san01_raid10_01 Group 0, Segment 0": "0,17(17:0)",
    "san01_raid10_01 Group 2, Segment 1": "0,21(21:0)",
    "san01_raid10_01 Group 2, Segment 0": "0,20(20:0)",
    "san01_raid10_01 Group 1, Segment 0": "0,18(18:0)",
    "san01_raid10_01 Group 1, Segment 1": "0,19(19:0)"
}

Вписываем в конфиг zabbix_agentd.conf следующий Userparameter:

UserParameter=adaptec.faileddisks, /usr/bin/adaptec_state.py check

Настраиваем его в zabbix. В итоге у нас будет приблизительно такой вывод проверки выпавшего диска:

# /usr/bin/adaptec_state.py check
0,19(19:0)


Может кому-нибудь пригодится.
P.S.: Писал как умею, просьба не пинать
Tags:
Hubs:
You can’t comment this publication because its author is not yet a full member of the community. You will be able to contact the author only after he or she has been invited by someone in the community. Until then, author’s username will be hidden by an alias.