Skip to content
Merged
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ checks every service and rolls back on its own. The web UI, the CLI and AI agent
|---|---|
| <img src="docs/assets/shot-mobile.png" alt="手机端" width="440"> | <img src="docs/assets/shot-proxy.png" alt="代理节点" width="440"> |

<p align="center"><img src="docs/assets/shot-devices-dark.png" alt="每设备流量(深色主题)" width="920"><br>
<sub>每设备实时流量(深色主题)。截图均为演示数据。</sub></p>
<p align="center"><img src="docs/assets/shot-monitor.png" alt="实时监控(深色主题)" width="920"><br>
<sub>实时监控:CPU / 内存 / 存储占用、每核 CPU 构成、接口流量(深色主题)。截图均为演示数据。</sub></p>

## 功能 / Features

Expand All @@ -67,7 +67,7 @@ checks every service and rolls back on its own. The web UI, the CLI and AI agent
| DNS / DHCP | dnsmasq:DHCP 静态分配与选项、IPv6 RA / DHCPv6、本地记录(A/AAAA/CNAME/SRV…)、DNS 分流、DoT(stubby)、统计与临时查询日志 |
| 防火墙 fw | nftables:区域、端口转发(来源限制 / 线路选择 / NAT 回流)、IPv6 入站(按接口标识,前缀变化也有效)、通信规则(含时间段)、设备上网管控、硬件 / 软件流量卸载 |
| 代理 proxy | sing-box 选择性透明代理:fake-ip + nftables tproxy,只有命中规则的域名 / IP 进代理;全协议节点、节点组(自动测速 / 手选)、分享链接与订阅、例外设备 |
| 监控 mon | 实时流量 / CPU / 内存图、24 小时历史、每设备流量、连接表、进程与内核日志 |
| 监控 mon | 占用仪表(CPU / 内存 / 连接数 / 温度 / 存储)、每核 CPU 构成、内存构成、实时流量图、24 小时历史、每设备流量、连接表、进程与内核日志 |
| 系统 sys | 时区 / NTP、SSH 与密钥、计划任务、备份恢复、固件升级、服务管理、日志、诊断(ping / traceroute / nslookup) |

