mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Show System metrics in hosts page
Implement simple collection of basic real time system metrics of hosts and the controller for the purpose of displaying them in the Web UI. The metrics are collected by the controller at a configurable interval and pushed out to web clients currently subscribed to the metrics.
This commit is contained in:
1 parent
69bdc8e884
commit
d64bf6015e
13 files changed
+409
-7
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import React from "react";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { Progress } from "antd";
|
||||
|
||||
export function MetricCpuRatio(props: { metrics?: lib.SystemMetrics }) {
|
||||
if (!props.metrics) {
|
||||
return "N/A";
|
||||
}
|
||||
const ratio = props.metrics.cpuRatio;
|
||||
return <Progress status="normal" percent={Math.ceil(ratio * 100)}/>;
|
||||
}
|
||||
|
||||
export function MetricCpuUsed(props: { metrics?: lib.SystemMetrics }) {
|
||||
if (!props.metrics) {
|
||||
return "N/A";
|
||||
}
|
||||
const used = props.metrics.cpuUsed.toLocaleString(undefined, { maximumFractionDigits: 1 });
|
||||
const capacity = props.metrics.cpuCapacity;
|
||||
return `${used} / ${capacity}`;
|
||||
}
|
||||
|
||||
export function MetricMemoryRatio(props: { metrics?: lib.SystemMetrics }) {
|
||||
if (!props.metrics) {
|
||||
return "N/A";
|
||||
}
|
||||
const ratio = props.metrics.memoryRatio;
|
||||
return <Progress status="normal" percent={Math.ceil(ratio * 100)}/>;
|
||||
}
|
||||
|
||||
export function MetricMemoryUsed(props: { metrics?: lib.SystemMetrics }) {
|
||||
if (!props.metrics) {
|
||||
return "N/A";
|
||||
}
|
||||
const used = lib.formatBytes(props.metrics.memoryUsed);
|
||||
const capacity = lib.formatBytes(props.metrics.memoryCapacity);
|
||||
return `${used} / ${capacity}`;
|
||||
}
|
||||
|
||||
export function MetricDiskRatio(props: { metrics?: lib.SystemMetrics }) {
|
||||
if (!props.metrics) {
|
||||
return "N/A";
|
||||
}
|
||||
const ratio = props.metrics.diskRatio;
|
||||
return <Progress status="normal" percent={Math.ceil(ratio * 100)}/>;
|
||||
}
|
||||
|
||||
export function MetricDiskUsed(props: { metrics?: lib.SystemMetrics }) {
|
||||
if (!props.metrics) {
|
||||
return "N/A";
|
||||
}
|
||||
const used = lib.formatBytes(props.metrics.diskUsed);
|
||||
const capacity = lib.formatBytes(props.metrics.diskCapacity);
|
||||
return `${used} / ${capacity}`;
|
||||
}
|
||||
Reference in new issue
Block a user