mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-05 04:42:34 +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
|
||||
*/
|
||||
async check(monitor, heartbeat, server) {
|
||||
|
||||
await axios.get(`${monitor.nodeHost}/api/system`, {
|
||||
const pingStart = Date.now();
|
||||
const url = new URL(monitor.url);
|
||||
url.port = monitor.port;
|
||||
url.pathname = "/api/system";
|
||||
await axios.get(url.href, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${monitor.apiKey}`
|
||||
}
|
||||
})
|
||||
.then(async res => {
|
||||
if (res.status === 200) {
|
||||
const data = await res.json();
|
||||
heartbeat.msg = `Node is up, Version ${data.version}`;
|
||||
heartbeat.msg = `Node is up, Version ${res.data.version}`;
|
||||
heartbeat.status = UP;
|
||||
heartbeat.ping = Date.now() - pingStart;
|
||||
} else {
|
||||
throw Error(`Node is down, Status ${res.status}`);
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
</div>
|
||||
|
||||
<!-- 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>
|
||||
<input id="url" v-model="monitor.url" type="url" class="form-control" pattern="https?://.+" required data-testid="url-input">
|
||||
</div>
|
||||
|
@ -285,7 +285,7 @@
|
|||
|
||||
<!-- Hostname -->
|
||||
<!-- 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>
|
||||
<input
|
||||
id="hostname"
|
||||
|
@ -576,6 +576,12 @@
|
|||
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 -->
|
||||
<div class="my-3">
|
||||
<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">
|
||||
</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">
|
||||
<label for="resend-interval" class="form-label">
|
||||
{{ $t("Resend Notification if Down X times consecutively") }}
|
||||
|
|
Loading…
Add table
Reference in a new issue