mirror of
https://github.com/Sithranduil/srcds_exporter.git
synced 2025-07-23 17:28:00 +02:00
feat: add support for source 2
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user