Категории

вторник, 17 марта 2015 г.

Zabbix: supervisord автообнаружение программ и мониторинг статуса.

Скрипт поддерживает обнаружение (discovery) всех программ, которые сконфигурированы для запуска.
Отправка данных осуществляется через zabbix_sender.
Установка довольно тривиальна:
mkdir /etc/zabbix/scripts
chown root:zabbix -R /etc/zabbix/scripts
chmod 750 /etc/zabbix/scripts
Код скрипта /etc/zabbix/scripts/lsimegaraid_discovery_trapper.sh:
#!/bin/sh

ZABBIX_SENDER='/usr/bin/env zabbix_sender'
ZBX_CONFIG='/etc/zabbix/zabbix_agentd.conf'
ZBX_HOSTNAME=$(awk -F'=' '/^Hostname=/{ print $2 }' /etc/zabbix/zabbix_agentd.d/*.conf)

supervisorctl status | \
 awk 'match($0, /^([^:]+):[^[:blank:]]+[[:blank:]]+([^[:blank:]]+).*$/, line) {
  SUBSEP=","
  # Sadly, we can not initialize all the worker,status couples in the BEGIN section.
  # We have to run these almost useless lines during the input parsing
  if (status[line[1],"STOPPED"]  == 0) {status[line[1],"STOPPED"]  = 0}
  if (status[line[1],"STARTING"] == 0) {status[line[1],"STARTING"] = 0}
  if (status[line[1],"RUNNING"]  == 0) {status[line[1],"RUNNING"]  = 0}
  if (status[line[1],"BACKOFF"]  == 0) {status[line[1],"BACKOFF"]  = 0}
  if (status[line[1],"STOPPING"] == 0) {status[line[1],"STOPPING"] = 0}
  if (status[line[1],"EXITED"]   == 0) {status[line[1],"EXITED"]   = 0}
  if (status[line[1],"FATAL"]    == 0) {status[line[1],"FATAL"]    = 0}
  if (status[line[1],"UNKNOWN"]  == 0) {status[line[1],"UNKNOWN"]  = 0}
  status[line[1],line[2]]++
 }
 END {
  for(i in status) {
   print "- supervisord.workerState[" i "] " status[i]
  }
 }' | /usr/bin/env zabbix_sender --config $ZBX_CONFIG \
  --input-file - --host $ZBX_HOSTNAME >/dev/null 2>&1
echo $?
exit 0
Установка прав на скрипт:
chown root:zabbix /etc/zabbix/scripts/supervisord_discovery_trapper.sh
chmod 750 /etc/zabbix/scripts/supervisord_discovery_trapper.sh
Не забываем про настройки в скрипте, где нужно указать полные пути до необходимых программ и конфигурационных файлов:
ZABBIX_SENDER='/usr/bin/env zabbix_sender'
ZBX_CONFIG='/etc/zabbix/zabbix_agentd.conf'
ZBX_HOSTNAME=$(awk -F'=' '/^Hostname=/{ print $2 }' /etc/zabbix/zabbix_agentd.d/*.conf)
Конфигурационный файл: /etc/zabbix/zabbix_agentd.conf.d/lsimegaraid.conf
AllowRoot=1
UserParameter=supervisord.discovery,supervisorctl status | awk 'BEGIN {out="{\n\t\"data\":[\n"; f=0;} {match($0, /^([^:]+):[^[:blank:]]+[[:blank:]]+([^[:blank:]]+).*$/, line);if (!seen[line[1]]++ && line[1] != NULL) {if (f == 1) out=out",\n";out=out "\t\t{\"{#PROGRAMM}\":\""line[1]"\"}";f=1}} END{ if(f == 0){print "{}"}else{print out"\n\t]\n}"}}'
UserParameter=supervisord.trapper,/etc/zabbix/scripts/supervisord_trapper.sh
Шаблон для zabbix:
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2015-03-17T09:01:18Z</date>
    <groups>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template_APP supervisor</template>
            <name>Template_APP supervisor</name>
            <description/>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>App supervisord</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Controller</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>supervisord.trapper</key>
                    <delay>30</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>App supervisord</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                </item>
                <item>
                    <name>Supervisord process count</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>proc.num[supervisord]</key>
                    <delay>30</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>App supervisord</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>supervisord State discovery</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>supervisord.discovery</key>
                    <delay>3600</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>30</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>supervisord BACKOFF State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},BACKOFF]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord EXITED State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},EXITED]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord FATAL State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},FATAL]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord RUNNING State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},RUNNING]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord STARTING State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},STARTING]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord STOPPED State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},STOPPED]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord STOPPING State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},STOPPING]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>supervisord UNKNOWN State of worker $1</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>supervisord.workerState[{#PROGRAMM},UNKNOWN]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>App supervisord</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{Template_APP supervisor:supervisord.workerState[{#PROGRAMM},BACKOFF].last(0)}&gt;0</expression>
                            <name>Supervisord BACKOFF State of worker {#PROGRAMM} on host {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template_APP supervisor:supervisord.workerState[{#PROGRAMM},EXITED].last(0)}&gt;0</expression>
                            <name>Supervisord EXITED State of worker {#PROGRAMM} on host {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template_APP supervisor:supervisord.workerState[{#PROGRAMM},FATAL].last(0)}&gt;0</expression>
                            <name>Supervisord FATAL State of worker {#PROGRAMM} on host {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template_APP supervisor:supervisord.workerState[{#PROGRAMM},RUNNING].last(0)}=0</expression>
                            <name>Supervisord RUNNING State of worker {#PROGRAMM} on host {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template_APP supervisor:supervisord.workerState[{#PROGRAMM},STOPPED].last(0)}&gt;0</expression>
                            <name>Supervisord STOPPED State of worker {#PROGRAMM} on host {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template_APP supervisor:supervisord.workerState[{#PROGRAMM},UNKNOWN].last(0)}&gt;0</expression>
                            <name>Supervisord UNKNOWN State of worker {#PROGRAMM} on host {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes/>
                    <host_prototypes/>
                </discovery_rule>
            </discovery_rules>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
    <triggers>
        <trigger>
            <expression>{Template_APP supervisor:proc.num[supervisord].last(0)}=0</expression>
            <name>Supervisord is down on {HOST.NAME}</name>
            <url/>
            <status>0</status>
            <priority>4</priority>
            <description/>
            <type>0</type>
            <dependencies/>
        </trigger>
    </triggers>
</zabbix_export>
Не забываем перезапустить агент, чтобы агент прочитал новый конфигурационный файл:
service zabbix-agentd restart
Проверка:
zabbix_get -s HOST -k "supervisord.discovery"

Просмотр Markdown в MidnightCommander

Для просмотра MarkDown файлов в Midnight Commander необходимо добавить тип файлов .md, для этого в файл /etc/mc/mc.ext добавить следующий код:
# md
regex/\.[Mm][Dd]$
 View=%view{ascii,nroff} iconv -t utf-8 %p | pandoc -f markdown -t html | iconv -f utf-8 | (w3m -dump -T text/html 2>/dev/null || lynx -force_html -stdin -dump -nolist 2>/dev/null)
Для конвертирования md в html используется утилита pandoc, она мне показалась более предпочтительной, чем markdown, т.к. последний не умел обрабатывать теги с подобным кодом ```bash.
pandoc необходимо установить, например для ubuntu:
apt-get install pandoc
Если нет желания ставить w3m или lynx браузер, то можно воспользоваться форматом man (pandoc по прежнему необходим):
# md
regex/\.[Mm][Dd]$
 View=%view{ascii,nroff} iconv -t utf-8 %p | pandoc -s -f markdown -t man | iconv -f utf-8 | man -l -
P.S. iconv используется на всякий случай, если вдруг по какой-то причине у вас не UTF8 локаль, а pandoc обрабатывает по умолчанию в UTF8 и результат отдает тоже в UTF8, поэтому сперва конвертируем исходный текст из вашей локали в UTF8, отдаем на обработку в pandoc и конвертируем из UTF8 обратно в текущую локаль.
1. Online MarkDown Editor

понедельник, 16 марта 2015 г.

Мониторинг LSI MegaRAID в Zabbix

Скрипт мониторит по-умолчанию адаптер 0, т.е. когда в системе только одна плата Raid контроллера (опция -a0), но можно указать конкретный номер адаптера, если это необходимо.

Скрипт имеет встроенную справку:
# ./lsimegaraid_discovery_trapper.sh help
WARNING: Correctly setup 'Hostname=' in config is REQUIRED!

INFO: Number of array is default 0;
 Examples:
    Discovery is default action:
        ./lsimegaraid_discovery_trapper.sh                            - physdiscovery disks for default array 0.
        ./lsimegaraid_discovery_trapper.sh discovery                  - physdiscovery disks for default array 0.
        ./lsimegaraid_discovery_trapper.sh discovery virtdiscovery    - virtdiscovery disks for custom array 0.
        ./lsimegaraid_discovery_trapper.sh discovery virtdiscovery 1  - virtdiscovery disks for custom array 1.
        ./lsimegaraid_discovery_trapper.sh discovery physdiscovery 1  - physdiscovery disks for custom array 1.
    Data sending to zabbix-server:
        ./lsimegaraid_discovery_trapper.sh trapper    - send data to zabbix for default array 0.
        ./lsimegaraid_discovery_trapper.sh trapper 1  - send data to zabbix for custom array 1.

03.2015 - metajiji@gmail.com
Скрипт поддерживает обнаружение (discovery) виртуальных и физических дисков в слотах. Отправка данных осуществляется через zabbix_sender.
Установка довольно тривиальна:
mkdir /etc/zabbix/scripts
chown root:zabbix -R /etc/zabbix/scripts
chmod 750 /etc/zabbix/scripts
Код скрипта /etc/zabbix/scripts/lsimegaraid_discovery_trapper.sh:
#!/bin/sh

MEGACLI='/usr/local/sbin/MegaCli'
ZABBIX_SENDER='/usr/local/bin/zabbix_sender'
CONFIG='/etc/zabbix/zabbix_agentd.conf'

usage() {
 cat <<-_EOF
 WARNING: Correctly setup 'Hostname=' in config is REQUIRED!

 INFO: Number of array is default 0;
  Examples:
     Discovery is default action:
         ./$(basename $0)                            - physdiscovery disks for default array 0.
         ./$(basename $0) discovery                  - physdiscovery disks for default array 0.
         ./$(basename $0) discovery virtdiscovery    - virtdiscovery disks for custom array 0.
         ./$(basename $0) discovery virtdiscovery 1  - virtdiscovery disks for custom array 1.
         ./$(basename $0) discovery physdiscovery 1  - physdiscovery disks for custom array 1.
     Data sending to zabbix-server:
         ./$(basename $0) trapper    - send data to zabbix for default array 0.
         ./$(basename $0) trapper 1  - send data to zabbix for custom array 1.

 03.2015 - metajiji@gmail.com
_EOF
}

LC_ALL=""
LANG="en_US.UTF-8"

discovery() {
 local TYPE=${1:-'physdiscovery'}  # Set Default value to physdiscovery.
 local ARRAY_NUM=${2:-'0'}  # Default value of array number is 0.
 if [ "$TYPE" == "virtdiscovery" ]; then
  $MEGACLI -LDInfo -LAll -a$ARRAY_NUM -NoLog | awk '
   BEGIN {
    out = "{\n\t\"data\":[\n"
    f = 0
   }
   /Virtual Drive:/ {
    if (f == 1) out = out",\n"
    out=out "\t\t{\"{#VIRTNUM}\":\"VirtualDrive"$3"\"}"
    f = 1
   }
   END {
    if (f == 0) {
     print "{}"
    } else {
     print out"\n\t]\n}"
    }
   }'
 elif [ "$TYPE" == 'physdiscovery' ]; then
  $MEGACLI -PDlist -a$ARRAY_NUM -NoLog | awk -F ': ' '
   BEGIN {
    out = "{\n\t\"data\":[\n"
    f = 0
   }
   /Slot Number:/ {
    if (f == 1) out = out",\n"
    out=out "\t\t{\"{#PHYSNUM}\":\"DriveSlot"$2"\"}"
    f = 1
   }
   END {
    if (f == 0) {
     print "{}"
    } else {
     print out"\n\t]\n}"
    }
   }'
 else
  >&2 echo 'ERROR  : Discovery TYPE "'$TYPE'" is not correct!'
  echo '{}'  # Return empty json, if TYPE is not correct.
 fi
}

trapper() {
 local ARRAY_NUM=${1:-'0'}  # Default value of array number is 0.
 ($MEGACLI -PDlist -a$ARRAY_NUM -NoLog | awk -F':' '
  function ltrim(s) {sub(/^[ \t]+/, "", s);return s}
  function rtrim(s) {sub(/[ \t]+$/, "", s);return s}
  function trim(s)  {return rtrim(ltrim(s))}
  /Slot Number/              {slotcounter += 1; slot[slotcounter] = trim($2)}
  /Firmware state/           {state[slotcounter]        = trim($2)}
  /S.M.A.R.T/                {smart[slotcounter]        = trim($2)}
  /Inquiry Data/             {inquiry[slotcounter]      = trim($2)}
  /Media Error Count/        {mediaerror[slotcounter]   = trim($2)}
  /Other Error Count/        {othererror[slotcounter]   = trim($2)}
  /Drive Temperature/        {temperature[slotcounter]  = trim($2)}
  /Predictive Failure Count/ {failurecount[slotcounter] = trim($2)}
  END {
   for (i = 1; i <= slotcounter; i += 1) {
    printf ("- lsimegaraid.data[DriveSlot%d,state] %s\n",        slot[i], state[i])
    printf ("- lsimegaraid.data[DriveSlot%d,smart] %s\n",        slot[i], smart[i])
    printf ("- lsimegaraid.data[DriveSlot%d,inquiry] %s\n",      slot[i], inquiry[i])
    printf ("- lsimegaraid.data[DriveSlot%d,mediaerror] %d\n",   slot[i], mediaerror[i])
    printf ("- lsimegaraid.data[DriveSlot%d,othererror] %d\n",   slot[i], othererror[i])
    printf ("- lsimegaraid.data[DriveSlot%d,temperature] %d\n",  slot[i], temperature[i])
    printf ("- lsimegaraid.data[DriveSlot%d,failurecount] %d\n", slot[i], failurecount[i])
   }
  }'; [ $? -gt 1 ] && echo 'ERROR  : MegaCli failed while getting phusical drives data!' && exit 1

 ${MEGACLI} -LDInfo -LAll -a$ARRAY_NUM -NoLog | awk -F':' '
  function ltrim(s) {sub(/^[ \t]+/, "", s);return s}
  function rtrim(s) {sub(/[ \t]+$/, "", s);return s}
  function trim(s)  {return rtrim(ltrim(s))}
  /Virtual Drive:/  {drivecounter += 1; slot[drivecounter] = trim($2)}
  /State/           {state[drivecounter]    = trim($2)}
  /Bad Blocks/      {badblock[drivecounter] = trim($2)}
  END {
   for (i = 1; i <= drivecounter; i += 1) {
    printf ("- lsimegaraid.data[VirtualDrive%d,state] %s\n", slot[i], state[i])
    printf ("- lsimegaraid.data[VirtualDrive%d,badblock] %s\n", slot[i], badblock[i]?badblock[i]:"Unknown")
   }
  }'; [ $? -gt 1 ] && echo 'ERROR  : MegaCli failed while getting virtual drives data!' && exit 1
 ) | $ZABBIX_SENDER --config $CONFIG -vv --input-file - >/dev/null 2>&1
 [ $? -gt 1 ] && echo 0 && exit 1
 echo 1 # 1 - Ok | 0 - Fail
}

case "$1" in
 help|usage|-h|--help) usage ;;
 discovery) discovery $2 $3 ;;
 trapper) trapper $2 ;;
 *) discovery ;;
esac
Установка прав на скрипт:
chown root:zabbix /etc/zabbix/scripts/lsimegaraid_discovery_trapper.sh
chmod 750 /etc/zabbix/scripts/lsimegaraid_discovery_trapper.sh
Не забываем про настройки в скрипте, где нужно указать полные пути до необходимых программ и конфигурационных файлов:
MEGACLI='/usr/local/sbin/MegaCli'
ZABBIX_SENDER='/usr/local/bin/zabbix_sender'
CONFIG='/etc/zabbix/zabbix_agentd.conf'
Конфигурационный файл: /etc/zabbix/zabbix_agentd.conf.d/lsimegaraid.conf
UserParameter=lsimegaraid.discovery[*],/usr/local/etc/zabbix24/scripts/lsimegaraid_discovery_trapper.sh "discovery" $1 $2
UserParameter=lsimegaraid.trapper[*],/usr/local/etc/zabbix24/scripts/lsimegaraid_discovery_trapper.sh "trapper" $1
Шаблон для zabbix:
<zabbix_export>
    <version>2.0</version>
    <date>2015-03-16T07:54:05Z</date>
    <groups>
        <group>
            <name>MyTemplates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template LSIMegaRaid_trapper</template>
            <name>Template LSIMegaRaid_trapper</name>
            <description/>
            <groups>
                <group>
                    <name>MyTemplates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>LSI MegaRaid</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Trapper</name>
                    <type>0</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>lsimegaraid.trapper[0]</key>
                    <delay>30</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>LSI MegaRaid</name>
                        </application>
                    </applications>
                    <valuemap/>
                    <logtimefmt/>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>LSIMegaRaid: Physical disks slot discovery</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>lsimegaraid.discovery[physdiscovery,0]</key>
                    <delay>3600</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>30</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Firmware State</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},state]</key>
                            <delay>0</delay>
                            <history>365</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>4</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 has flagged a S.M.A.R.T alert</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},smart]</key>
                            <delay>0</delay>
                            <history>365</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>4</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Inquiry Data</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},inquiry]</key>
                            <delay>0</delay>
                            <history>365</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>4</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Media Error Count</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},mediaerror]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Other Error Count</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},othererror]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Predictive Failure Count</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},failurecount]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Temperature</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#PHYSNUM},temperature]</key>
                            <delay>0</delay>
                            <history>7</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>C</units>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},smart].str(No)}=0</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} has flagged a S.M.A.R.T alert on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},inquiry].diff(0)}&gt;0</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} inquiry data changed on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>1</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},mediaerror].last(0)}&gt;0</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} Media Error Count on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},othererror].last(0)}&gt;0</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} Other Error Count on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},failurecount].last(0)}&gt;0</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} Predictive Failure Count on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},state].str(Online)}=0</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} state is not online on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},temperature].last(0)}&gt;45</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} temperature is high on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>4</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#PHYSNUM},temperature].last(0)}&gt;49</expression>
                            <name>LSIMegaRaid: {#PHYSNUM} temperature is very high on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes/>
                    <host_prototypes/>
                </discovery_rule>
                <discovery_rule>
                    <name>LSIMegaRaid: Virtual disks discovery</name>
                    <type>0</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>lsimegaraid.discovery[virtdiscovery,0]</key>
                    <delay>3600</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>
                        <evaltype>0</evaltype>
                        <formula/>
                        <conditions/>
                    </filter>
                    <lifetime>30</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 Bad Blocks Exist</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#VIRTNUM},badblock]</key>
                            <delay>0</delay>
                            <history>365</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                        <item_prototype>
                            <name>LSIMegaRaid: $1 State</name>
                            <type>2</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>lsimegaraid.data[{#VIRTNUM},state]</key>
                            <delay>0</delay>
                            <history>365</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>1</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>LSI MegaRaid</name>
                                </application>
                            </applications>
                            <valuemap/>
                            <logtimefmt/>
                        </item_prototype>
                    </item_prototypes>
                    <trigger_prototypes>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#VIRTNUM},badblock].str(No)}=0</expression>
                            <name>LSIMegaRaid: {#VIRTNUM} Bad Blocks Exist on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                        <trigger_prototype>
                            <expression>{Template LSIMegaRaid_trapper:lsimegaraid.data[{#VIRTNUM},state].str(Optimal)}=0</expression>
                            <name>LSIMegaRaid: {#VIRTNUM} state is not optimal on {HOST.NAME}</name>
                            <url/>
                            <status>0</status>
                            <priority>5</priority>
                            <description/>
                            <type>0</type>
                        </trigger_prototype>
                    </trigger_prototypes>
                    <graph_prototypes/>
                    <host_prototypes/>
                </discovery_rule>
            </discovery_rules>
            <macros/>
            <templates/>
            <screens/>
        </template>
    </templates>
</zabbix_export>

1. Мониторинг LSI MegaRAID в Zabbix
2. Мониторинг состояния HDD в RAID контроллере LSI MegaRAID под Linux, средствами Nagios.
3. Intel Raid Controller RS2BL040 Slow Performance – BBU problems.
4. Perc RAID Controllers
5. Adding a Hard Drive back into RAID on a Web Gateway 5000 or 5500 Intel based Appliance

суббота, 7 марта 2015 г.

Восстановление Seagate 1Tb ST31000528AS 7200.12

Перестал определяться в BIOS ST31000528AS (CC35) 7200.12, первое что подумал - 1Tb данных пропал безвозвратно, но погуглив, понял, что не все так плохо, как кажется и решил побороться за данные и hdd, и так, подключаемся к hdd через serial терминал.
Для подключения использовал FTDI232, в распоряжении был еще BusPirate, но до него дело не дошло, FTDI232 справился отлично.
# screen /dev/ttyUSB0 38400
Rst 0x20M
ASCII Diag mode

F3 T>
Как видно, тут что-то не так Rst 0x20M - происходит сброс, зайдем в терминал нажатием Ctrl+Z и попробуем проверить работу электроники и механики путём отключения/включения шпинделя:
F3 F>Z
Spin Down Complete
Elapsed Time 513.285 msecs 
F3 F>U
 HighPowerMode 
ExecuteSpinRequest

Spin Up Complete
Elapsed Time 5.776 secs 
F3 F>
Ошибок не было, значит с большей долей вероятности все живое и функционирует, поиск по интернету показал, что проблема в SMART данных (они хранятся на пластинах диска) - можно попробовать сбросить SMART данные:
F3 T>/1
F3 1>N1
Init SMART Fail
LED:000000CC FAddr:0024EE41
LED:000000CC FAddr:0024EE41
А вот и ошибки, опять же поиск подсказывает, что необходимо форматировать пользовательскую зону с сертификацией, без записи, используя Slip(V1)-лист, т.е. пересчитать транслятор, пробуем, для этого я отключил кабель питания hdd, дождался остановки шпинделя (почему-то я не отключил его) и включил снова:
# screen /dev/ttyUSB0 38400
Rst 0x20M
ASCII Diag mode

F3 T>
Снова зашел в терминал диска нажатием Ctrl+Z и попробовал пересчитать транслятор, как рекомендуют на форуме:
F3 T>V4
Reassigned Sectors List
Original     New    log log   log     phy     phy
    LBA      PBA    cyl  hd  sctr zn  cyl hd  sctr     SFI
 
         Alt   Pending  Total    Alted  Total
       Entries Entries Entries    Alts   Alts
Head 0              0
Head 1              0
Head 2              0
Head 3              0
Total        0      0       0        0      0
Total Alt Removals:    0
Checksum = 0000
 
F3 T>V1
 User Slip Defect List
                         log log   log     phys   phys
    LBA    span   cumm   cyl  hd  sctr zn   cyl   sctr     SFI      PBA
       0      0      0     0  0     0   0      0     0        4        0
 
Head 0: entries      1        slips        0
Head 1: entries      0        slips        0
Head 2: entries      0        slips        0
Head 3: entries      0        slips        0
  Total Entries      1  Total Slips        0
 
F3 T>m0,2,2,,,,,22
Max Wr Retries = 00, Max Rd Retries = 00, Max ECC T-Level = 16, Max Certify Rewrite Retries = 2DF8
 
User Partition Format Successful - Elapsed Time 0 mins 00 secs
Zone re-format was skipped.
Ошибок не было, все прошло успешно, теперь необходимо обязательно отключить питание hdd и можно пробовать подключать SATA кабель и проверять данные!
Итак, после включения диск определился в BIOS, после загрузки ос я увидел все свои данные в целости и сохранности, на всякий случай скопировал оттуда фотографии, видео на другой диск.
У меня был еще такой же диск, но с прошивкой поновее (CC38), поэтому я решил обновить её, делается это не так сложно, на сайте производителя [2] есть необходимый софт, мне очень подошел вариант с iso образом - я загрузился по сети pxeboot и произвел процедуру обновления, она не сложная.

Ссылки по теме:

1. Восстановление работоспособности жесткого диска
2. Barracuda 7200.12 Firmware Update
3. Maxtor DiamondMax 23 STM3500418AS не определяется в BIOS
4. Расширяем стандартные возможности жесткого диска