feat(admin): Administration page — Users tab + Server tab (hardware, per-user CPU/memory/home share)
/users becomes /admin (redirected), a tab shell over the existing Users view and a new Server tab backed by GET /api/host (server/lib/host-stats.js): hostname/OS/uptime, CPU and load, memory and swap, every real disk with HDD/SSD, NVIDIA GPUs, and each user's live share from two /proc samples — attributed by the member's Linux uid (S3) or, for host processes, by the inherited AGENTHUB_LANE_ID's workspace owner. Read-only, staff-only (/host in STAFF_ONLY_PREFIXES), comm names only. Members' tmux card moves to the Server tab.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @file host.js
|
||||
* @description `GET /api/host` — the Administration page's Server tab: 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). Read-only; staff only
|
||||
* in server mode (`/host` is in STAFF_ONLY_PREFIXES, server/lib/auth.js).
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
const { Router } = require("express");
|
||||
const { hostStats } = 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 } });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user