使用MegaCli和Smartctl获取普通磁盘

设备名称:

[[email protected] shell]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 02 Id: 00 Lun: 00
  Vendor: DELL     Model: PERC 5/i         Rev: 1.03
  Type:   Direct-Access                    ANSI SCSI revision: 05
[[email protected] shell]#

运行出错:

[[email protected] opt]# smartctl -i /dev/sda
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-238.el5] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

Smartctl open device: /dev/sda failed: DELL or MegaRaid controller, please try adding ‘-d megaraid,N’
[[email protected] opt]#

MegaCli是一款管理维护硬件RAID软件,可以通过它来了解当前raid卡的所有信息,包括
raid卡的型号,raid的阵列类型,raid
上各磁盘状态,等等。通常,我们对硬盘当前的状态不太好确定,一般通过机房人员巡检来完成,有没有通过软件的方式来检查确定这个问题呢。MegaCli就
可以做到,一般通过 MegaCli 的

下载:http://ftp.cs.stanford.edu/pub/rpms/centos/5/x86_64/

http://ftp.cs.stanford.edu/pub/rpms/centos/5/x86_64/MegaCli-8.00.46-1.i386.rpm

[[email protected] opt]# wget http://ftp.cs.stanford.edu/pub/rpms/centos/5/x86_64/MegaCli-8.00.46-1.i386.rpm

安装出错:

[[email protected] opt]# rpm -ivh MegaCli-8.00.46-1.i386.rpm
error: Failed dependencies:
    Lib_Utils is needed by MegaCli-8.00.46-1.i386

解决:

[[email protected] opt]# wget http://ftp.cs.stanford.edu/pub/rpms/centos/5/x86_64/Lib_Utils-1.00-08.noarch.rpm

[[email protected] opt]# rpm -ivh Lib_Utils-1.00-08.noarch.rpm
Preparing…                ########################################### [100%]
Installing….
   1:Lib_Utils              ########################################### [100%]
[[email protected] opt]# rpm -ivh MegaCli-8.00.46-1.i386.rpm
Preparing…                ########################################### [100%]
   1:MegaCli                ########################################### [100%]
[[email protected] opt]#

安装位置:

[[email protected] MegaCli]# ls -al /opt/MegaRAID/MegaCli/MegaCli64
-rwxr-xr-x 1 root root 2247688 2011-02-03 /opt/MegaRAID/MegaCli/MegaCli64
[[email protected] MegaCli]#

查看RAID级别:

[[email protected] MegaCli]# /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL

Adapter 0 — Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :database
RAID Level          : Primary-1, Secondary-3, RAID Level Qualifier-0
Size                : 203.25 GB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives per span:2
Span Depth          : 3
Default Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Access Policy       : Read/Write
Disk Cache Policy   : Disk’s Default
Encryption Type     : None

Exit Code: 0x00
[[email protected] MegaCli]#

实用方法:

命令使用:
#/opt/MegaCli  -LDInfo -Lall -aALL 查raid级别
#/opt/MegaCli -AdpAllInfo -aALL 查raid卡信息
#/opt/MegaCli -PDList -aALL 查看硬盘信息
#/opt/MegaCli -AdpBbuCmd -aAll 查看电池信息
#/opt/MegaCli -FwTermLog -Dsply -aALL 查看raid卡日志
#/opt/MegaCli -adpCount 【显示适配器个数】
#/opt/MegaCli -AdpGetTime –aALL 【显示适配器时间】
#/opt/MegaCli -AdpAllInfo -aAll    【显示所有适配器信息】
#/opt/MegaCli -LDInfo -LALL -aAll    【显示所有逻辑磁盘组信息】
#/opt/MegaCli -PDList -aAll    【显示所有的物理信息】
#/opt/MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Charger Status’ 【查看充电状态】
#/opt/MegaCli -AdpBbuCmd -GetBbuStatus -aALL【显示BBU状态信息】
#/opt/MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL【显示BBU容量信息】
#/opt/MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL    【显示BBU设计参数】
#/opt/MegaCli -AdpBbuCmd -GetBbuProperties -aALL    【显示当前BBU属性】
#/opt/MegaCli -cfgdsply -aALL    【显示Raid卡型号,Raid设置,Disk相关信息】

