smartctl command's RETURN VALUES
smartctl -S on -s on -o on /dev/sdd
[root@db-172-16-3-150 ~]# /opt/smartmontools-6.0/sbin/smartctl -S on -s on -o on /dev/sdd
smartctl 6.0 2012-10-10 r3643 [x86_64-linux-2.6.18-274.el5] (local build)
Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
SMART Attribute Autosave Enabled.
SMART Automatic Offline Testing Enabled every four hours.
2. smartctl健康检查选项 :
-H, --healthCheck: Ask the device to report its SMART health status or pending TapeAlert messages. SMART status isbased on information that it has gathered from online and offline tests, which were used to deter-mine/update its SMART vendor-specific Attribute values. TapeAlert status is obtained by reading theTapeAlert log page.If the device reports failing health status, this means either that the device has already failed, orthat it is predicting its own failure within the next 24 hours. If this happens, use the ′-a′ option toget more information, and get your data off the disk and to someplace safe as soon as you can.
健康检查示例 :
[root@db-172-16-3-150 ~]# /opt/smartmontools-6.0/sbin/smartctl -H /dev/sdd
smartctl 6.0 2012-10-10 r3643 [x86_64-linux-2.6.18-274.el5] (local build)
Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
返回值 :
[root@db-172-16-3-150 ~]# echo $?
0
或者仅输出错误 :
[root@db-172-16-3-150 ~]# /opt/smartmontools-6.0/sbin/smartctl -H -q errorsonly /dev/sdd
[root@db-172-16-3-150 ~]#
3. 返回值解析脚本 :
[root@db-172-16-3-150 ~]# cat smart.sh
/opt/smartmontools-6.0/sbin/smartctl -H -d sat+megaraid,2 /dev/sdb
status=$?
for ((i=0; i<8; i++)); doecho "Bit $i: $((status & 2**i && 1))"
done
执行这个shell script :
[root@db-172-16-3-150 ~]# . ./smart.sh
smartctl 6.0 2012-10-10 r3643 [x86_64-linux-2.6.18-274.el5] (local build)
Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.Bit 0: 0
Bit 1: 0
Bit 2: 1
Bit 3: 0
Bit 4: 0
Bit 5: 0
Bit 6: 0
Bit 7: 0
default:// Something went wrong with the SMART STATUS command.// The ATA SMART RETURN STATUS command provides the result in the ATA output// registers. Buggy ATA/SATA drivers and SAT Layers often do not properly// return the registers values.failuretest(OPTIONAL_CMD, returnval|=FAILSMART);if (!(smart_val_ok && smart_thres_ok)) {print_on();pout("SMART overall-health self-assessment test result: UNKNOWN!\n""SMART Status, Attributes and Thresholds cannot be read.\n\n");}else if (find_failed_attr(&smartval, &smartthres, attribute_defs, 1)) {print_on();pout("SMART overall-health self-assessment test result: FAILED!\n""Drive failure expected in less than 24 hours. SAVE ALL DATA.\n");print_off();returnval|=FAILATTR;returnval|=FAILSTATUS;if (options.smart_vendor_attrib)pout("See vendor-specific Attribute list for failed Attributes.\n\n");else {print_on();pout("Failed Attributes:\n");PrintSmartAttribWithThres(&smartval, &smartthres, attribute_defs, rpm, 1, options.output_format);}}else {pout("SMART overall-health self-assessment test result: PASSED\n");pout("Warning: This result is based on an Attribute check.\n");
【参考】
The return values of smartctl are defined by a bitmask. If all is well with the disk, the return value (exitstatus) of smartctl is 0 (all bits turned off). If a problem occurs, or an error, potential error, or fault isdetected, then a non-zero status is returned. In this case, the eight different bits in the return value havethe following meanings for ATA disks; some of these values may also be returned for SCSI disks.Bit 0: Command line did not parse.Bit 1: Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode(see ′-n′ option above).Bit 2: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data struc-ture (see ′-b′ option above).Bit 3: SMART status check returned "DISK FAILING".Bit 4: We found prefail Attributes <= threshold.Bit 5: SMART status check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <=threshold at some time in the past.Bit 6: The device error log contains records of errors.Bit 7: The device self-test log contains records of errors. [ATA only] Failed self-tests outdated by a newersuccessful extended self-test are ignored.To test within the shell for whether or not the different bits are turned on or off, you can use the followingtype of construction (this is bash syntax):smartstat=$(($? & 8))This looks at only at bit 3 of the exit status $? (since 8=2^3). The shell variable $smartstat will benonzero if SMART status check returned "disk failing" and zero otherwise.This bash script prints all status bits:status=$?for ((i=0; i<8; i++)); doecho "Bit $i: $((status & 2**i && 1))"done
smartctl command's RETURN VALUES相关推荐
- QMetaMethod::invoke: Unable to invoke methods with return values in queued connections
报错信息为: QMetaMethod::invoke: Unable to invoke methods with return values in queued connections 解决方法是: ...
- 【QML】C++访问QML函数获取返回值时报:Unable to invoke methods with return values in queued connections
QMetaMethod::invoke: Unable to invoke methods with return values in queued connections 相关资料可以参考:http ...
- mysql stored procedures with return values
存储过程的功能非常强大,在某种程度上甚至可以替代业务逻辑层, 接下来就一个小例子来说明,用存储过程插入或更新语句. 1.数据库表结构 所用数据库为Sql Server2008. 2.创建存储过程 (1 ...
- WPF 使用Command,CommandParameter向 MVVM传递多个参数
有的时候需要向ViewModel传递两个CommandParameter参数.需要实现一个Converter.然后就可以实现多个参数传递啦.本案例以MVVM为基础做的Demo.还有一个编写的按钮样式的 ...
- [UWP]了解模板化控件(7):支持Command
原文:[UWP]了解模板化控件(7):支持Command 以我的经验来说,要让TemplatedControl支持Command的需求不会很多,大部分情况用附加属性解决这个需求会更便利些,譬如UWPC ...
- 【白话设计模式八】命令模式(Command)
为什么80%的码农都做不了架构师?>>> #0 系列目录# 白话设计模式 工厂模式 单例模式 [白话设计模式一]简单工厂模式(Simple Factory) [白话设计模式二] ...
- HashMap.values().addAll()异常
问题:在使用一个Collection.addAll()方法时报告UnsupportedOperationException.追溯原因发现该collection是来自于hashMap.values(). ...
- 10+ commonly using find command switches with example Unix/Linux
http://crybit.com/find-command-usage-with-example-unixlinux/ find command is one of the best search ...
- 设计模式--命令(Command)模式
模式定义 将一个请求(行为)封装为一个对象,从而使你可用不同的请求对客户进行参数化,对请求排队或记录请求日志,以及支持可撤销的操作 类图 要点总结 Command模式的根本目的在于将"行为请 ...
最新文章
- 帧中继-实验(第三篇)
- java list详解_Java 中 list 用法案例详解
- mesh和wifi中继的区别_小米官方科普路由器Mesh功能,它和普通的中继有什么区别...
- ARM LDR与MOV的区别
- Java返回int型的空值_使用MyBatis查询int类型字段,返回NULL值时报异常的解决方法...
- GCC的内嵌汇编语法 ATT汇编语言语法
- 最长回文子串--动态规划
- C# HttpWebRequest 填充IP代理
- 洛谷1004方格取数
- MySQL int类型的显示
- NIVC-gt;IPR[IPADDR]
- java 集合教程_Java Collections
- 1. 制作软盘启动镜像.md
- CPU卡密钥管理系统
- d520笔记本linux无线网卡驱动下载,无线网卡万能驱动
- java8中的闭包Function/BiFunction
- 使用 Kind 在 5 分钟内快速部署一个 Kubernetes 高可用集群
- android 钉钉考勤日历,Flutter仿钉钉考勤日历
- 爬虫与数据分析(二)
- mfc程序退出时删除托盘图标