@brainwart/screeps-prometheus-game
v1.0.1
Published
A way to create memory easier for the corresponding Prometheus exporter
Downloads
2
Readme
Screeps Prometheus Game
This is the library to make setting up screepsPrometheus easier.
Usage
Install the package from npm.
npm i @brainwart/screeps-prometheus-game
Import the ScreepPrometheus class.
import { ScreepsPrometheus } from '@brainwart/screeps-prometheus-game';
Create a copy of the class
const prom = new ScreepsPrometheus();
Add prefixes, gauges, and labels as needed
const prom = new ScreepsPrometheus();
const cpu = prom.add(Prefix, 'cpu');
cpu.add(Gauge, 'used', Game.cpu.getUsed());
cpu.add(Gauge, 'bucket', Game.cpu.bucket);
const rooms = prom.add(Prefix, 'roomSummary');
for (const roomName in Game.rooms) {
const room = Game.rooms[roomName];
if (room.controller && room.controller.my) {
const roomSummary = rooms.add(Label, 'roomName', roomName);
const controller = roomSummary.add(Prefix, 'controller');
controller.add(Gauge, 'level', room.controller.level, 'Current controller level');
controller.add(Gauge, 'progress', room.controller.progress);
controller.add(Gauge, 'progressNeeded', room.controller.progressTotal);
controller.add(Gauge, 'downgrade', room.controller.ticksToDowngrade);
if (room.storage) {
const storage = roomSummary.add(Prefix, 'storage');
storage.add(Gauge, 'energy', 20);
}
}
}
Memory.stats = prom.build();
Build the memory and add it
Memory.stats = prom.build();