Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,18 @@
host: https://homeserver.local
ssc: True
expected_code: 200

- title: 'Group 4 / HPC'
checks:
- name: Slurm HPC Cluster
type: slurm
system: viper
expected: up
path: "../hpc/generic.json"
key_to_system: "systems"

- name: HPC Cluster Nodes
type: nodes
system: viper
path: "../hpc/generic.json"
key_to_system: "systems"
7 changes: 7 additions & 0 deletions index.html.theme
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@
<a target="_blank" href="{{ check.url }}">
{% endif %}
<div class="status-item">
{% if check.nodes %}
<h3>{{ check.name }}</h3>
{% for k, v in check.nodes.items() %}
{{ k }}: {{ v }}<br />
{% endfor %}
</div>
{% else %}
<h3>{{ check.name }}</h3>
<p class="{% if check.status %}status-up{% else %}status-down{% endif %}">
{{ '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 256 256"><path d="M225.86,102.82c-3.77-3.94-7.67-8-9.14-11.57-1.36-3.27-1.44-8.69-1.52-13.94-.15-9.76-.31-20.82-8-28.51s-18.75-7.85-28.51-8c-5.25-.08-10.67-.16-13.94-1.52-3.56-1.47-7.63-5.37-11.57-9.14C146.28,23.51,138.44,16,128,16s-18.27,7.51-25.18,14.14c-3.94,3.77-8,7.67-11.57,9.14C88,40.64,82.56,40.72,77.31,40.8c-9.76.15-20.82.31-28.51,8S41,67.55,40.8,77.31c-.08,5.25-.16,10.67-1.52,13.94-1.47,3.56-5.37,7.63-9.14,11.57C23.51,109.72,16,117.56,16,128s7.51,18.27,14.14,25.18c3.77,3.94,7.67,8,9.14,11.57,1.36,3.27,1.44,8.69,1.52,13.94.15,9.76.31,20.82,8,28.51s18.75,7.85,28.51,8c5.25.08,10.67.16,13.94,1.52,3.56,1.47,7.63,5.37,11.57,9.14C109.72,232.49,117.56,240,128,240s18.27-7.51,25.18-14.14c3.94-3.77,8-7.67,11.57-9.14,3.27-1.36,8.69-1.44,13.94-1.52,9.76-.15,20.82-.31,28.51-8s7.85-18.75,8-28.51c.08-5.25.16-10.67,1.52-13.94,1.47-3.56,5.37-7.63,9.14-11.57C232.49,146.28,240,138.44,240,128S232.49,109.73,225.86,102.82Zm-52.2,6.84-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z"></path></svg> Operational' if check.status else '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 256 256"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm37.66,130.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path></svg> Down' }}
Expand Down
42 changes: 40 additions & 2 deletions tinystatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ async def check_port(host, port):
return True
except:
return False

async def check_slurm(expected, system, path, key_to_system):
try:
with open(path, "r") as file:
data = json.load(file)
slurm = data[key_to_system][system]
if slurm["state"] == expected:
return True
else:
print(f"SLURM check failed: {slurm["state"]} != {expected}")
return False

except aiohttp.ClientError as err:
print("Network error during SLURM check: ", err)
return False
except Exception as err:
print("Unexpected error with ", err)
return False

async def check_nodes(system, path, key_to_system):
try:
with open(path, "r") as file:
data = json.load(file)
nodes = data[key_to_system][system]["nodes"]
return nodes

except aiohttp.ClientError as err:
print("Network error during SLURM check: ", err)
return []
except Exception as err:
print("Unexpected error with", err)
return []


async def run_checks(checks):
Expand All @@ -76,17 +108,23 @@ async def run_checks(checks):
task = tg.create_task(
check_http(check['host'], check['expected_code'], selfcert) if check['type'] == 'http' else
check_ping(check['host']) if check['type'] == 'ping' else
check_port(check['host'], check['port']) if check['type'] == 'port' else None,
check_port(check['host'], check['port']) if check['type'] == 'port' else
check_slurm(check['expected'], check['system'], check['path'], check['key_to_system']) if check['type'] == 'slurm' else
check_nodes(check['system'], check['path'], check['key_to_system']) if check['type'] == 'nodes' else None,
name=check['name']
)
if task:
background_tasks[check['name']] = task


results = [
{
"name": check["name"],
"url": check.get("url"),
"status": background_tasks[check["name"]].result()}
"status": background_tasks[check["name"]].result(),
**({"nodes": await check_nodes(check["system"], check["path"], check["key_to_system"]) }
if check["type"] == "nodes" else {})
}
for check in checks
]

Expand Down