Skip to content

Commit

Permalink
NEW: zSmartIgnoreUnsupported control, SCSI & NVMe improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
daviswr committed Nov 14, 2021
1 parent 21f0d7e commit d22ab59
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
35 changes: 29 additions & 6 deletions ZenPacks/daviswr/SMART/modeler/plugins/daviswr/cmd/SMART.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def process(self, device, results, log):
else:
log.debug('%s: zSmartDiskMapMatch not set', device.id)

skip_unsupport = getattr(device, 'zSmartIgnoreUnsupported', '')
if skip_unsupport:
log.debug('%s: zSmartIgnoreUnsupported set', device.id)
else:
log.debug('%s: zSmartIgnoreUnsupported not set', device.id)

# Example: 512 bytes logical, 4096 bytes physical
sector_re = r'(\d+) bytes logical, (\d+) bytes physical'

Expand Down Expand Up @@ -150,18 +156,23 @@ def process(self, device, results, log):
dev_map['LogicalSector'] = value
elif 'Physical block size' in key_raw:
dev_map['PhysicalSector'] = value
elif 'Formatted LBA Size' in key_raw:
dev_map['LogicalSector'] = value
elif key in ['SataVersion', 'TransportProtocol']:
dev_map['TransportType'] = value
elif key_raw == 'SMART support':
# This comes from a datapoint rather
# than modeled attribute
continue
elif 'Total NVM Capacity' in key_raw:
dev_map['UserCapacity'] = value
elif key_raw.startswith('AAM'):
key = 'AamFeature'
elif key_raw.startswith('APM'):
key = 'ApmFeature'
elif 'Product' == key and 'DeviceModel' not in dev_map:
elif (key in ['Product', 'ModelNumber']
and 'DeviceModel' not in dev_map):
dev_map['DeviceModel'] = value
elif key_raw == 'SMART support':
# This comes from a datapoint rather
# than modeled attribute
continue
dev_map[key] = value

if dev_map.get('DevicePath', None):
Expand All @@ -171,13 +182,20 @@ def process(self, device, results, log):
device.id,
dev_map['DevicePath']
)
elif (('Unavailable - device lacks SMART capability' in dev
or 'Operation not supported by device' in dev)
and skip_unsupport):
log.info(
'%s: %s does not support SMART, ignoring',
device.id,
dev_map['DevicePath']
)
else:
dev_map['title'] = dev_map['DevicePath'].replace(
'--device',
'-d'
)
dev_map['id'] = self.prepId(gen_comp_id(dev_map['title']))
om = ObjectMap(modname=self.modname, data=dev_map)
# Model fixup for SCSI devices
if (dev_map.get('Vendor', None)
and dev_map.get('Product', None)):
Expand All @@ -186,6 +204,11 @@ def process(self, device, results, log):
dev_map['Vendor'],
dev_map['Product']
)
# NVMe form-factor
if ('FormFactor' not in dev_map
and 'M.2' in dev_map.get('DeviceModel', '')):
dev_map['FormFactor'] = 'M.2'
om = ObjectMap(modname=self.modname, data=dev_map)
model = dev_map.get('DeviceModel', '').replace('_', ' ')
if model:
if ' ' in model:
Expand Down
3 changes: 3 additions & 0 deletions ZenPacks/daviswr/SMART/zenpack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ zProperties:
category: SMART
zSmartDiskMapMatch:
type: string
zSmartIgnoreUnsupported:
type: boolean
default: true


device_classes:
Expand Down

0 comments on commit d22ab59

Please sign in to comment.