From 0876b1cbf5bc2beea8f28e7f93190a6f7e57f807 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 22 Apr 2025 13:14:12 +0200 Subject: [PATCH 01/14] chore:extracted the group monitor to a different monitoring type (#4395) --- server/model/monitor.js | 35 +------------------------ server/monitor-types/group.js | 49 +++++++++++++++++++++++++++++++++++ server/uptime-kuma-server.js | 2 ++ 3 files changed, 52 insertions(+), 34 deletions(-) create mode 100644 server/monitor-types/group.js diff --git a/server/model/monitor.js b/server/model/monitor.js index 5999d93e7..a07f2595a 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -380,39 +380,6 @@ class Monitor extends BeanModel { if (await Monitor.isUnderMaintenance(this.id)) { bean.msg = "Monitor under maintenance"; bean.status = MAINTENANCE; - } else if (this.type === "group") { - const children = await Monitor.getChildren(this.id); - - if (children.length > 0) { - bean.status = UP; - bean.msg = "All children up and running"; - for (const child of children) { - if (!child.active) { - // Ignore inactive childs - continue; - } - const lastBeat = await Monitor.getPreviousHeartbeat(child.id); - - // Only change state if the monitor is in worse conditions then the ones before - // lastBeat.status could be null - if (!lastBeat) { - bean.status = PENDING; - } else if (bean.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { - bean.status = lastBeat.status; - } else if (bean.status === PENDING && lastBeat.status === DOWN) { - bean.status = lastBeat.status; - } - } - - if (bean.status !== UP) { - bean.msg = "Child inaccessible"; - } - } else { - // Set status pending if group is empty - bean.status = PENDING; - bean.msg = "Group empty"; - } - } else if (this.type === "http" || this.type === "keyword" || this.type === "json-query") { // Do not do any queries/high loading things before the "bean.ping" let startTime = dayjs().valueOf(); @@ -1625,7 +1592,7 @@ class Monitor extends BeanModel { /** * Gets all Children of the monitor * @param {number} monitorID ID of monitor to get - * @returns {Promise>} Children + * @returns {Promise[]>} Children */ static async getChildren(monitorID) { return await R.getAll(` diff --git a/server/monitor-types/group.js b/server/monitor-types/group.js new file mode 100644 index 000000000..28d0443d4 --- /dev/null +++ b/server/monitor-types/group.js @@ -0,0 +1,49 @@ +const { UP, PENDING, DOWN } = require("../../src/util"); +const { MonitorType } = require("./monitor-type"); +const Monitor = require("../model/monitor"); + +class GroupMonitorType extends MonitorType { + name = "group"; + + /** + * @inheritdoc + */ + async check(monitor, heartbeat, _server) { + const children = await Monitor.getChildren(monitor.id); + + if (children.length > 0) { + heartbeat.status = UP; + heartbeat.msg = "All children up and running"; + for (const child of children) { + if (!child.active) { + // Ignore inactive childs + continue; + } + const lastBeat = await Monitor.getPreviousHeartbeat(child.id); + + // Only change state if the monitor is in worse conditions then the ones before + // lastBeat.status could be null + if (!lastBeat) { + heartbeat.status = PENDING; + } else if (heartbeat.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { + heartbeat.status = lastBeat.status; + } else if (heartbeat.status === PENDING && lastBeat.status === DOWN) { + heartbeat.status = lastBeat.status; + } + } + + if (heartbeat.status !== UP) { + heartbeat.msg = "Child inaccessible"; + } + } else { + // Set status pending if group is empty + heartbeat.status = PENDING; + heartbeat.msg = "Group empty"; + } + } +} + +module.exports = { + GroupMonitorType, +}; + diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 062f098d7..cdaa83dfc 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -113,6 +113,7 @@ class UptimeKumaServer { UptimeKumaServer.monitorTypeList["tailscale-ping"] = new TailscalePing(); UptimeKumaServer.monitorTypeList["dns"] = new DnsMonitorType(); UptimeKumaServer.monitorTypeList["mqtt"] = new MqttMonitorType(); + UptimeKumaServer.monitorTypeList["group"] = new GroupMonitorType(); UptimeKumaServer.monitorTypeList["snmp"] = new SNMPMonitorType(); UptimeKumaServer.monitorTypeList["mongodb"] = new MongodbMonitorType(); UptimeKumaServer.monitorTypeList["rabbitmq"] = new RabbitMqMonitorType(); @@ -551,6 +552,7 @@ const { RealBrowserMonitorType } = require("./monitor-types/real-browser-monitor const { TailscalePing } = require("./monitor-types/tailscale-ping"); const { DnsMonitorType } = require("./monitor-types/dns"); const { MqttMonitorType } = require("./monitor-types/mqtt"); +const { GroupMonitorType } = require("./monitor-types/group"); const { SNMPMonitorType } = require("./monitor-types/snmp"); const { MongodbMonitorType } = require("./monitor-types/mongodb"); const { RabbitMqMonitorType } = require("./monitor-types/rabbitmq"); From 3b58ac3fd3712df192741b6b7bfd759d4624fd2c Mon Sep 17 00:00:00 2001 From: Ryo Hanafusa Date: Fri, 25 Apr 2025 20:47:18 +0900 Subject: [PATCH 02/14] feat: Extend the length of status bar and feed sufficient data (#5241) Co-authored-by: Frank Elsinga --- server/routers/status-page-router.js | 2 +- src/components/MonitorListItem.vue | 4 ++-- src/components/PublicGroupList.vue | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/routers/status-page-router.js b/server/routers/status-page-router.js index 893f57564..6e57451f1 100644 --- a/server/routers/status-page-router.js +++ b/server/routers/status-page-router.js @@ -89,7 +89,7 @@ router.get("/api/status-page/heartbeat/:slug", cache("1 minutes"), async (reques SELECT * FROM heartbeat WHERE monitor_id = ? ORDER BY time DESC - LIMIT 50 + LIMIT 100 `, [ monitorID, ]); diff --git a/src/components/MonitorListItem.vue b/src/components/MonitorListItem.vue index 93c1deab4..ce38086b9 100644 --- a/src/components/MonitorListItem.vue +++ b/src/components/MonitorListItem.vue @@ -14,7 +14,7 @@
-
+
@@ -26,7 +26,7 @@
-
+
diff --git a/src/components/PublicGroupList.vue b/src/components/PublicGroupList.vue index bacddbf13..38aca2957 100644 --- a/src/components/PublicGroupList.vue +++ b/src/components/PublicGroupList.vue @@ -33,7 +33,7 @@ diff --git a/src/lang/en.json b/src/lang/en.json index 37c023ee4..009d24ee6 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1093,5 +1093,6 @@ "the smsplanet documentation": "the smsplanet documentation", "Phone numbers": "Phone numbers", "Sender name": "Sender name", - "smsplanetNeedToApproveName": "Needs to be approved in the client panel" + "smsplanetNeedToApproveName": "Needs to be approved in the client panel", + "Disable URL in Notification": "Disable URL in Notification" } From eb18677e4fa00f9c709451d8f37e82858419a119 Mon Sep 17 00:00:00 2001 From: Pargorn Ruasijan Date: Thu, 8 May 2025 03:29:27 +0700 Subject: [PATCH 14/14] fixed: #5564 slack notifications no preview available (#5824) --- server/notification-providers/slack.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/notification-providers/slack.js b/server/notification-providers/slack.js index 5e25a1fbc..455d787c7 100644 --- a/server/notification-providers/slack.js +++ b/server/notification-providers/slack.js @@ -145,6 +145,7 @@ class Slack extends NotificationProvider { const title = "Uptime Kuma Alert"; let data = { + "text": msg, "channel": notification.slackchannel, "username": notification.slackusername, "icon_emoji": notification.slackiconemo,