Fix bug with SMART info

This commit is contained in:
Joshua Boniface 2023-02-23 13:21:23 -05:00
parent bcff6650d0
commit 4c2d99f8a6
1 changed files with 2 additions and 2 deletions

View File

@ -129,7 +129,7 @@ class MonitoringPluginScript(MonitoringPlugin):
continue
if disk_type == 'nvme':
for attribute in smart_info['nvme_smart_health_information_log'].items():
for attribute in smart_info.get('nvme_smart_health_information_log', {}).items():
if attribute[0] == "critical_warning" and attribute[1] > 0:
health_delta += 10
messages.append(f"{disk} critical warning value {attribute[1]}")
@ -140,7 +140,7 @@ class MonitoringPluginScript(MonitoringPlugin):
health_delta += 10
messages.append(f"{disk} percentage used value {attribute[1]}%")
else:
for attribute in smart_info['ata_smart_attributes']['table']:
for attribute in smart_info.get('ata_smart_attributes', {}).get('table', []):
if attribute["when_failed"]:
health_delta += 10
messages.append(f"{disk} attribute {attribute['name']} value {attribute['raw']['value']}")