Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fail if 'total data bytes written' is zero #71

Merged
merged 5 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions pySMART/interface/nvme.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,26 @@ def parse(self, data: Iterator[str]) -> None:
self.percentageUsed = int(value[:-1])
elif name == 'Data Units Read':
# Format: 1,234,567 [2.00 TB]
self.dataUnitsRead = int(
value.split(' ')[0].replace(',', '').replace('.', '').replace('’', ''))
self.bytesRead = humanfriendly.parse_size(
value.split(' ', 1)[1][1:-1].replace(',', '.'))
# Or : 0
if value.isdigit():
self.dataUnitsRead = int(value)
self.bytesRead = int(value)
else:
self.dataUnitsRead = int(
value.split(' ')[0].replace(',', '').replace('.', '').replace('’', ''))
self.bytesRead = humanfriendly.parse_size(
value.split(' ', 1)[1][1:-1].replace(',', '.'))
elif name == 'Data Units Written':
# Format: 1,234,567 [2.00 TB]
self.dataUnitsWritten = int(
value.split(' ')[0].replace(',', '').replace('.', '').replace('’', ''))
self.bytesWritten = humanfriendly.parse_size(
value.split(' ', 1)[1][1:-1].replace(',', '.'))
# Or : 0
if value.isdigit():
self.dataUnitsWritten = int(value)
self.bytesWritten = int(value)
else:
self.dataUnitsWritten = int(
value.split(' ')[0].replace(',', '').replace('.', '').replace('’', ''))
self.bytesWritten = humanfriendly.parse_size(
value.split(' ', 1)[1][1:-1].replace(',', '.'))
elif name == 'Host Read Commands':
self.hostReadCommands = int(
value.replace(',', '').replace('.', '').replace('’', ''))
Expand Down
64 changes: 64 additions & 0 deletions tests/dataset/singletests/nvme_8/_-d_nvme_--all__dev_nvme0n1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.103] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number: WDS200T1X0E-00AFY0
Serial Number: XXXXXXXXXXXX
Firmware Version: 614600WD
PCI Vendor/Subsystem ID: 0x15b7
IEEE OUI Identifier: 0x001b44
Total NVM Capacity: 2’000’398’934’016 [2.00 TB]
Unallocated NVM Capacity: 0
Controller ID: 8224
NVMe Version: 1.4
Number of Namespaces: 1
Namespace 1 Size/Capacity: 2’000’398’934’016 [2.00 TB]
Namespace 1 Formatted LBA Size: 512
Namespace 1 IEEE EUI-64: 001b44 8b451ffb99
Local Time is: Thu Mar 23 21:15:53 2023 CET
Firmware Updates (0x14): 2 Slots, no Reset required
Optional Admin Commands (0x0017): Security Format Frmw_DL Self_Test
Optional NVM Commands (0x005f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
Log Page Attributes (0x1e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg Pers_Ev_Lg
Maximum Data Transfer Size: 128 Pages
Warning Comp. Temp. Threshold: 84 Celsius
Critical Comp. Temp. Threshold: 88 Celsius
Namespace 1 Features (0x02): NA_Fields

Supported Power States
St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat
0 + 9.00W 9.00W - 0 0 0 0 0 0
1 + 4.10W 4.10W - 0 0 0 0 0 0
2 + 3.50W 3.50W - 0 0 0 0 0 0
3 - 0.0250W - - 3 3 3 3 5000 10000
4 - 0.0050W - - 4 4 4 4 3900 45700

Supported LBA Sizes (NSID 0x1)
Id Fmt Data Metadt Rel_Perf
0 + 512 0 2
1 - 4096 0 1

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

SMART/Health Information (NVMe Log 0x02)
Critical Warning: 0x00
Temperature: 44 Celsius
Available Spare: 100%
Available Spare Threshold: 10%
Percentage Used: 0%
Data Units Read: 0
Data Units Written: 0
Host Read Commands: 0
Host Write Commands: 0
Controller Busy Time: 403
Power Cycles: 25
Power On Hours: 3’457
Unsafe Shutdowns: 10
Media and Data Integrity Errors: 0
Error Information Log Entries: 0
Warning Comp. Temperature Time: 0
Critical Comp. Temperature Time: 0

Error Information (NVMe Log 0x01, 16 of 256 entries)
No Errors Logged
Loading