diff --git a/server/monitor-types/pterodactyl-node.js b/server/monitor-types/pterodactyl-node.js new file mode 100644 index 000000000..2cc2eab4c --- /dev/null +++ b/server/monitor-types/pterodactyl-node.js @@ -0,0 +1,34 @@ +const { MonitorType } = require("./monitor-type"); +const { UP } = require("../../src/util"); +const axios = require("axios"); + +class PterodactylNode extends MonitorType { + name = "pterodactyl-node"; + + /** + * @inheritdoc + */ + async check(monitor, heartbeat, server) { + + await axios.get(`${monitor.nodeHost}/api/system`, { + 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.status = UP; + } else { + throw Error(`Node is down, Status ${res.status}`); + } + }); + + } + +} + +module.exports = { + PterodactylNode, +}; diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 062f098d7..db853726c 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -116,6 +116,7 @@ class UptimeKumaServer { UptimeKumaServer.monitorTypeList["snmp"] = new SNMPMonitorType(); UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType(); UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType(); + UptimeKumaServer.monitorTypeList["pterodactyl-node"] = new PterodactylNode(); // Allow all CORS origins (polling) in development let cors = undefined; @@ -554,4 +555,5 @@ const { MqttMonitorType } = require("./monitor-types/mqtt"); const { SNMPMonitorType } = require("./monitor-types/snmp"); const { MongodbMonitorType } = require("./monitor-types/mongodb"); const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq"); +const { PterodactylNode } = require("./monitor-types/pterodactyl-node"); const Monitor = require("./model/monitor"); diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 4763f8722..240f5ef9f 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -91,6 +91,9 @@ Tailscale Ping + + Pterodactyl Node + @@ -282,7 +285,7 @@ - + {{ $t("Hostname") }} - + {{ $t("Port") }} @@ -601,6 +604,12 @@ + + + {{ $t("API Key") }} + + + {{ $t("Resend Notification if Down X times consecutively") }} @@ -1111,7 +1120,8 @@ const monitorDefaults = { rabbitmqNodes: [], rabbitmqUsername: "", rabbitmqPassword: "", - conditions: [] + conditions: [], + apiKey: "", }; export default {