mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 23:33:12 +09:00
There are more pieces of information about a system than just its CPU, Memory and disk metrics. To avoid having to build a separate collection and subscription for metrics and system info, rename the existing system metrics to system info in anticipation of providing additonal static system information such as CPU model in it.
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import React from "react";
|
|
|
|
import * as lib from "@clusterio/lib";
|
|
import { Progress } from "antd";
|
|
|
|
export function MetricCpuRatio(props: { system?: lib.SystemInfo }) {
|
|
if (!props.system) {
|
|
return "N/A";
|
|
}
|
|
const ratio = props.system.cpuRatio;
|
|
return <Progress status="normal" percent={Math.ceil(ratio * 100)}/>;
|
|
}
|
|
|
|
export function MetricCpuUsed(props: { system?: lib.SystemInfo }) {
|
|
if (!props.system) {
|
|
return "N/A";
|
|
}
|
|
const used = props.system.cpuUsed.toLocaleString(undefined, { maximumFractionDigits: 1 });
|
|
const capacity = props.system.cpuCapacity;
|
|
return `${used} / ${capacity}`;
|
|
}
|
|
|
|
export function MetricMemoryRatio(props: { system?: lib.SystemInfo }) {
|
|
if (!props.system) {
|
|
return "N/A";
|
|
}
|
|
const ratio = props.system.memoryRatio;
|
|
return <Progress status="normal" percent={Math.ceil(ratio * 100)}/>;
|
|
}
|
|
|
|
export function MetricMemoryUsed(props: { system?: lib.SystemInfo }) {
|
|
if (!props.system) {
|
|
return "N/A";
|
|
}
|
|
const used = lib.formatBytes(props.system.memoryUsed, "binary");
|
|
const capacity = lib.formatBytes(props.system.memoryCapacity, "binary");
|
|
return `${used} / ${capacity}`;
|
|
}
|
|
|
|
export function MetricDiskRatio(props: { system?: lib.SystemInfo }) {
|
|
if (!props.system) {
|
|
return "N/A";
|
|
}
|
|
const ratio = props.system.diskRatio;
|
|
return <Progress status="normal" percent={Math.ceil(ratio * 100)}/>;
|
|
}
|
|
|
|
export function MetricDiskUsed(props: { system?: lib.SystemInfo }) {
|
|
if (!props.system) {
|
|
return "N/A";
|
|
}
|
|
const used = lib.formatBytes(props.system.diskUsed);
|
|
const capacity = lib.formatBytes(props.system.diskCapacity);
|
|
return `${used} / ${capacity}`;
|
|
}
|