mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-27 08:15:01 +03:00
fix(monitoring): read LXC CPU, swap and uptime from the container (#6920)
In an LXC container with LXCFS the Overview showed the container's RAM beside the host's swap, the host's CPU topology and a CPU percentage from the host's view. Swap and uptime now come from LXCFS's virtualised files and CPU from the container's cgroup v2 counter, normalised by the visible vCPUs and any quota; container CPU and swap history is kept apart from the earlier host samples. A value the reader cannot measure (the first CPU sample, or a layout it cannot verify such as cgroup v1) is reported as unavailable instead of 0: the dashboard, the node list, node CPU history and the Telegram and Discord uptime show a dash, and nodes keep the flags in a new unavailable_metrics column.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { NumberFormatter } from '@/utils';
|
||||
import type { StatusInput as ParsedStatusInput } from '@/schemas/status';
|
||||
|
||||
export const USAGE_WARN_PERCENT = 80;
|
||||
export const USAGE_CRIT_PERCENT = 90;
|
||||
@@ -66,7 +67,7 @@ export interface AmneziaWGInfo {
|
||||
running: boolean;
|
||||
}
|
||||
|
||||
interface StatusInput {
|
||||
interface StatusInput extends Pick<ParsedStatusInput, 'resourceScope' | 'unavailableMetrics'> {
|
||||
cpu?: number;
|
||||
cpuCores?: number;
|
||||
logicalPro?: number;
|
||||
@@ -88,6 +89,13 @@ interface StatusInput {
|
||||
}
|
||||
|
||||
export class Status {
|
||||
resourceScope = '';
|
||||
unavailableMetrics: string[] = [];
|
||||
|
||||
metricAvailable(metric: string): boolean {
|
||||
return !this.unavailableMetrics.includes(metric);
|
||||
}
|
||||
|
||||
cpu: CurTotal = new CurTotal(0, 0);
|
||||
cpuCores = 0;
|
||||
logicalPro = 0;
|
||||
@@ -110,6 +118,8 @@ export class Status {
|
||||
constructor(data?: StatusInput | null) {
|
||||
if (data == null) return;
|
||||
|
||||
this.resourceScope = data.resourceScope ?? '';
|
||||
this.unavailableMetrics = data.unavailableMetrics ?? [];
|
||||
this.cpu = new CurTotal(data.cpu ?? 0, 100);
|
||||
this.cpuCores = data.cpuCores ?? 0;
|
||||
this.logicalPro = data.logicalPro ?? 0;
|
||||
|
||||
Reference in New Issue
Block a user