How to: Install LSI Command Line Tool
LSI hardware RAID has a command line tool to manage RAID related commands and configuration. It is called MegaCLI. MegaCLI is available at broadcom doc downloads. Use the following to download MegaCLI:
Unzip the MegaCLI file:
unzip 8-07-14_MegaCLI.zip cd Linux
Run the rpm file:
rpm -ivh MegaCli-8.07.14-1.noarch.rpm
Command | Action |
---|---|
./MegaCli64 -FwTermLog -Dsply -aALL > /tmp/ttylog.txt |
Creates the RAID controller log (ttylog) |
./MegaCli64 -PDList -aALL > /tmp/disks.txt |
Creates a list with information about the RAID controllers, virtual disks and hard disks installed |
./MegaCli64 -LDInfo -LALL -aALL > /tmp/LDinfo.txt |
Creates a list with information about existing RAID volumes and configurations |
./MegaCli64 -AdpAllInfo -aALL > /tmp/Adapterinfo.txt |
Creates a list with information about RAID controller settings |
./MegaCli64 -AdpBbuCmd -aALL > /tmp/Battery.txt |
Creates a detailed list of the battery status of the RAID controller (state of charge, learning cycle, etc.) |
./MegaCli64 -AdpEventLog -IncludeDeleted -f deleted.txt -aALL |
Creates the RAID controller log (ttylog) with all information since very first controller initialization( Note: This file will always be saved in the MegaCLI root folder) |
Ansible 安装 MegaCLi64
---
- hosts: all
become: yes
gather_facts: no
tasks:
- name: upload MegaCli64
copy:
src: files/MegaCli-8.07.14-1.noarch.rpm
dest: /tmp/MegaCli-8.07.14-1.noarch.rpm
- name: install MegaCli64 rpm from a local file
yum:
name: /tmp/MegaCli-8.07.14-1.noarch.rpm
state: present
- name: create symlink for MegaCli64
file:
src: /opt/MegaRAID/MegaCli/MegaCli64
dest: /usr/sbin/MegaCli
state: link
Ansible 使用 MegaCli64 检查故障硬盘
---
- hosts: all
become: yes
gather_facts: no
tasks:
- name: Check Disk Status
command: ./MegaCli64 -ShowSummary -aALL
args:
chdir: /opt/MegaRAID/MegaCli/
register: result
- name: Log check info
lineinfile:
dest: "{{inventory_dir}}/ansible.log"
line: '[Ansiable Tasks: Disk Failure info] host={{inventory_hostname}}'
insertafter: EOF
create: yes
when: '"Failed" in result.stdout'
delegate_to: localhost
become: no
# check log
cat ansible.log
[Ansiable Tasks: Disk Failure info] host=10.71.12.89
https://wsgzao.github.io/post/megacli64/