Add commands sent statistic

Track RCON commands sent.
This commit is contained in:
Hornwitser committed 2020-04-04 12:18:26 +02:00
1 parent 75067e992d
commit 99ac8f4f33
2 files changed
+13

No files matched your search

+1
View File
@@ -36,6 +36,7 @@ Version 2.0.0
- Added config to specify which path the master interface is accessed under,
allowing it to be proxied behind web-server.
- Added WebSocket usage statistics.
- Added commands sent statistic.
### Changes
+12
View File
@@ -16,6 +16,12 @@ const luaTools = require('lib/luaTools');
const config = require('lib/config');
const instanceRconCommandsCounter = new prometheus.Counter(
"clusterio_instance_rcon_commands_total",
"How many commands have been sent to the instance",
{ labels: ["instance_id"] }
);
/**
* Keeps track of the runtime parameters of an instance
*/
@@ -39,6 +45,12 @@ class Instance extends link.Link{
factorioDir, this._dir, serverOptions
);
let originalSendRcon = this.server.sendRcon;
this.server.sendRcon = (...args) => {
instanceRconCommandsCounter.labels(String(this.config.get("instance.id"))).inc();
return originalSendRcon.call(this.server, ...args);
}
this.server.on('output', (output) => {
link.messages.instanceOutput.send(this, { instance_id: this.config.get("instance.id"), output })