刻意**不做**的:WireGuard 服务端、SQM、UPnP、广告过滤这类“有了更像 OpenWrt”的功能——每个功能都要对得起它占的内存和闪存。
Expand Down
Binary file removed docs/assets/shot-devices-dark.png
Binary file not shown.
Binary file modified docs/assets/shot-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/shot-monitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/shot-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 28 additions & 4 deletions mr/mod_mon.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,35 @@ func monCmd(c *Config, args []string) error {

type monIface struct {
Name string `json:"name"`
Role string `json:"role,omitempty"` // wan | wan-dev | lan | port | wifi | vpn
State string `json:"state"` // operstate: up, down, unknown (ppp/tun report unknown while up)
RX uint64 `json:"rx"` // bytes
Role string `json:"role,omitempty"` // wan | wan-dev | lan | port | wifi | vpn
State string `json:"state"` // up | down | … (operstate; ppp/tun "unknown" resolved by IFF_UP|IFF_RUNNING)
Raw string `json:"oper_raw,omitempty"` // the kernel's operstate when State was derived from the flags
RX uint64 `json:"rx"` // bytes
TX uint64 `json:"tx"`
RXP uint64 `json:"rxp"` // packets
TXP uint64 `json:"txp"`
Err uint64 `json:"err"` // rx + tx errors
Drop uint64 `json:"drop"` // rx + tx drops
}

// monDisk: a filesystem the monitor shows (config storage on flash, /tmp in RAM).
type monDisk struct {
Name string `json:"name"` // config | tmp
Path string `json:"path"`
TotalKB int64 `json:"total_kb"`
AvailKB int64 `json:"avail_kb"`
}

func monDisks() []monDisk {
out := []monDisk{}
for _, d := range []monDisk{{Name: "config", Path: "/etc/mini-router"}, {Name: "tmp", Path: "/tmp"}} {
if d.TotalKB, d.AvailKB = dfKB(d.Path); d.TotalKB > 0 {
out = append(out, d)
}
}
return out
}

type monTemp struct {
Zone string `json:"zone"`
Type string `json:"type"`
Expand All @@ -187,6 +206,7 @@ func monNow(c *Config) map[string]any {
"ct": atoi(strings.TrimSpace(readFile(monPath("/proc/sys/net/netfilter/nf_conntrack_count")))),
"ct_max": atoi(strings.TrimSpace(readFile(monPath("/proc/sys/net/netfilter/nf_conntrack_max")))),
"temps": monTemps(),
"disks": monDisks(),
"ifaces": monIfaces(c),
}
if f := strings.Fields(readFile(monPath("/proc/loadavg"))); len(f) >= 4 {
Expand Down Expand Up @@ -281,8 +301,12 @@ func monIfaces(c *Config) []monIface {
}
n := func(i int) uint64 { v, _ := strconv.ParseUint(f[i], 10, 64); return v }
sys := monPath("/sys/class/net/" + name)
it := monIface{Name: name, Role: roles[name], State: strings.TrimSpace(readFile(sys + "/operstate")),
raw := strings.TrimSpace(readFile(sys + "/operstate"))
it := monIface{Name: name, Role: roles[name], State: effOper(raw, readFile(sys+"/flags")),
RX: n(0), RXP: n(1), TX: n(8), TXP: n(9), Err: n(2) + n(10), Drop: n(3) + n(11)}
if raw != it.State {
it.Raw = raw
}
if it.Role == "" {
switch {
case monExists(sys + "/phy80211"):
Expand Down
8 changes: 6 additions & 2 deletions mr/mod_net_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ type portInfo struct {
AdminUp bool `json:"admin_up"`
Carrier bool `json:"carrier"`
Oper string `json:"oper"`
Speed int `json:"speed,omitempty"` // Mbit/s
OperRaw string `json:"oper_raw,omitempty"` // the kernel's operstate when Oper was derived from the flags (ppp, tun)
Speed int `json:"speed,omitempty"` // Mbit/s
Duplex string `json:"duplex,omitempty"`
MTU int `json:"mtu"`
MAC string `json:"mac,omitempty"`
Expand Down Expand Up @@ -228,7 +229,10 @@ func readPorts(c *Config) []portInfo {
if d == "lo" {
continue
}
p := portInfo{Name: d, Role: roles[d], Oper: sysRead(d, "operstate"), MTU: atoi(sysRead(d, "mtu")), MAC: sysRead(d, "address")}
p := portInfo{Name: d, Role: roles[d], Oper: effOper(sysRead(d, "operstate"), sysRead(d, "flags")), MTU: atoi(sysRead(d, "mtu")), MAC: sysRead(d, "address")}
if raw := sysRead(d, "operstate"); raw != p.Oper {
p.OperRaw = raw
}
flags, _ := strconv.ParseUint(strings.TrimPrefix(sysRead(d, "flags"), "0x"), 16, 32)
p.AdminUp = flags&1 == 1
p.Carrier = sysRead(d, "carrier") == "1"
Expand Down
23 changes: 22 additions & 1 deletion mr/sys.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package main

import "syscall"
import (
"strconv"
"strings"
"syscall"
)

// dfKB returns total and available KiB of the filesystem holding path.
func dfKB(path string) (int64, int64) {
Expand All @@ -11,3 +15,20 @@ func dfKB(path string) (int64, int64) {
bs := int64(s.Bsize)
return int64(s.Blocks) * bs / 1024, int64(s.Bavail) * bs / 1024
}

// effOper: the state to show for a netdev. PPP and tun devices have no carrier and always report operstate
// "unknown" (RFC 2863), even while they carry traffic: then IFF_UP|IFF_RUNNING in sysfs "flags" decides.
func effOper(oper, flags string) string {
oper = strings.TrimSpace(oper)
if oper != "unknown" {
return oper
}
f, err := strconv.ParseUint(strings.TrimPrefix(strings.TrimSpace(flags), "0x"), 16, 32)
if err != nil {
return oper
}
if f&0x1 != 0 && f&0x40 != 0 { // IFF_UP, IFF_RUNNING
return "up"
}
return "down"
}
21 changes: 21 additions & 0 deletions mr/sys_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import "testing"

// effOper: ethernet keeps its operstate; ppp / tun ("unknown") follow IFF_UP|IFF_RUNNING.
func TestEffOper(t *testing.T) {
for _, c := range []struct{ oper, flags, want string }{
{"up", "0x1003", "up"},
{"down", "0x1003", "down"},
{"unknown", "0x10d1", "up"},
{"unknown", "0x1d1\n", "up"},
{"unknown", "0x1090", "down"},
{"unknown", "0x1001", "down"},
{"unknown", "", "unknown"},
{"dormant", "0x10d1", "dormant"},
} {
if got := effOper(c.oper, c.flags); got != c.want {
t.Errorf("effOper(%q, %q) = %q, want %q", c.oper, c.flags, got, c.want)
}
}
}
19 changes: 19 additions & 0 deletions rootfs/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@
.stat .v{font-size:20px;font-weight:600;margin-top:2px}
.stat .s{color:var(--mut);font-size:12px}
.bar{height:6px;background:var(--line);border-radius:3px;margin-top:6px;overflow:hidden}
.grid.gauges{grid-template-columns:repeat(auto-fill,minmax(230px,1fr))}
.gauge{display:flex;align-items:center;gap:14px;padding:14px 16px;margin:0}
.gauge-r{position:relative;width:76px;height:76px;flex:none}
.gauge-r svg{width:100%;height:100%;display:block}
.gauge-p{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;font-variant-numeric:tabular-nums}
.gauge-fg{stroke:var(--acc)}.gauge-fg.ok{stroke:var(--ok)}.gauge-fg.warn{stroke:var(--warn)}.gauge-fg.bad{stroke:var(--bad)}
.gauge-t{min-width:0;flex:1}
.gauge-t .l{color:var(--mut);font-size:12px}
.gauge-t .v{font-size:18px;font-weight:600;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}
.gauge-t .s{color:var(--mut);font-size:12px;overflow:hidden;text-overflow:ellipsis}
.spark{display:block;width:100%;height:26px;margin-top:6px}
.lc{display:flex;gap:6px}
.lc-axis{position:relative;flex:none;width:60px;font-size:10px;color:var(--mut);font-variant-numeric:tabular-nums}
.lc-axis span{position:absolute;right:0;transform:translateY(-50%);white-space:nowrap}
.lc-svg{flex:1;min-width:0;width:100%;display:block}
.bar i{display:block;height:100%;background:var(--acc)}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:7px 10px;border-bottom:1px solid var(--line);vertical-align:middle}
Expand Down Expand Up @@ -129,6 +144,10 @@
.form{grid-template-columns:1fr}
.form label.l{text-align:left;margin-bottom:-6px}
.form .hint{grid-column:1}
.grid.gauges{grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:10px}
.gauge{flex-direction:column;align-items:flex-start;gap:8px;padding:12px}
.gauge-r{width:64px;height:64px}
.gauge-t .v{font-size:16px}
}
</style>
</head>
Expand Down
78 changes: 60 additions & 18 deletions rootfs/www/ui/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,39 +235,78 @@ function tabs(list){
return h("div",{}, strip, body);
}
// lineChart(series, opts): tiny SVG chart. series = [{label, color, points:[[t, v], ...]}];
// opts = {height, fmt: v=>string, max}. Returns an SVG element with a legend.
// opts = {height, fmt: v=>string, max}. The plot stretches to the card's width at a fixed pixel height;
// the value labels are HTML beside it, so neither text nor strokes get distorted.
function lineChart(series, opts){
opts ||= {}; const W=600, H=opts.height||160, P=34;
opts ||= {}; const W=600, H=opts.height||160, T=6, B=4;
const all = series.flatMap(s=>s.points);
if (!all.length) return h("div",{class:"mut"},"(暂无数据)");
const t0=Math.min(...all.map(p=>p[0])), t1=Math.max(...all.map(p=>p[0]))||t0+1;
const vmax = opts.max || Math.max(1, ...all.map(p=>p[1]));
const X=t=>P+(W-P-4)*(t-t0)/Math.max(1,t1-t0), Y=v=>H-16-(H-24)*(v/vmax);
const ns="http://www.w3.org/2000/svg", el=(t,a)=>{ const e=document.createElementNS(ns,t); for(const k in a) e.setAttribute(k,a[k]); return e; };
const svg = el("svg",{viewBox:`0 0 ${W} ${H}`, width:"100%", preserveAspectRatio:"none", style:"display:block"});
const X=t=>W*(t-t0)/Math.max(1,t1-t0), Y=v=>T+(H-T-B)*(1-v/vmax);
const svg = svgEl("svg",{viewBox:`0 0 ${W} ${H}`, preserveAspectRatio:"none", class:"lc-svg", style:`height:${H}px`});
const axis = h("div",{class:"lc-axis", style:`height:${H}px`});
for (let i=0;i<=4;i++){ const v=vmax*i/4, y=Y(v);
svg.append(el("line",{x1:P,x2:W,y1:y,y2:y,stroke:"var(--line)","stroke-width":1}));
const tx=el("text",{x:2,y:y+4,"font-size":10,fill:"var(--mut)"}); tx.textContent=(opts.fmt||String)(v); svg.append(tx); }
svg.append(svgEl("line",{x1:0,x2:W,y1:y,y2:y,stroke:"var(--line)","stroke-width":1,"vector-effect":"non-scaling-stroke"}));
axis.append(h("span",{style:`top:${y.toFixed(1)}px`}, (opts.fmt||String)(v))); }
for (const s of series){ if(!s.points.length) continue;
svg.append(el("polyline",{points:s.points.map(p=>X(p[0]).toFixed(1)+","+Y(p[1]).toFixed(1)).join(" "),fill:"none",stroke:s.color||"var(--acc)","stroke-width":1.6})); }
return h("div",{}, svg, h("div",{class:"row",style:"font-size:12px;margin-top:4px"}, series.map(s=>h("span",{},h("span",{class:"dot",style:"background:"+(s.color||"var(--acc)")}), s.label))));
svg.append(svgEl("polyline",{points:s.points.map(p=>X(p[0]).toFixed(1)+","+Y(p[1]).toFixed(1)).join(" "),fill:"none",stroke:s.color||"var(--acc)",
"stroke-width":1.6,"stroke-linejoin":"round","vector-effect":"non-scaling-stroke"})); }
return h("div",{}, h("div",{class:"lc"}, axis, svg), h("div",{class:"row",style:"font-size:12px;margin-top:4px"}, series.map(s=>h("span",{},h("span",{class:"dot",style:"background:"+(s.color||"var(--acc)")}), s.label))));
}
const COLORS = ["#2f6fed","#1f9d55","#d64545","#c98a0b","#8e44ad","#16a2b8","#e67e22","#7f8c8d"];
const svgEl = (t,a)=>{ const e=document.createElementNS("http://www.w3.org/2000/svg",t); for(const k in a) e.setAttribute(k,a[k]); return e; };
// level(p, warn, bad): "" | "warn" | "bad" — colour class for a usage percentage
function level(p, warn, bad){ return p==null ? "" : p>=(bad||90) ? "bad" : p>=(warn||70) ? "warn" : ""; }
// gauge({label, pct, value, sub, center, lv, extra}): a card with a usage ring (pct 0-100, null = not known yet)
// and its numbers; center overrides the text in the ring (default "NN%"), lv the colour class, extra goes below.
function gauge(o){
const r=30, c=2*Math.PI*r, p = o.pct==null ? 0 : Math.max(0, Math.min(100, o.pct));
const svg = svgEl("svg",{viewBox:"0 0 76 76"});
svg.append(svgEl("circle",{cx:38, cy:38, r, fill:"none", stroke:"var(--line)", "stroke-width":7}),
svgEl("circle",{cx:38, cy:38, r, fill:"none", class:"gauge-fg "+(o.lv ?? level(o.pct)), "stroke-width":7, "stroke-linecap":"round",
"stroke-dasharray":(c*p/100).toFixed(1)+" "+c.toFixed(1), transform:"rotate(-90 38 38)"}));
return h("div",{class:"card gauge"}, h("div",{class:"gauge-r"}, svg, h("div",{class:"gauge-p"}, o.center ?? (o.pct==null ? "…" : Math.round(p)+"%"))),
h("div",{class:"gauge-t"}, h("div",{class:"l"},o.label), h("div",{class:"v"},o.value), o.sub?h("div",{class:"s"},o.sub):null, o.extra||null));
}
// spark(values, color, max): a small area chart of recent values, no axes
function spark(vals, color, max){
const W=120, H=26, col = color||"var(--acc)";
const svg = svgEl("svg",{viewBox:`0 0 ${W} ${H}`, preserveAspectRatio:"none", class:"spark"});
if (!vals || vals.length<2) return svg;
const m = max || Math.max(1e-9, ...vals), X=i=>(i*W/(vals.length-1)).toFixed(1), Y=v=>(H-1-(H-3)*Math.min(1, Math.max(0,v)/m)).toFixed(1);
const line = vals.map((v,i)=>(i?"L":"M")+X(i)+","+Y(v)).join("");
svg.append(svgEl("path",{d:line+"L"+W+","+H+"L0,"+H+"Z", fill:col, "fill-opacity":.13, stroke:"none"}),
svgEl("path",{d:line, fill:"none", stroke:col, "stroke-width":1.5, "vector-effect":"non-scaling-stroke"}));
return svg;
}
// cpuBusy(a, b): busy % between two /proc/stat samples (user nice system idle iowait irq softirq steal)
function cpuBusy(a, b){
if (!a || !b) return null;
const d = b.map((v,i)=>v-(a[i]||0)), tot = d.reduce((x,y)=>x+y,0);
return tot>0 ? Math.max(0, 100-(d[3]+d[4])*100/tot) : null;
}
// confirmBtn(label, question, fn): a red button that asks before running fn.
function confirmBtn(label, question, fn){ return h("button",{class:"btn sm d",onclick:async()=>{ if(!confirm(question)) return; try{ await fn(); }catch(e){ toast(e.message,4000); } }}, label); }

// ---------- core pages ----------
// overview gauges keep a short history for their sparklines (40 points = 2 min at 3 s)
const OV = {cpu:null, h:{cpu:[], mem:[], ct:[]}};
const ovPush = (k, v)=>{ if (v==null) return; const a=OV.h[k]; a.push(v); if (a.length>40) a.shift(); };
registerPage("status", "overview", "总览", 10, async ()=>{
const wrap = h("div");
const draw = async ()=>{
const s = await api("status"); const now = Date.now()/1000;
const [s, m] = await Promise.all([api("status"), api("mon.now").catch(()=>null)]); const now = Date.now()/1000;
const busy = m ? cpuBusy(OV.cpu, m.cpu) : null; if (m) OV.cpu = m.cpu;
const rates = {};
for (const w of s.wan||[]){ const p=S.prevWan[w.name]; if(p&&now>p.t){ rates[w.name]={rx:(w.rx-p.rx)*8/(now-p.t), tx:(w.tx-p.tx)*8/(now-p.t)}; } S.prevWan[w.name]={rx:w.rx,tx:w.tx,t:now}; }
S.status = s;
$("#brandsub").textContent = s.host||"";
$("#hmeta").textContent = (s.version||"")+" · "+(s.kernel||"");
const memUsed = s.mem_total_kb - s.mem_avail_kb;
const stat = (l,v,sub,pct)=>h("div",{class:"card stat"}, h("div",{class:"l"},l), h("div",{class:"v"},v), sub?h("div",{class:"s"},sub):null, pct!==undefined?h("div",{class:"bar"},h("i",{style:"width:"+Math.min(100,pct).toFixed(0)+"%"})):null);
const memUsed = s.mem_total_kb - s.mem_avail_kb, memPct = memUsed*100/s.mem_total_kb, ctPct = s.conntrack*100/s.conntrack_max;
const ovUsed = s.overlay_total_kb - s.overlay_free_kb, temp = s.temp_mc ? s.temp_mc/1000 : null;
ovPush("cpu", busy); ovPush("mem", memPct); ovPush("ct", s.conntrack);
const cores = m && m.cpus ? m.cpus.length+" 核 · " : "";
const wanCards = (s.wan||[]).map(w=>card(h("span",{},h("span",{class:"dot "+(w.up?"ok":"bad")}),"WAN · "+w.name),
h("dl",{class:"kv"}, h("dt",{},"状态"),h("dd",{},w.up?"已连接 · "+fmtDur(w.uptime):"未连接"),
h("dt",{},"IPv4"),h("dd",{class:"mono"},w.ip||"-"), h("dt",{},"接口"),h("dd",{class:"mono"},w.dev),
Expand All @@ -278,18 +317,21 @@ registerPage("status", "overview", "总览", 10, async ()=>{
h("dt",{},"终端"),h("dd",{},w.clients))));
const ts = s.tailscale||{};
wrap.replaceChildren(
h("div",{class:"grid"},
stat("运行时间", fmtDur(s.uptime), "负载 "+s.load),
stat("内存", fmtBytes(memUsed*1024)+" / "+fmtBytes(s.mem_total_kb*1024), "可用 "+fmtBytes(s.mem_avail_kb*1024), memUsed/s.mem_total_kb*100),
stat("连接数", s.conntrack+" / "+s.conntrack_max, "硬件加速中 "+s.hnat_bind, s.conntrack/s.conntrack_max*100),
stat("温度", s.temp_mc?(s.temp_mc/1000).toFixed(1)+" °C":"-", "配置存储剩余 "+fmtBytes(s.overlay_free_kb*1024))),
h("div",{class:"grid gauges"},
gauge({label:"CPU", pct:busy, value:busy==null ? "…" : busy.toFixed(0)+" %", sub:cores+"负载 "+s.load, extra:spark(OV.h.cpu, null, 100)}),
gauge({label:"内存", pct:memPct, value:fmtBytes(memUsed*1024), sub:"共 "+fmtBytes(s.mem_total_kb*1024)+" · 可用 "+fmtBytes(s.mem_avail_kb*1024), extra:spark(OV.h.mem, COLORS[4], 100)}),
gauge({label:"连接数", pct:ctPct, value:String(s.conntrack), sub:"上限 "+s.conntrack_max+" · 硬件加速 "+s.hnat_bind, extra:spark(OV.h.ct, COLORS[5])}),
gauge({label:"温度", pct:temp, center:temp==null ? "-" : temp.toFixed(0)+"°", lv:level(temp, 75, 90), value:temp==null ? "-" : temp.toFixed(1)+" °C", sub:"运行 "+fmtDur(s.uptime)}),
s.overlay_total_kb ? gauge({label:"配置存储", pct:ovUsed*100/s.overlay_total_kb, value:fmtBytes(ovUsed*1024), sub:"共 "+fmtBytes(s.overlay_total_kb*1024)+" · 剩余 "+fmtBytes(s.overlay_free_kb*1024)}) : null),
h("div",{class:"grid",style:"margin-top:14px"}, wanCards, wifiCards,
card("Tailscale", h("dl",{class:"kv"}, h("dt",{},"状态"),h("dd",{},ts.state||"-"), h("dt",{},"地址"),h("dd",{class:"mono"},ts.ip||"-"), h("dt",{},"在线节点"),h("dd",{},(ts.peers_online??"-")+" / "+(ts.peers_total??"-"))))),
card("服务", h("div",{class:"row"}, (s.services||[]).map(x=>h("span",{class:"tag "+(x.running?"ok":"bad")}, x.name)))),
card("最近变更", h("pre",{}, (s.changes||[]).slice().reverse().join("\n")||"(无)")));
};
await draw();
S.timer = setInterval(()=>draw().catch(()=>{}), 3000);
const t = setInterval(()=>draw().catch(()=>{}), 3000);
S.timer = t;
setTimeout(()=>{ if (S.timer===t) draw().catch(()=>{}); }, 800); // a second CPU sample right away
return wrap;
});

Expand Down
Loading
Loading