mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 15:33:12 +09:00
Add platform speed and weight metrics
clusterio_statistics_exporter_platform_speed clusterio_statistics_exporter_platform_weight
This commit is contained in:
1 parent
9464541d61
commit
8e22de9d2d
3 files changed
+41
-3
No files matched your search
@@ -22,6 +22,8 @@ type IpcStats = {
|
||||
[key: string]: {
|
||||
force: string,
|
||||
surface: string,
|
||||
speed: number,
|
||||
weight: number,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +58,16 @@ const instancePlatformMapping = new Gauge(
|
||||
"Mapping of platform name to force, surface and instance",
|
||||
{ labels: ["instance_id", "platform_name", "force", "surface"] }
|
||||
);
|
||||
const instancePlatformSpeed = new Gauge(
|
||||
"clusterio_statistics_exporter_platform_speed",
|
||||
"Current speed of the platform",
|
||||
{ labels: ["instance_id", "force", "surface"] }
|
||||
);
|
||||
const instancePlatformWeight = new Gauge(
|
||||
"clusterio_statistics_exporter_platform_weight",
|
||||
"Current weight/mass of the platform",
|
||||
{ labels: ["instance_id", "force", "surface"] }
|
||||
);
|
||||
|
||||
function setForceFlowStatistic(
|
||||
instanceId: number,
|
||||
@@ -114,10 +126,12 @@ export class InstancePlugin extends BaseInstancePlugin {
|
||||
instanceGameTicksTotal.labels(String(instanceId)).set(stats.game_tick);
|
||||
instancePlayerCount.labels(String(instanceId)).set(stats.player_count);
|
||||
|
||||
// Remove existing platform mappings for this instance
|
||||
// Remove existing platform mappings and stats for this instance
|
||||
instancePlatformMapping.removeAll({ instance_id: String(instanceId) });
|
||||
instancePlatformSpeed.removeAll({ instance_id: String(instanceId) });
|
||||
instancePlatformWeight.removeAll({ instance_id: String(instanceId) });
|
||||
|
||||
// Set new platform mappings
|
||||
// Set new platform mappings and stats
|
||||
for (let [platformName, platform] of Object.entries(stats.platforms)) {
|
||||
instancePlatformMapping.labels(
|
||||
String(instanceId),
|
||||
@@ -125,6 +139,18 @@ export class InstancePlugin extends BaseInstancePlugin {
|
||||
platform.force,
|
||||
platform.surface
|
||||
).set(1);
|
||||
|
||||
instancePlatformSpeed.labels(
|
||||
String(instanceId),
|
||||
platform.force,
|
||||
platform.surface
|
||||
).set(platform.speed);
|
||||
|
||||
instancePlatformWeight.labels(
|
||||
String(instanceId),
|
||||
platform.force,
|
||||
platform.surface
|
||||
).set(platform.weight);
|
||||
}
|
||||
|
||||
for (let [surfaceName, surfaceStats] of Object.entries(stats.surface_statistics)) {
|
||||
@@ -176,3 +202,5 @@ export const _instanceGameTicksTotal = instanceGameTicksTotal;
|
||||
export const _instanceForceFlowStatistics = instanceForceFlowStatistics;
|
||||
export const _instanceGameFlowStatistics = instanceGameFlowStatistics;
|
||||
export const _instancePlatformMapping = instancePlatformMapping;
|
||||
export const _instancePlatformSpeed = instancePlatformSpeed;
|
||||
export const _instancePlatformWeight = instancePlatformWeight;
|
||||
Reference in new issue
Block a user