Handle some raw values which aren't simple integers
This commit is contained in:
parent
1a7003fef2
commit
aa66f8d615
|
@ -20,8 +20,14 @@ for ln in p.stdout.splitlines():
|
|||
elif state == 1 and ln == "":
|
||||
state = 2
|
||||
elif state == 1:
|
||||
(id, attribute_name, flag, value, worst, thresh, type, updated, when_failed, raw_value) = ln.split()
|
||||
(id, attribute_name, flag, value, worst, thresh, type, updated, when_failed, raw_value) = ln.split(None, 9)
|
||||
|
||||
if attribute_name == "Command_Timeout":
|
||||
# This is a tuple of three values and I don't know what they mean
|
||||
# so I just skip them.
|
||||
# I guess I could just record them as smart_command_timeout_1,
|
||||
# smart_command_timeout_2 and smart_command_timeout_3 ...
|
||||
continue
|
||||
if "_Ct" in attribute_name or "_Count" in attribute_name or "_Cnt" in attribute_name:
|
||||
unit = "count"
|
||||
elif "_Hours" in attribute_name:
|
||||
|
@ -33,11 +39,23 @@ for ln in p.stdout.splitlines():
|
|||
else:
|
||||
unit = "unknown"
|
||||
|
||||
if unit == "°C":
|
||||
# Sometimes there is extra information included - just ignore that.
|
||||
value = int(raw_value.split()[0])
|
||||
elif unit == "hours":
|
||||
if m := re.match(r"([0-9]+)h\+([0-9]+)m\+([0-9.]+)s", raw_value):
|
||||
# e.g. 60633h+54m+11.557s
|
||||
value = (int(m.group(1)) * 3600 + int(m.group(2)) * 60 + float(m.group(2))) / 3600
|
||||
else:
|
||||
value = int(raw_value)
|
||||
else:
|
||||
value = int(raw_value)
|
||||
|
||||
report0.append(
|
||||
{
|
||||
"measure": "smart_" + attribute_name.lower(),
|
||||
"unit": unit,
|
||||
"value": int(raw_value),
|
||||
"value": value,
|
||||
})
|
||||
now = time.time()
|
||||
report = [
|
||||
|
|
Loading…
Reference in New Issue