[[email protected] MegaCli]# /opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL
                                    
=============================================================
Adapter: 0
Product Name: PERC 5/i Integrated
Memory: 256MB
BBU: Present
Serial No: 12345
==============================================================

[[email protected] MegaCli]# ls -al /dev/megaraid_sas_ioctl_node
cr——– 1 root root 253, 0 04-15 13:23 /dev/megaraid_sas_ioctl_node
[[email protected] MegaCli]#

下面使用smartctl透过Raid卡获取磁盘更详细的信息:

# smartctl manual 摘录..
              Under Linux , to look at SCSI/SAS disks behind LSI MegaRAID controllers, use syntax such as:
              smartctl -a -d megaraid,2 /dev/sda
              smartctl -a -d megaraid,0 /dev/sdb
             
where in the argument megaraid,N, the integer N is the physical disk
number within the MegaRAID controller.  This  interface  will
             
also work for Dell PERC controllers.  The following /dev/XXX entry must
exist:                 # 经测试只要存在即可,对应关系搞错确也仍可正常显示
              For PERC2/3/4 controllers: /dev/megadev0
              For PERC5/6 controllers: /dev/megaraid_sas_ioctl_node

[[email protected] MegaCli]# smartctl -a -d megaraid,0 /dev/sda1

-------------------------------------------------------------------------------------------------------------------------------------------------------------

c233 ~ # smartctl -a -d megaraid,0 /dev/sda                     //在天津233执行的结果
smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.36-gentoo-r8] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

Vendor:               SEAGATE
Product:              ST3146755SS     
Revision:             T106
User Capacity:        146,815,733,760 bytes [146 GB]
Logical block size:   512 bytes
Logical Unit id:      0x5000c50001fa3487
Serial number:        3LN0DAQZ
Device type:          disk
Transport protocol:   SAS
Local Time is:        Tue Jul  7 14:08:10 2015 CST
Device supports SMART and is Enabled
Temperature Warning Disabled or Not Supported
SMART Health Status: OK

Current Drive Temperature:     39 C
Drive Trip Temperature:        68 C
Elements in grown defect list: 0
Vendor (Seagate) cache information
  Blocks sent to initiator = 2033818666
  Blocks received from initiator = 1189632289
  Blocks read from cache and sent to initiator = 224505734
  Number of read and write commands whose size <= segment size = 254557295
  Number of read and write commands whose size > segment size = 12531253
Vendor (Seagate/Hitachi) factory information
  number of hours powered up = 66374.83
  number of minutes until next internal SMART test = 17

Error counter log:
           Errors Corrected by           Total   Correction     Gigabytes    Total
               ECC          rereads/    errors   algorithm      processed    uncorrected
           fast | delayed   rewrites  corrected  invocations   [10^9 bytes]  errors
read:   160704420        4         0  160704424   160704424       1139.656           0
write:         0        0         0         0          0       5032.699           0
verify: 449944729        0         0  449944729   449944729      25972.300           0

Non-medium error count:       39

SMART Self-test log
Num  Test              Status                 segment  LifeTime  LBA_first_err [SK ASC ASQ]
     Description                              number   (hours)
# 1  Background long   Aborted (by user command)   -     168                 - [-   -    -]
# 2  Background long   Aborted (by user command)   -     159                 - [-   -    -]
# 3  Background long   Completed                   -       1                 - [-   -    -]
# 4  Background short  Completed                   -       0                 - [-   -    -]

Long (extended) Self Test duration: 1941 seconds [32.4 minutes]

