Add GameDig monitor

This commit is contained in:
Adam Spurgeon 2023-01-08 21:22:36 +13:00
parent 23a525e36a
commit 774d754b21
7 changed files with 784 additions and 10 deletions

View file

@ -16,6 +16,7 @@ const { CacheableDnsHttpAgent } = require("../cacheable-dns-http-agent");
const { DockerHost } = require("../docker");
const Maintenance = require("./maintenance");
const { UptimeCacheList } = require("../uptime-cache-list");
const Gamedig = require("gamedig");
/**
* status:
@ -107,6 +108,7 @@ class Monitor extends BeanModel {
grpcEnableTls: this.getGrpcEnableTls(),
radiusCalledStationId: this.radiusCalledStationId,
radiusCallingStationId: this.radiusCallingStationId,
game: this.game,
};
if (includeSensitiveData) {
@ -487,6 +489,20 @@ class Monitor extends BeanModel {
} else {
throw new Error("Server not found on Steam");
}
} else if (this.type === "gamedig") {
try {
const state = await Gamedig.query({
type: this.game,
host: this.hostname,
port: this.port
});
bean.msg = state.name;
bean.status = UP;
bean.ping = state.ping;
} catch (e) {
throw new Error("Server is offline");
}
} else if (this.type === "docker") {
log.debug(`[${this.name}] Prepare Options for Axios`);