updog-checker_template/checker_template.py

21 lines
600 B
Python
Raw Permalink Normal View History

2024-01-29 11:34:31 -06:00
import random
class CheckerTemplate:
# has `self` since checkers *should* have instances
# it's not actually needed here though since it's just static methods
def __init__(self, arguments):
2024-01-29 11:34:31 -06:00
pass
def get_status(self):
2024-01-29 11:34:31 -06:00
latency = int(random.random() * 3000)
if latency > 2500: # "simulate" a timeout
return 0
elif latency > 1000: # "simulate" a very slow application - a partial outage
return 50
else:
return 100
def get_return_codes(self):
2024-01-29 11:34:31 -06:00
return {0: "Down", 50: "Partial outage", 100: "Up"}