1c6dfea5b5
Dashboard → System Health is grouped into AgentHub, Machine and Agent
activity. The machine (GET /api/host, every signed-in user) is drawn by
components/health/HostHealth.tsx: host card beside the CPU/memory history,
then CPU (threads as compact cells + temperatures/GPUs), disks & network,
busiest processes, and per-user tiles. Concurrency bars each show their own
agent type on hover.
The Health Score (client/src/lib/healthScore.ts) is now 100 minus what each
check costs, between an amber and a red threshold: event-loop p99
(server/lib/loop-delay.js, shared with /api/metrics), Linux PSI pressure for
CPU, memory and disk I/O (/api/host `pressure`; load per core without PSI),
RAM, the database's disk, V8 heap, hooks silent while agents work, and agent
errors in the last 24 h. All-time success rate, API errors and the transcript
cache hit rate no longer count. /api/settings/info adds server.event_loop and
activity {last_event_at, working_agents, agents_24h}.
Administration: a user row opens its detail in place (GET
/api/users/:id/details — spend, account pool share, live panes, workspaces,
newest sessions); the server panel is gone, member tmux folded into the table;
the Sessions list shows each row's owner in server mode.
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
/**
|
|
* @file host.js
|
|
* @description `GET /api/host` — the Dashboard System Health tab's machine
|
|
* cards, its per-user CPU/RAM card included: the machine's hardware, load and
|
|
* disks, and each AgentHub user's share of its CPU and memory right now
|
|
* (server/lib/host-stats.js); `GET /api/host/history` (`?range=1h|6h|24h`) the
|
|
* in-memory CPU/memory history the server keeps since it started. Read-only;
|
|
* every signed-in user (`/host` is NOT in STAFF_ONLY_PREFIXES — System Health
|
|
* is everyone's).
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
const { Router } = require("express");
|
|
const { hostStats, hostHistory } = require("../lib/host-stats");
|
|
|
|
const router = Router();
|
|
|
|
router.get("/", async (_req, res) => {
|
|
try {
|
|
res.json(await hostStats());
|
|
} catch (e) {
|
|
res.status(500).json({ error: { code: "EHOST", message: e.message } });
|
|
}
|
|
});
|
|
|
|
router.get("/history", (req, res) => {
|
|
res.json(hostHistory(typeof req.query.range === "string" ? req.query.range : "1h"));
|
|
});
|
|
|
|
module.exports = router;
|