mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-06 13:12:33 +02:00
* Added db migration
* Made inputting the endpoint more user friendly & foolproof
This commit is contained in:
parent
346f7806f4
commit
5b074c834d
3 changed files with 31 additions and 12 deletions
16
db/knex_migrations/2024-10-30-2000-pterodactyl-apikey.js
Normal file
16
db/knex_migrations/2024-10-30-2000-pterodactyl-apikey.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
exports.up = function (knex) {
|
||||||
|
// Add new column monitor.api_key
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("monitor", function (table) {
|
||||||
|
table.string("api_key", 255).notNullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (knex) {
|
||||||
|
// Drop column monitor.api_key
|
||||||
|
return knex.schema
|
||||||
|
.alterTable("monitor", function (table) {
|
||||||
|
table.dropColumn("api_key");
|
||||||
|
});
|
||||||
|
};
|
|
@ -9,17 +9,20 @@ class PterodactylNode extends MonitorType {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async check(monitor, heartbeat, server) {
|
async check(monitor, heartbeat, server) {
|
||||||
|
const pingStart = Date.now();
|
||||||
await axios.get(`${monitor.nodeHost}/api/system`, {
|
const url = new URL(monitor.url);
|
||||||
|
url.port = monitor.port;
|
||||||
|
url.pathname = "/api/system";
|
||||||
|
await axios.get(url.href, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${monitor.apiKey}`
|
Authorization: `Bearer ${monitor.apiKey}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(async res => {
|
.then(async res => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = await res.json();
|
heartbeat.msg = `Node is up, Version ${res.data.version}`;
|
||||||
heartbeat.msg = `Node is up, Version ${data.version}`;
|
|
||||||
heartbeat.status = UP;
|
heartbeat.status = UP;
|
||||||
|
heartbeat.ping = Date.now() - pingStart;
|
||||||
} else {
|
} else {
|
||||||
throw Error(`Node is down, Status ${res.status}`);
|
throw Error(`Node is down, Status ${res.status}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- URL -->
|
<!-- URL -->
|
||||||
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' " class="my-3">
|
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'real-browser' || monitor.type === 'pterodactyl-node'" class="my-3">
|
||||||
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
<label for="url" class="form-label">{{ $t("URL") }}</label>
|
||||||
<input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required data-testid="url-input">
|
<input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required data-testid="url-input">
|
||||||
</div>
|
</div>
|
||||||
|
@ -285,7 +285,7 @@
|
||||||
|
|
||||||
<!-- Hostname -->
|
<!-- Hostname -->
|
||||||
<!-- TCP Port / Ping / DNS / Steam / MQTT / Radius / Tailscale Ping / SNMP only -->
|
<!-- TCP Port / Ping / DNS / Steam / MQTT / Radius / Tailscale Ping / SNMP only -->
|
||||||
<div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'tailscale-ping' || monitor.type === 'snmp' || monitor.type === 'pterodactyl-node'" class="my-3">
|
<div v-if="monitor.type === 'port' || monitor.type === 'ping' || monitor.type === 'dns' || monitor.type === 'steam' || monitor.type === 'gamedig' || monitor.type === 'mqtt' || monitor.type === 'radius' || monitor.type === 'tailscale-ping' || monitor.type === 'snmp'" class="my-3">
|
||||||
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
|
<label for="hostname" class="form-label">{{ $t("Hostname") }}</label>
|
||||||
<input
|
<input
|
||||||
id="hostname"
|
id="hostname"
|
||||||
|
@ -576,6 +576,12 @@
|
||||||
class="my-3"
|
class="my-3"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- ApiKey: Pterodactyl node only -->
|
||||||
|
<div v-if="monitor.type === 'pterodactyl-node'" class="my-3">
|
||||||
|
<label for="apiKey" class="form-label">{{ $t("API Key") }}</label>
|
||||||
|
<HiddenInput id="apiKey" v-model="monitor.apiKey" type="password" required></HiddenInput>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Interval -->
|
<!-- Interval -->
|
||||||
<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>
|
||||||
|
@ -604,12 +610,6 @@
|
||||||
<input id="timeout" v-model="monitor.timeout" type="number" class="form-control" required min="0" step="0.1">
|
<input id="timeout" v-model="monitor.timeout" type="number" class="form-control" required min="0" step="0.1">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ApiKey: Pterodactyl node only -->
|
|
||||||
<div v-if="monitor.type === 'pterodactyl-node'" class="my-3">
|
|
||||||
<label for="apiKey" class="form-label">{{ $t("API Key") }}</label>
|
|
||||||
<HiddenInput id="apiKey" v-model="monitor.apiKey" type="password" required></HiddenInput>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<label for="resend-interval" class="form-label">
|
<label for="resend-interval" class="form-label">
|
||||||
{{ $t("Resend Notification if Down X times consecutively") }}
|
{{ $t("Resend Notification if Down X times consecutively") }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue