uptime-status/uptimestatus/utils.py

16 lines
483 B
Python
Raw Normal View History

2021-05-15 14:31:07 +02:00
#!/usr/bin/env python3
def ratio_to_status(ratio):
if ratio > 0.99:
return "ok"
elif ratio > 0.8:
return "warning"
else:
return "critical"
def process_instance(instance):
return {
"name": instance["metric"]["instance"].split(".")[0],
"i": [{"status": "unknown", "ratio": None} for i in range(56 - len(instance["values"]))] + [{"status": ratio_to_status(float(i[1])), "ratio": float(i[1])} for i in instance["values"]],
}