Переглянути джерело

Allow SMART self test to recover themselves

tags/0.4.1
Johann Schmitz 2 роки тому
джерело
коміт
ae7c1a7b74

+ 4
- 1
smartcheck/__main__.py Переглянути файл

@@ -47,6 +47,9 @@ def main():
parser.add_argument('-x', '--exclude-notices', help='Do not report NOTICE warnings (default: %(default)s)', action='store_true', default=False)
parser.add_argument('-n', '--notices-are-warnings', help='Exit with status code 1 on NOTICEs too (default: %(default)s)', action='store_true', default=False)

parser.add_argument('--accept-recovered-self-test', action='store_true', default=False,
help='Only check the latest self test (accept a newer self tests without error)')

parser.add_argument('--ignore-attributes', help='Ignore this S.M.A.R.T. attributes (id or name)', nargs='*')
parser.add_argument('-v', '--verbose', help='Verbose messages', action='store_true', default=False)
parser.add_argument('--debug', help="Print debug messages", action="store_true", default=False)
@@ -102,7 +105,7 @@ def main():
if any((ae.level == AttributeWarning.Critical for ae in attribute_errors.values())):
exit_code = 2

if not check.check_tests():
if not check.check_tests(latest_only=args.accept_recovered_self_test):
msg = (msg.strip() + '; S.M.A.R.T. self test reported an error').lstrip(';').strip()
exit_code = 2


+ 4
- 1
smartcheck/check.py Переглянути файл

@@ -248,12 +248,15 @@ class SMARTCheck(object):
def check(self, ignore_attributes=None):
return len(self.check_attributes(ignore_attributes or [])) == 0 and self.check_tests() and self.ata_error_count == 0

def check_tests(self):
def check_tests(self, latest_only=False):
ok_test_results = [
'Completed without error',
'Interrupted (host reset)', # reboot during self test
'Aborted by host'
]
if latest_only and self.self_tests['test_results']:
return not self.self_tests['test_results'][2] in ok_test_results

return not any([x[2] not in ok_test_results for x in self.self_tests['test_results']])

def check_attributes(self, ignore_attributes=None):

+ 12
- 0
tests/check.py Переглянути файл

@@ -6,6 +6,7 @@ from smartcheck.check import SMARTCheck, AttributeWarning, parse_range_specifier
samples_path = os.path.join(os.path.dirname(__file__), 'samples')
db_path = os.path.join(samples_path, '../../smartcheck/disks.yaml')


class CheckTest(unittest.TestCase):

def test_check_broken1(self):
@@ -181,6 +182,17 @@ ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_
(5, 'Reallocated_Sector_Ct'): AttributeWarning(AttributeWarning.Notice, 'Reallocated_Sector_Ct', 84)
})

def test_check_recovered_self_tests(self):
with open(os.path.join(samples_path, 'seagate-barracuda-broken2.txt')) as f:
check = SMARTCheck(f)
self.assertFalse(check.check_tests())
self.assertFalse(check.check())

with open(os.path.join(samples_path, 'seagate-barracuda-broken2.txt')) as f:
check = SMARTCheck(f)
self.assertTrue(check.check_tests(latest_only=True))
self.assertFalse(check.check())

def test_parse_range_specifier(self):
# greater than
f = parse_range_specifier(1)

+ 116
- 0
tests/samples/wdc-wd2000fyyz-recovered.txt Переглянути файл

@@ -0,0 +1,116 @@
smartctl 6.3 2014-07-26 r3976 [x86_64-linux-4.4.26-gentoo-cit-1] (local build)
Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Western Digital RE4 (SATA 6Gb/s)
Device Model: WDC WD2000FYYZ-01UL1B2
Serial Number: WD-WMC1P0DCMTW3
LU WWN Device Id: 5 0014ee 0ae9a25c2
Firmware Version: 01.01K03
User Capacity: 2.000.398.934.016 bytes [2,00 TB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 7200 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS (minor revision not indicated)
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Wed Dec 14 16:00:46 2016 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x84) Offline data collection activity
was suspended by an interrupting command from host.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (26100) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 285) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x70bd) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 0
3 Spin_Up_Time 0x0027 100 253 021 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 4
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0
9 Power_On_Hours 0x0032 082 082 000 Old_age Always - 13384
10 Spin_Retry_Count 0x0032 100 253 000 Old_age Always - 0
11 Calibration_Retry_Count 0x0032 100 253 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 4
183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 1
193 Load_Cycle_Count 0x0032 200 200 000 Old_age Always - 2
194 Temperature_Celsius 0x0022 122 117 000 Old_age Always - 28
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 6

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Extended offline Completed without error 00% 13360 -
# 2 Extended offline Completed without error 00% 13286 -
# 3 Extended offline Completed without error 00% 13238 -
# 4 Extended offline Completed without error 00% 13189 -
# 5 Extended offline Completed without error 00% 13165 -
# 6 Short offline Completed without error 00% 13161 -
# 7 Extended offline Completed: read failure 10% 13119 3907004231
# 8 Extended offline Completed without error 00% 12951 -
# 9 Extended offline Completed without error 00% 12783 -
#10 Extended offline Completed without error 00% 12615 -
#11 Extended offline Completed without error 00% 12452 -
#12 Extended offline Completed without error 00% 12278 -
#13 Extended offline Completed without error 00% 12111 -
#14 Extended offline Completed without error 00% 11943 -
#15 Extended offline Completed without error 00% 11775 -
#16 Extended offline Completed without error 00% 11612 -
#17 Extended offline Completed without error 00% 11439 -
#18 Extended offline Completed without error 00% 11272 -
#19 Extended offline Completed without error 00% 11104 -
#20 Extended offline Completed without error 00% 10936 -
#21 Extended offline Completed without error 00% 10768 -
1 of 1 failed self-tests are outdated by newer successful extended offline self-test # 1

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

Завантаження…
Відмінити
Зберегти