You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For really really broken disks, the temperature may not be read, and therefore is set to N/A.
In this case, trying to read the Fahrenheit values fails with exception
Traceback (most recent call last):
File "megacli.py", line 309, in <module>
main()
File "megacli.py", line 298, in main
exec(a)
File "<string>", line 1, in <module>
IndexError: list index out of range
Additionally, passing N/A to Prometheus leads to a syntax error on Prometheus side, since it expects only numbers.
I changed the output logic to:
for k,v in out.iteritems():
print("# HELP " + k + " " + v['help'])
print("# TYPE " + k + " " + v['type'])
for m in v['metrics']:
clean = str(m['val'])
if clean.replace('.','',1).isdigit() == False:
clean = '0'
print ( str(k) + '{' + ', '.join([ "{}=\"{}\"".format(str(l),str(m['labels'][l])) for l in sorted(m['labels']) ]) + '} ' + clean )
For really really broken disks, the temperature may not be read, and therefore is set to
N/A
.In this case, trying to read the Fahrenheit values fails with exception
The input data that leads to this exception is:
line:
Drive Temperature : N/A
a:
out["megacli_pd_temperature"]["metrics"].append({ "labels": { "adapter": adapter, "enclosure": enclosure, "slot": slot, "type": "barbarians" }, "val": line.split("(")[1].split(" ")[0].strip() })
Since the input does not contain an opening bracket, the splitting does not create an array with at least two elements, so accessing index 1 fails.
The text was updated successfully, but these errors were encountered: