29 lines
1.0 KiB
Bash
29 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# 复核监控状态:状态码含义 0=DOWN 1=UP 2=PENDING 3=MAINTENANCE
|
|
sleep 25
|
|
sudo python3 - <<'PY'
|
|
import sqlite3
|
|
con = sqlite3.connect("file:/data/uptime-kuma/kuma.db?mode=ro", uri=True)
|
|
|
|
print("=== name encoding check (chars, first bytes hex) ===")
|
|
for row in con.execute("select id, name, length(name), hex(substr(name,1,4)) from monitor order by id limit 3"):
|
|
print(" ", row)
|
|
|
|
print()
|
|
print("=== latest status per monitor ===")
|
|
q = """
|
|
select m.id, m.name, h.status, h.time, h.msg
|
|
from monitor m
|
|
left join heartbeat h on h.id = (select max(id) from heartbeat where monitor_id = m.id)
|
|
order by m.weight, m.id
|
|
"""
|
|
label = {0: "DOWN", 1: "UP", 2: "PENDING", 3: "MAINTENANCE"}
|
|
for mid, name, status, time, msg in con.execute(q):
|
|
st = label.get(status, status)
|
|
print(" id=%s [%-11s] %s (%s) %s" % (mid, st, name, time, (msg or "")[:60]))
|
|
|
|
print()
|
|
print("heartbeat total:", con.execute("select count(*) from heartbeat").fetchone()[0])
|
|
print("tls_info rows:", con.execute("select count(*) from monitor_tls_info").fetchone()[0])
|
|
PY
|