feat(nodes): add fleet monitoring and implement the Penpot layout (#7342)

Expose sampled CPU topology, absolute RAM, TCP/UDP counts, load averages and network throughput through the existing heartbeat and descendant contracts, preserving measured zero versus unavailable values. Add an explicit nullable telemetry migration and freshness/availability checks.

Provide read-only All nodes and Master rows with deduplicated host/client totals, grouped SQL aggregation and reporting coverage. Preserve known descendants during parent outages and prefer the freshest valid observation of shared GUIDs. Keep the ordinary heartbeat broadcast free of fleet-wide totals.

Implement the approved compact Penpot-inspired Nodes layout, responsive stacked details, status diagnostics and existing remote actions. Preserve cached rows, search and controls on overview refresh failures. By maintainer decision, hide both system rows when no remote nodes are registered.

Final review of 44ed457985: no outstanding HIGH or MEDIUM findings. CI and Docs CI passed (13 jobs; 2342 frontend tests in 269 files), including Go/race and mixed-version node E2E. Feature-specific PostgreSQL regression execution was not independently verified in the selected CI logs. See https://github.com/MHSanaei/3x-ui/pull/7342#issuecomment-7363599190.

Closes #7335
Closes #7336
Closes #7337
This commit is contained in:
Hamed
2026-12-03 04:19:48 +03:30
committed by GitHub
parent 0afa11ddff
commit ef99e67507
64 changed files with 4710 additions and 1608 deletions
+73
View File
@@ -1297,6 +1297,7 @@ export const EXAMPLES: Record<string, unknown> = {
"remark": "",
"scheme": "https",
"status": "online",
"telemetry": null,
"tlsVerifyMode": "verify",
"transitive": false,
"unavailableMetrics": [
@@ -1324,11 +1325,34 @@ export const EXAMPLES: Record<string, unknown> = {
"total": 10737418240,
"up": 1048576
},
"NodeFleetCounts": {
"activeCount": 90,
"clientCount": 100,
"depletedCount": 2,
"disabledCount": 8,
"inboundCount": 8,
"onlineCount": 20
},
"NodeInboundTraffic": {
"down": 0,
"id": 1,
"up": 0
},
"NodeMasterView": {
"counts": {
"activeCount": 90,
"clientCount": 100,
"depletedCount": 2,
"disabledCount": 8,
"inboundCount": 8,
"onlineCount": 20
},
"panelVersion": "v3.12.0",
"telemetry": null,
"xrayError": "",
"xrayState": "running",
"xrayVersion": "26.1.1"
},
"NodeMutationRequest": {
"address": "",
"allowPrivateAddress": false,
@@ -1349,6 +1373,34 @@ export const EXAMPLES: Record<string, unknown> = {
"scheme": "http",
"tlsVerifyMode": "verify"
},
"NodeOverview": {
"fleet": {
"activeCount": 90,
"clientCount": 100,
"depletedCount": 2,
"disabledCount": 8,
"inboundCount": 8,
"onlineCount": 20
},
"master": {
"counts": {
"activeCount": 90,
"clientCount": 100,
"depletedCount": 2,
"disabledCount": 8,
"inboundCount": 8,
"onlineCount": 20
},
"panelVersion": "v3.12.0",
"telemetry": null,
"xrayError": "",
"xrayState": "running",
"xrayVersion": "26.1.1"
},
"nodes": [
null
]
},
"NodeSnapshotAttachment": {
"email": "user1",
"inboundId": 1
@@ -1364,6 +1416,25 @@ export const EXAMPLES: Record<string, unknown> = {
null
]
},
"NodeTelemetry": {
"cpuPct": 12.5,
"load1": 0.25,
"load15": 0.12,
"load5": 0.18,
"logicalCores": 8,
"memAvailableBytes": 1073741824,
"memTotalBytes": 4294967296,
"memUsedBytes": 2147483648,
"netDown": 2048,
"netUp": 1024,
"physicalCores": 4,
"resourceScope": "container",
"sampleAgeMillis": 125,
"sampledAt": 1700000000000,
"tcpCount": 75,
"udpCount": 12,
"uptimeSecs": 3600
},
"NodeTrafficSnapshotV1": {
"activeInboundTree": {},
"clients": [
@@ -1439,6 +1510,7 @@ export const EXAMPLES: Record<string, unknown> = {
"remark": "Primary edge",
"scheme": "https",
"status": "online",
"telemetry": null,
"tlsVerifyMode": "verify",
"transitive": false,
"unavailableMetrics": [
@@ -1674,6 +1746,7 @@ export const EXAMPLES: Record<string, unknown> = {
"panelVersion": "",
"publicIP": null,
"resourceScope": "",
"sampleAgeMillis": 125,
"swap": null,
"tcpCount": 0,
"udpCount": 0,
+220
View File
@@ -4729,6 +4729,14 @@ export const SCHEMAS: Record<string, unknown> = {
"example": "online",
"type": "string"
},
"telemetry": {
"allOf": [
{
"$ref": "#/components/schemas/NodeTelemetry"
}
],
"nullable": true
},
"tlsVerifyMode": {
"enum": [
"verify",
@@ -4890,6 +4898,43 @@ export const SCHEMAS: Record<string, unknown> = {
],
"type": "object"
},
"NodeFleetCounts": {
"properties": {
"activeCount": {
"example": 90,
"type": "integer"
},
"clientCount": {
"example": 100,
"type": "integer"
},
"depletedCount": {
"example": 2,
"type": "integer"
},
"disabledCount": {
"example": 8,
"type": "integer"
},
"inboundCount": {
"example": 8,
"type": "integer"
},
"onlineCount": {
"example": 20,
"type": "integer"
}
},
"required": [
"activeCount",
"clientCount",
"depletedCount",
"disabledCount",
"inboundCount",
"onlineCount"
],
"type": "object"
},
"NodeInboundTraffic": {
"properties": {
"down": {
@@ -4912,6 +4957,40 @@ export const SCHEMAS: Record<string, unknown> = {
],
"type": "object"
},
"NodeMasterView": {
"properties": {
"counts": {
"$ref": "#/components/schemas/NodeFleetCounts"
},
"panelVersion": {
"example": "v3.12.0",
"type": "string"
},
"telemetry": {
"allOf": [
{
"$ref": "#/components/schemas/NodeTelemetry"
}
],
"nullable": true
},
"xrayError": {
"type": "string"
},
"xrayState": {
"example": "running",
"type": "string"
},
"xrayVersion": {
"example": "26.1.1",
"type": "string"
}
},
"required": [
"counts"
],
"type": "object"
},
"NodeMutationRequest": {
"description": "NodeMutationRequest is the node write/probe contract. ApiToken is accepted\nonly as input. On update, nil means keep the stored token; replacement and\nclearing are explicit and mutually exclusive.",
"properties": {
@@ -5002,6 +5081,33 @@ export const SCHEMAS: Record<string, unknown> = {
],
"type": "object"
},
"NodeOverview": {
"properties": {
"fleet": {
"$ref": "#/components/schemas/NodeFleetCounts"
},
"master": {
"$ref": "#/components/schemas/NodeMasterView"
},
"nodes": {
"items": {
"allOf": [
{
"$ref": "#/components/schemas/NodeView"
}
],
"nullable": true
},
"type": "array"
}
},
"required": [
"fleet",
"master",
"nodes"
],
"type": "object"
},
"NodeSnapshotAttachment": {
"properties": {
"email": {
@@ -5045,6 +5151,106 @@ export const SCHEMAS: Record<string, unknown> = {
],
"type": "object"
},
"NodeTelemetry": {
"description": "NodeTelemetry describes one host sample. Nil metrics were not measured.",
"properties": {
"cpuPct": {
"example": 12.5,
"nullable": true,
"type": "number"
},
"load1": {
"example": 0.25,
"nullable": true,
"type": "number"
},
"load15": {
"example": 0.12,
"nullable": true,
"type": "number"
},
"load5": {
"example": 0.18,
"nullable": true,
"type": "number"
},
"logicalCores": {
"example": 8,
"nullable": true,
"type": "integer"
},
"memAvailableBytes": {
"example": 1073741824,
"format": "int64",
"nullable": true,
"type": "integer"
},
"memTotalBytes": {
"example": 4294967296,
"format": "int64",
"nullable": true,
"type": "integer"
},
"memUsedBytes": {
"example": 2147483648,
"format": "int64",
"nullable": true,
"type": "integer"
},
"netDown": {
"example": 2048,
"format": "int64",
"nullable": true,
"type": "integer"
},
"netUp": {
"example": 1024,
"format": "int64",
"nullable": true,
"type": "integer"
},
"physicalCores": {
"example": 4,
"nullable": true,
"type": "integer"
},
"resourceScope": {
"example": "container",
"type": "string"
},
"sampleAgeMillis": {
"example": 125,
"format": "int64",
"nullable": true,
"type": "integer"
},
"sampledAt": {
"example": 1700000000000,
"format": "int64",
"type": "integer"
},
"tcpCount": {
"example": 75,
"nullable": true,
"type": "integer"
},
"udpCount": {
"example": 12,
"nullable": true,
"type": "integer"
},
"uptimeSecs": {
"example": 3600,
"format": "int64",
"nullable": true,
"type": "integer"
}
},
"required": [
"sampledAt"
],
"type": "object"
},
"NodeTrafficSnapshotV1": {
"description": "NodeTrafficSnapshotV1 carries complete counters every tick; only unchanged structure is omitted.",
"properties": {
@@ -5276,6 +5482,14 @@ export const SCHEMAS: Record<string, unknown> = {
"example": "online",
"type": "string"
},
"telemetry": {
"allOf": [
{
"$ref": "#/components/schemas/NodeTelemetry"
}
],
"nullable": true
},
"tlsVerifyMode": {
"example": "verify",
"type": "string"
@@ -6179,6 +6393,12 @@ export const SCHEMAS: Record<string, unknown> = {
"resourceScope": {
"type": "string"
},
"sampleAgeMillis": {
"example": 125,
"format": "int64",
"nullable": true,
"type": "integer"
},
"swap": {},
"tcpCount": {
"type": "integer"
+47
View File
@@ -1092,6 +1092,7 @@ export interface Node {
remark: string;
scheme: string;
status: string;
telemetry?: NodeTelemetry | null;
tlsVerifyMode: string;
transitive?: boolean;
unavailableMetrics?: string[];
@@ -1119,12 +1120,30 @@ export interface NodeClientTraffic {
up: number;
}
export interface NodeFleetCounts {
activeCount: number;
clientCount: number;
depletedCount: number;
disabledCount: number;
inboundCount: number;
onlineCount: number;
}
export interface NodeInboundTraffic {
down: number;
id: number;
up: number;
}
export interface NodeMasterView {
counts: NodeFleetCounts;
panelVersion?: string;
telemetry?: NodeTelemetry | null;
xrayError?: string;
xrayState?: string;
xrayVersion?: string;
}
export interface NodeMutationRequest {
address: string;
allowPrivateAddress: boolean;
@@ -1144,6 +1163,12 @@ export interface NodeMutationRequest {
tlsVerifyMode: string;
}
export interface NodeOverview {
fleet: NodeFleetCounts;
master: NodeMasterView;
nodes: NodeView | null[];
}
export interface NodeSnapshotAttachment {
email: string;
inboundId: number;
@@ -1154,6 +1179,26 @@ export interface NodeSnapshotStructure {
inbounds: Inbound | null[];
}
export interface NodeTelemetry {
cpuPct?: number | null;
load1?: number | null;
load15?: number | null;
load5?: number | null;
logicalCores?: number | null;
memAvailableBytes?: number | null;
memTotalBytes?: number | null;
memUsedBytes?: number | null;
netDown?: number | null;
netUp?: number | null;
physicalCores?: number | null;
resourceScope?: string;
sampleAgeMillis?: number | null;
sampledAt: number;
tcpCount?: number | null;
udpCount?: number | null;
uptimeSecs?: number | null;
}
export interface NodeTrafficSnapshotV1 {
activeInboundTree: Record<string, string[]>;
clients: NodeClientTraffic[];
@@ -1203,6 +1248,7 @@ export interface NodeView {
remark: string;
scheme: string;
status: string;
telemetry?: NodeTelemetry | null;
tlsVerifyMode: string;
transitive?: boolean;
unavailableMetrics?: string[];
@@ -1411,6 +1457,7 @@ export interface Status {
panelVersion: string;
publicIP: unknown;
resourceScope?: string;
sampleAgeMillis?: number | null;
swap: unknown;
tcpCount: number;
udpCount: number;
+51
View File
@@ -1167,6 +1167,7 @@ export const NodeSchema = z.object({
remark: z.string(),
scheme: z.enum(['http', 'https']),
status: z.string(),
telemetry: z.lazy(() => NodeTelemetrySchema).nullable().optional(),
tlsVerifyMode: z.enum(['verify', 'skip', 'pin', 'mtls']),
transitive: z.boolean().optional(),
unavailableMetrics: z.array(z.string()).optional(),
@@ -1196,6 +1197,16 @@ export const NodeClientTrafficSchema = z.object({
});
export type NodeClientTraffic = z.infer<typeof NodeClientTrafficSchema>;
export const NodeFleetCountsSchema = z.object({
activeCount: z.number().int(),
clientCount: z.number().int(),
depletedCount: z.number().int(),
disabledCount: z.number().int(),
inboundCount: z.number().int(),
onlineCount: z.number().int(),
});
export type NodeFleetCounts = z.infer<typeof NodeFleetCountsSchema>;
export const NodeInboundTrafficSchema = z.object({
down: z.number().int(),
id: z.number().int(),
@@ -1203,6 +1214,16 @@ export const NodeInboundTrafficSchema = z.object({
});
export type NodeInboundTraffic = z.infer<typeof NodeInboundTrafficSchema>;
export const NodeMasterViewSchema = z.object({
counts: z.lazy(() => NodeFleetCountsSchema),
panelVersion: z.string().optional(),
telemetry: z.lazy(() => NodeTelemetrySchema).nullable().optional(),
xrayError: z.string().optional(),
xrayState: z.string().optional(),
xrayVersion: z.string().optional(),
});
export type NodeMasterView = z.infer<typeof NodeMasterViewSchema>;
export const NodeMutationRequestSchema = z.object({
address: z.string(),
allowPrivateAddress: z.boolean(),
@@ -1223,6 +1244,13 @@ export const NodeMutationRequestSchema = z.object({
});
export type NodeMutationRequest = z.infer<typeof NodeMutationRequestSchema>;
export const NodeOverviewSchema = z.object({
fleet: z.lazy(() => NodeFleetCountsSchema),
master: z.lazy(() => NodeMasterViewSchema),
nodes: z.array(z.lazy(() => NodeViewSchema).nullable()),
});
export type NodeOverview = z.infer<typeof NodeOverviewSchema>;
export const NodeSnapshotAttachmentSchema = z.object({
email: z.string(),
inboundId: z.number().int(),
@@ -1235,6 +1263,27 @@ export const NodeSnapshotStructureSchema = z.object({
});
export type NodeSnapshotStructure = z.infer<typeof NodeSnapshotStructureSchema>;
export const NodeTelemetrySchema = z.object({
cpuPct: z.number().nullable().optional(),
load1: z.number().nullable().optional(),
load15: z.number().nullable().optional(),
load5: z.number().nullable().optional(),
logicalCores: z.number().int().nullable().optional(),
memAvailableBytes: z.number().int().nullable().optional(),
memTotalBytes: z.number().int().nullable().optional(),
memUsedBytes: z.number().int().nullable().optional(),
netDown: z.number().int().nullable().optional(),
netUp: z.number().int().nullable().optional(),
physicalCores: z.number().int().nullable().optional(),
resourceScope: z.string().optional(),
sampleAgeMillis: z.number().int().nullable().optional(),
sampledAt: z.number().int(),
tcpCount: z.number().int().nullable().optional(),
udpCount: z.number().int().nullable().optional(),
uptimeSecs: z.number().int().nullable().optional(),
});
export type NodeTelemetry = z.infer<typeof NodeTelemetrySchema>;
export const NodeTrafficSnapshotV1Schema = z.object({
activeInboundTree: z.record(z.string(), z.array(z.string())),
clients: z.array(z.lazy(() => NodeClientTrafficSchema)),
@@ -1285,6 +1334,7 @@ export const NodeViewSchema = z.object({
remark: z.string(),
scheme: z.string(),
status: z.string(),
telemetry: z.lazy(() => NodeTelemetrySchema).nullable().optional(),
tlsVerifyMode: z.string(),
transitive: z.boolean().optional(),
unavailableMetrics: z.array(z.string()).optional(),
@@ -1509,6 +1559,7 @@ export const StatusSchema = z.object({
panelVersion: z.string(),
publicIP: z.unknown(),
resourceScope: z.string().optional(),
sampleAgeMillis: z.number().int().nullable().optional(),
swap: z.unknown(),
tcpCount: z.number().int(),
udpCount: z.number().int(),