mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 06:49:41 -05:00
add steam gameserver for monitoring
This commit is contained in:
parent
9e10296290
commit
b67b4d5afd
7
db/patch-add-apikey-monitor.sql
Normal file
7
db/patch-add-apikey-monitor.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE monitor
|
||||||
|
ADD apikey VARCHAR(64) default '' not null;
|
||||||
|
|
||||||
|
COMMIT;
|
@ -46,6 +46,7 @@ class Database {
|
|||||||
"patch-improve-performance.sql": true,
|
"patch-improve-performance.sql": true,
|
||||||
"patch-2fa.sql": true,
|
"patch-2fa.sql": true,
|
||||||
"patch-add-retry-interval-monitor.sql": true,
|
"patch-add-retry-interval-monitor.sql": true,
|
||||||
|
"patch-add-apikey-monitor.sql": true,
|
||||||
"patch-incident-table.sql": true,
|
"patch-incident-table.sql": true,
|
||||||
"patch-group-table.sql": true,
|
"patch-group-table.sql": true,
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ class Monitor extends BeanModel {
|
|||||||
weight: this.weight,
|
weight: this.weight,
|
||||||
active: this.active,
|
active: this.active,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
|
apikey: this.apikey,
|
||||||
interval: this.interval,
|
interval: this.interval,
|
||||||
retryInterval: this.retryInterval,
|
retryInterval: this.retryInterval,
|
||||||
keyword: this.keyword,
|
keyword: this.keyword,
|
||||||
@ -236,6 +237,46 @@ class Monitor extends BeanModel {
|
|||||||
|
|
||||||
bean.msg = dnsMessage;
|
bean.msg = dnsMessage;
|
||||||
bean.status = UP;
|
bean.status = UP;
|
||||||
|
} else if (this.type === "steam") {
|
||||||
|
const steamApiUrl = "https://api.steampowered.com/IGameServersService/GetServerList/v1/";
|
||||||
|
const filter = `addr\\${this.hostname}:${this.port}`;
|
||||||
|
|
||||||
|
let res = await axios.get(steamApiUrl, {
|
||||||
|
timeout: this.interval * 1000 * 0.8,
|
||||||
|
headers: {
|
||||||
|
"Accept": "*/*",
|
||||||
|
"User-Agent": "Uptime-Kuma/" + version,
|
||||||
|
},
|
||||||
|
httpsAgent: new https.Agent({
|
||||||
|
maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940)
|
||||||
|
rejectUnauthorized: ! this.getIgnoreTls(),
|
||||||
|
}),
|
||||||
|
maxRedirects: this.maxredirects,
|
||||||
|
validateStatus: (status) => {
|
||||||
|
return checkStatusCode(status, this.getAcceptedStatuscodes());
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
filter: filter,
|
||||||
|
key: this.apikey,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bean.msg = `${res.status} - ${res.statusText}`;
|
||||||
|
bean.ping = await ping(this.hostname);
|
||||||
|
|
||||||
|
let data = res.data;
|
||||||
|
|
||||||
|
// Convert to string for object/array
|
||||||
|
if (typeof data !== "string") {
|
||||||
|
data = JSON.stringify(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.includes(`${this.hostname}:${this.port}`)) {
|
||||||
|
bean.msg += ", server is found";
|
||||||
|
bean.status = UP;
|
||||||
|
} else {
|
||||||
|
throw new Error(bean.msg + ", but server is not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isUpsideDown()) {
|
if (this.isUpsideDown()) {
|
||||||
|
@ -504,6 +504,7 @@ exports.entryPage = "dashboard";
|
|||||||
bean.hostname = monitor.hostname;
|
bean.hostname = monitor.hostname;
|
||||||
bean.maxretries = monitor.maxretries;
|
bean.maxretries = monitor.maxretries;
|
||||||
bean.port = monitor.port;
|
bean.port = monitor.port;
|
||||||
|
bean.apikey = monitor.apikey;
|
||||||
bean.keyword = monitor.keyword;
|
bean.keyword = monitor.keyword;
|
||||||
bean.ignoreTls = monitor.ignoreTls;
|
bean.ignoreTls = monitor.ignoreTls;
|
||||||
bean.upsideDown = monitor.upsideDown;
|
bean.upsideDown = monitor.upsideDown;
|
||||||
|
@ -178,4 +178,5 @@ export default {
|
|||||||
"Add a monitor": "Add a monitor",
|
"Add a monitor": "Add a monitor",
|
||||||
"Edit Status Page": "Edit Status Page",
|
"Edit Status Page": "Edit Status Page",
|
||||||
"Go to Dashboard": "Go to Dashboard",
|
"Go to Dashboard": "Go to Dashboard",
|
||||||
|
steamApiKeyDescription: "For monitoring a Steam Gameserver you need a steam Web-API key. You can register your api key here: https://steamcommunity.com/dev",
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
<option value="dns">
|
<option value="dns">
|
||||||
DNS
|
DNS
|
||||||
</option>
|
</option>
|
||||||
|
<option value="steam">
|
||||||
|
Steam Gameserver
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -48,17 +51,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- TCP Port / Ping / DNS only -->
|
<!-- TCP Port / Ping / DNS only -->
|
||||||
<div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' " class="my-3">
|
<div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' || monitor.type === 'steam' " class="my-3">
|
||||||
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
|
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
|
||||||
<input id="hostname" v-model="monitor.hostname" type="text" class="form-control" :pattern="`${ipRegexPattern}|${hostnameRegexPattern}`" required>
|
<input id="hostname" v-model="monitor.hostname" type="text" class="form-control" :pattern="`${ipRegexPattern}|${hostnameRegexPattern}`" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- For TCP Port Type -->
|
<!-- For TCP Port Type -->
|
||||||
<div v-if="monitor.type === 'port' " class="my-3">
|
<div v-if="monitor.type === 'port'" class="my-3">
|
||||||
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
<label for="port" class="form-label">{{ $t("Port") }}</label>
|
||||||
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
<input id="port" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- For Steam Query Port Type -->
|
||||||
|
<div v-if="monitor.type === 'steam' " class="my-3">
|
||||||
|
<label for="queryport" class="form-label">{{ $t("Query Port") }}</label>
|
||||||
|
<input id="queryport" v-model="monitor.port" type="number" class="form-control" required min="0" max="65535" step="1">
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- For DNS Type -->
|
<!-- For DNS Type -->
|
||||||
<template v-if="monitor.type === 'dns'">
|
<template v-if="monitor.type === 'dns'">
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
@ -93,6 +102,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- For Steam Type -->
|
||||||
|
<div class="my-3" v-if="monitor.type === 'steam'">
|
||||||
|
<label for="steamApiKey" class="form-label">{{ $t("Steam Web-API Key") }}</label>
|
||||||
|
<input id="steamApiKey" v-model="monitor.apikey" type="text" class="form-control" required>
|
||||||
|
<div class="form-text">
|
||||||
|
{{ $t("steamApiKeyDescription") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
<label for="interval" class="form-label">{{ $t("Heartbeat Interval") }} ({{ $t("checkEverySecond", [ monitor.interval ]) }})</label>
|
||||||
<input id="interval" v-model="monitor.interval" type="number" class="form-control" required min="20" step="1">
|
<input id="interval" v-model="monitor.interval" type="number" class="form-control" required min="20" step="1">
|
||||||
@ -328,7 +346,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.isEdit) {
|
} else if (this.isEdit) {
|
||||||
this.$root.getSocket().emit("getMonitor", this.$route.params.id, (res) => {
|
this.$root.getSocket().emit("getMonitor", this.$route.params.id, (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
this.monitor = res.monitor;
|
this.monitor = res.monitor;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user