feat: add support for source 2

This commit is contained in:
2023-10-22 19:33:42 +02:00
parent 24e44a346d
commit 14ace4cd49
6 changed files with 106 additions and 59 deletions

View File

@@ -4,16 +4,19 @@ import utils from '../utils/utils.js';
const csgoRegistry = new prometheus.Registry();
const gmodRegistry = new prometheus.Registry();
const cstrikeRegistry = new prometheus.Registry();
const cs2Registry = new prometheus.Registry();
const allGameMetrics = [
csgoRegistry,
gmodRegistry,
cstrikeRegistry,
cs2Registry,
];
export default {
csgoRegistry,
gmodRegistry,
cstrikeRegistry,
cs2Registry,
allGameMetrics,
setDefaultLabels(ip, port, game, tags, metamodResponse, sourcemodResponse, sourcepythonResponse) {
@@ -36,9 +39,11 @@ export default {
const version = line.replace('SP version : ', '').trim();
defaultLabels.sourcepython = version;
}
if (game === 'csgo') {
csgoRegistry.setDefaultLabels(defaultLabels);
} else if (game === 'cstrike') {
if (game === 'cs2') {
cs2Registry.setDefaultLabels(defaultLabels);
} else if (game === 'csgo') {
csgoRegistry.setDefaultLabels(defaultLabels);
} else if (game === 'cstrike') {
cstrikeRegistry.setDefaultLabels(defaultLabels);
} else if (game === 'gmod') {
gmodRegistry.setDefaultLabels(defaultLabels);
@@ -46,9 +51,11 @@ export default {
},
sendMetrics(game, res) {
if (game === 'csgo') {
res.end(csgoRegistry.metrics());
} else if (game === 'cstrike') {
if (game === 'cs2') {
res.end(cs2Registry.metrics());
} else if (game === 'csgo') {
res.end(csgoRegistry.metrics());
} else if (game === 'cstrike') {
res.end(cstrikeRegistry.metrics());
} else if (game === 'gmod') {
res.end(gmodRegistry.metrics());