From ff39e864a0b7e9a98340bf564a7a4bf566958a77 Mon Sep 17 00:00:00 2001 From: yyamashita Date: Sat, 31 Oct 2026 19:28:45 +0900 Subject: 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 --- hetzner-admin/app.py | 67 +------------------------------------------- hetzner-admin/run-command.sh | 3 -- 2 files changed, 1 insertion(+), 69 deletions(-) (limited to 'hetzner-admin') 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 = """ Server Admin

Server Admin

-

Status

+

Status

{% for label, _ in commands %}
@@ -54,40 +48,6 @@ HTML = """ """ -STATUS_HTML = """ - -Server Status - -

Server Status

-

← Admin

-

Services

-{% if services is none %} -
{{ services_error }}
-{% else %} - - -{% for s in services %} - - - -{% endfor %} -
ServiceStateDetailLatencyUptime
{{ s.name }}{{ 'UP' if s.up else 'DOWN' }}{{ s.detail }}{{ s.ms }} ms{{ s.uptime }}%
-{% endif %} -

Containers

-{% if containers is none %} -
{{ containers_error }}
-{% else %} - - -{% for name, st in containers %} - - -{% endfor %} -
ContainerStatus
{{ name }}{{ st }}
-{% endif %} - -""" - 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 ;; -- cgit v1.3