#!/bin/bash # 读取 Uptime Kuma 数据库结构(只读),评估批量添加监控的可行路径 python3 - <<'PY' import sqlite3 con = sqlite3.connect("file:/data/uptime-kuma/kuma.db?mode=ro", uri=True) cur = con.cursor() print("===== all tables =====") for (n,) in cur.execute("select name from sqlite_master where type='table' order by name"): print(n) for name in ("user", "monitor", "monitor_notification", "monitor_tag", "tag", "notification"): r = cur.execute("select sql from sqlite_master where type='table' and name=?", (name,)).fetchone() print("\n===== schema: %s =====" % name) print(r[0] if r else "NOT FOUND") print("\n===== users =====") try: for row in cur.execute("select id, username, active from user"): print(row) except Exception as e: print("err:", e) print("\n===== monitor count =====") print(cur.execute("select count(*) from monitor").fetchone()) print("\n===== monitor columns (pragma) =====") for row in cur.execute("pragma table_info(monitor)"): print(row) PY