summaryrefslogtreecommitdiff
path: root/hetzner-admin
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-10-31 19:28:45 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-10-31 19:28:45 +0900
commitff39e864a0b7e9a98340bf564a7a4bf566958a77 (patch)
tree1f3f6db573956f4debb43bbbf605b6fde8bc8cf3 /hetzner-admin
parent01e7d14bf9f1cf3b9a5879ffbe4a8f0b5f553323 (diff)
Consolidate status pages into status.yyamashita.com
Drop Uptime Kuma (uptime.yyamashita.com) and the hetzner-admin /status page; status-app + ntfy alerts is the single status site. hetzner-admin now just links to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'hetzner-admin')
-rw-r--r--hetzner-admin/app.py67
-rwxr-xr-xhetzner-admin/run-command.sh3
2 files changed, 1 insertions, 69 deletions
diff --git a/hetzner-admin/app.py b/hetzner-admin/app.py
index 274364e..abef6a9 100644
--- a/hetzner-admin/app.py
+++ b/hetzner-admin/app.py
@@ -1,7 +1,5 @@
import functools
-import json
import os
-import urllib.request
import paramiko
from flask import Flask, Response, render_template_string, request
@@ -14,10 +12,6 @@ SSH_HOST = os.environ.get("SSH_HOST", "host.docker.internal")
SSH_PORT = int(os.environ.get("SSH_PORT", "22"))
SSH_USER = os.environ.get("SSH_USER", "root")
SSH_KEY_PATH = os.environ.get("SSH_KEY_PATH", "/app/id_rsa")
-STATUS_API = os.environ.get("STATUS_API", "http://status-app:8080/api/status")
-
-# /status ページでコンテナ一覧を取るコマンド(run-command.sh のホワイトリストに要登録)
-STATUS_COMMAND = "docker ps -a --format '{{.Names}}|{{.Status}}'"
COMMANDS = [
("Docker Status", "docker ps"),
@@ -36,7 +30,7 @@ HTML = """<!DOCTYPE html>
<head><title>Server Admin</title></head>
<body>
<h3>Server Admin</h3>
-<p><a href="/status">Status</a></p>
+<p><a href="https://status.yyamashita.com">Status</a></p>
{% for label, _ in commands %}
<form method="post" action="/run" style="display:block;margin-bottom:8px">
<input type="hidden" name="cmd" value="{{ label }}">
@@ -54,40 +48,6 @@ HTML = """<!DOCTYPE html>
</body>
</html>"""
-STATUS_HTML = """<!DOCTYPE html>
-<html>
-<head><title>Server Status</title><meta http-equiv="refresh" content="60"></head>
-<body>
-<h3>Server Status</h3>
-<p><a href="/">&larr; Admin</a></p>
-<h4>Services</h4>
-{% if services is none %}
-<pre>{{ services_error }}</pre>
-{% else %}
-<table border="1" cellpadding="4" style="border-collapse:collapse">
-<tr><th>Service</th><th>State</th><th>Detail</th><th>Latency</th><th>Uptime</th></tr>
-{% for s in services %}
-<tr><td>{{ s.name }}</td>
-<td style="color:{{ 'green' if s.up else 'red' }}">{{ 'UP' if s.up else 'DOWN' }}</td>
-<td>{{ s.detail }}</td><td>{{ s.ms }} ms</td><td>{{ s.uptime }}%</td></tr>
-{% endfor %}
-</table>
-{% endif %}
-<h4>Containers</h4>
-{% if containers is none %}
-<pre>{{ containers_error }}</pre>
-{% else %}
-<table border="1" cellpadding="4" style="border-collapse:collapse">
-<tr><th>Container</th><th>Status</th></tr>
-{% for name, st in containers %}
-<tr><td>{{ name }}</td>
-<td style="color:{{ 'green' if st.startswith('Up') and '(unhealthy)' not in st else 'red' }}">{{ st }}</td></tr>
-{% endfor %}
-</table>
-{% endif %}
-</body>
-</html>"""
-
def requires_auth(f):
@functools.wraps(f)
@@ -135,28 +95,3 @@ def run():
except Exception as e:
output = f"Error: {e}"
return render_template_string(HTML, commands=COMMANDS, output=output)
-
-
-@app.route("/status")
-@requires_auth
-def status():
- services = services_error = containers = containers_error = None
- try:
- with urllib.request.urlopen(STATUS_API, timeout=5) as r:
- services = json.load(r)["services"]
- except Exception as e:
- services_error = f"status-app に接続できない: {e}"
- try:
- out = run_ssh(STATUS_COMMAND)
- containers = sorted(
- tuple(line.split("|", 1)) for line in out.splitlines() if "|" in line
- )
- except Exception as e:
- containers_error = f"Error: {e}"
- return render_template_string(
- STATUS_HTML,
- services=services,
- services_error=services_error,
- containers=containers,
- containers_error=containers_error,
- )
diff --git a/hetzner-admin/run-command.sh b/hetzner-admin/run-command.sh
index 12f96bf..0ed9fe3 100755
--- a/hetzner-admin/run-command.sh
+++ b/hetzner-admin/run-command.sh
@@ -6,9 +6,6 @@ case "$SSH_ORIGINAL_COMMAND" in
"docker ps")
exec docker ps
;;
- "docker ps -a --format '{{.Names}}|{{.Status}}'")
- exec docker ps -a --format '{{.Names}}|{{.Status}}'
- ;;
"docker compose -f /app/infra/caddy/docker-compose.yml restart")
exec docker compose -f /app/infra/caddy/docker-compose.yml restart
;;