时间: 2024-11-13 06:34:12

使用MegaCli和Smartctl获取普通磁盘的相关文章

获取windows磁盘的可用空间函数

<?php /* *获取某个磁盘的剩余空间 *$param 关联数组,下标是哪个盘,单位,可以是B,KB,MB,GB *可以设置获取多个磁盘,例如:array('C'=>'KB','D'=>'MB','E'=>'GB','F'=>'B') *假如出错,返回false */ function Space($arr){ //检查参数 if(is_array($arr)){ //初始化存储值 $memory = array(); foreach($arr as $disk=>

C++通过WIN32 API获取逻辑磁盘详细信息

1 #include <iostream> 2 #include <windows.h> 3 using namespace std; 4 5 int main() 6 { 7 int DiskCount = 0; 8 DWORD DiskInfo = GetLogicalDrives(); 9 //利用GetLogicalDrives()函数可以获取系统中逻辑驱动器的数量,函数返回的是一个32位无符号整型数据. 10 while(DiskInfo)//通过循环操作查看每一位数据是

iphone获取当前磁盘信息

获取iphone磁盘总大小.已使用空间.空闲空间 1. [代码][C/C++]代码 -(float)getFreeDiskspace {    float totalSpace;    float totalFreeSpace;    float totalUsedSpace;        NSError *error = nil;      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NS

qt 获取系统磁盘空间大小

quint64 getDiskFreeSpace(QString driver) { LPCWSTR lpcwstrDriver=(LPCWSTR)driver.utf16(); ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalFreeBytes; if( !GetDiskFreeSpaceEx( lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTot

Qt获取电脑磁盘容量

项目中用到了监测某磁盘(如:C盘.D盘等)的总容量和可用容量,查了一下,发现其实挺简单,调用一个Windows自带的API:GetDiskFreeSpaceEx( ... )就可以解决.用Qt做了一个测试例子,如下所示.??另:测试发现,如果给定路径不存在(如程序中"F:\"),则获取不到信息:通常给定用以获取磁盘容量信息的路径为"C:\"."D:\"等,但给定已存在路径(如程序中"D:\Test"),同样可以获取到该路径所属

Java 获取Windows 磁盘卷标

Sun已经实现了几个主要操作系统缺省实现类,调用FileSystemView.getFileSystemView()即可. package test; import java.io.File; import javax.swing.filechooser.FileSystemView; public class DriverTest { public static void main(String[] args){ // 当前文件系统类 FileSystemView fsv = FileSyst

获取Linux磁盘分区的UUID

在设置fstab自动挂载时,需要填写如下的信息: # <file system> <mount point> <type> <options> <dump> <pass> 其中file system指的时磁盘在系统之中的ID,可以查看 /dev/下的设备,一般以sd[abcde...]命名 也可以填写UUID作为这个ID,用如下方法可以查看磁盘的UUID: ls -l /dev/disk/by-uuid

获取系统磁盘信息

#define DRIVE_LEN 100 char szDrivers[DRIVE_LEN] = {0}; int i_Drive_Len = DRIVE_LEN; GetLogicalDriveStrings(i_Drive_Len, szDrivers); char *psz = szDrivers; ULARGE_INTEGER FreeBytesAvailableToCaller = {0}; ULARGE_INTEGER TotalNumberOfBytes = {0}; ULARG

使用Megacli查看磁盘状态

Megacli是一款管理维护硬件RAID的工具,有LSI公司提供,LSI公司的raid卡,使用的比较广泛.我们可以通过megacli了解当前raid卡的所有信息,包括raid卡的型号,raid的阵列类型,raid上的磁盘状态,也可以通过它来直接创建阵列,在线添加磁盘等. 一,Megacli工具安装 可以在LSI公司的官网直接下载工具: http://www.lsi.com/downloads/Public/Nytro/downloads/Nytro%20XD/MegaCli_Linux.zip