mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
Add system info to SystemInfo
Provide the kernel, machine, CPU Model, hostname, and Node.js version
fields to SystemInfo and display them in the Web UI. These were added
as metrics exposed to prometheus in b46efeb.
This commit is contained in:
1 parent
4e36fa1b4e
commit
de47989527
6 files changed
+63
-3
No files matched your search
@@ -211,6 +211,11 @@ export class SystemInfo {
|
||||
* "controller" if these metrics are for the controller.
|
||||
*/
|
||||
public id: number | "controller",
|
||||
public hostname: string,
|
||||
public node: string,
|
||||
public kernel: string,
|
||||
public machine: string,
|
||||
public cpuModel: string,
|
||||
public coreRatios: number[],
|
||||
public memoryCapacity: number,
|
||||
public memoryAvailable: number,
|
||||
@@ -223,6 +228,11 @@ export class SystemInfo {
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"id": Type.Union([Type.Number(), Type.Literal("controller")]),
|
||||
"hostname": Type.String(),
|
||||
"node": Type.String(),
|
||||
"kernel": Type.String(),
|
||||
"machine": Type.String(),
|
||||
"cpuModel": Type.String(),
|
||||
"coreRatios": Type.Array(Type.Number()),
|
||||
"memoryCapacity": Type.Number(),
|
||||
"memoryAvailable": Type.Number(),
|
||||
@@ -235,6 +245,11 @@ export class SystemInfo {
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(
|
||||
json.id,
|
||||
json.hostname,
|
||||
json.node,
|
||||
json.kernel,
|
||||
json.machine,
|
||||
json.cpuModel,
|
||||
json.coreRatios,
|
||||
json.memoryCapacity,
|
||||
json.memoryAvailable,
|
||||
|
||||
@@ -4,7 +4,7 @@ import util from "util";
|
||||
import { Gauge } from "./prometheus";
|
||||
import { SystemInfo } from "./data";
|
||||
|
||||
function cpuModel() {
|
||||
function filterCpuModel() {
|
||||
const model = os.cpus()[0].model;
|
||||
// Remove irelevant clutter
|
||||
return model
|
||||
@@ -16,6 +16,7 @@ function cpuModel() {
|
||||
.trim() // AMD CPUs may have trailing spaces in the model.
|
||||
;
|
||||
}
|
||||
const cpuModel = filterCpuModel();
|
||||
|
||||
export const systemInfo = new Gauge(
|
||||
"system_info",
|
||||
@@ -27,7 +28,7 @@ export const systemInfo = new Gauge(
|
||||
systemInfo.labels({
|
||||
"kernel": os.type(),
|
||||
"machine": os.machine(),
|
||||
"cpu_model": cpuModel(),
|
||||
"cpu_model": cpuModel,
|
||||
"hostname": os.hostname(),
|
||||
"node": process.version,
|
||||
}).set(1);
|
||||
@@ -153,6 +154,11 @@ export async function gatherSystemInfo(id: SystemInfo["id"]) {
|
||||
|
||||
return new SystemInfo(
|
||||
id,
|
||||
os.hostname(),
|
||||
process.version,
|
||||
os.type(),
|
||||
os.machine(),
|
||||
cpuModel,
|
||||
cpuUsage,
|
||||
os.totalmem(),
|
||||
os.freemem(),
|
||||
|
||||
Reference in new issue
Block a user