From 1ac904d6d6260a34d08a29249fb7cc15236ee787 Mon Sep 17 00:00:00 2001 From: OidaTiftla Date: Sun, 23 Jan 2022 15:22:57 +0100 Subject: [PATCH] Introduce resend interval if down --- package-lock.json | 4 ++-- package.json | 8 ++++---- server/model/monitor.js | 17 +++++++++++++++++ server/server.js | 7 +++++++ src/pages/EditMonitor.vue | 8 ++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc21a63f9..5253c3af4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uptime-kuma", - "version": "1.11.3", + "version": "1.11.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "uptime-kuma", - "version": "1.11.3", + "version": "1.11.4", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-svg-core": "~1.2.36", diff --git a/package.json b/package.json index 048a5e0a9..cd522a31b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uptime-kuma", - "version": "1.11.3", + "version": "1.11.4", "license": "MIT", "repository": { "type": "git", @@ -30,13 +30,13 @@ "build-docker": "npm run build && npm run build-docker-debian && npm run build-docker-alpine", "build-docker-alpine-base": "docker buildx build -f docker/alpine-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-alpine . --push", "build-docker-debian-base": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-debian . --push", - "build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.11.3-alpine --target release . --push", - "build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.11.3 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.11.3-debian --target release . --push", + "build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.11.4-alpine --target release . --push", + "build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.11.4 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.11.4-debian --target release . --push", "build-docker-nightly": "npm run build && docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push", "build-docker-nightly-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly-alpine --target nightly . --push", "build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain", "upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain", - "setup": "git checkout 1.11.3 && npm ci --production && npm run download-dist", + "setup": "git checkout 1.11.4 && npm ci --production && npm run download-dist", "download-dist": "node extra/download-dist.js", "update-version": "node extra/update-version.js", "mark-as-nightly": "node extra/mark-as-nightly.js", diff --git a/server/model/monitor.js b/server/model/monitor.js index c4441d63e..eaba61ad3 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -68,6 +68,7 @@ class Monitor extends BeanModel { type: this.type, interval: this.interval, retryInterval: this.retryInterval, + resendInterval: this.resendInterval, keyword: this.keyword, ignoreTls: this.getIgnoreTls(), upsideDown: this.isUpsideDown(), @@ -135,6 +136,7 @@ class Monitor extends BeanModel { bean.monitor_id = this.id; bean.time = R.isoDateTime(dayjs.utc()); bean.status = DOWN; + bean.lastNotifiedTime = previousBeat?.lastNotifiedTime || null; // after first update lastNotifiedTime will be undefined if (this.isUpsideDown()) { bean.status = flipStatus(bean.status); @@ -390,12 +392,27 @@ class Monitor extends BeanModel { debug(`[${this.name}] sendNotification`); await Monitor.sendNotification(isFirstBeat, this, bean); + // Set last notified time to now + bean.lastNotifiedTime = dayjs().valueOf(); + // Clear Status Page Cache debug(`[${this.name}] apicache clear`); apicache.clear(); } else { bean.important = false; + + if (bean.status === DOWN && this.resendInterval > 0) { + timeSinceLastNotified = dayjs().valueOf() - (bean.lastNotifiedTime || 0); + if (timeSinceLastNotified >= this.resendInterval) { + // Send notification again, because we are still DOWN + debug(`[${this.name}] sendNotification`); + await Monitor.sendNotification(isFirstBeat, this, bean); + + // Set last notified time to now + bean.lastNotifiedTime = dayjs().valueOf(); + } + } } if (bean.status === UP) { diff --git a/server/server.js b/server/server.js index 153cac4fd..5a9cf944a 100644 --- a/server/server.js +++ b/server/server.js @@ -588,6 +588,7 @@ exports.entryPage = "dashboard"; bean.basic_auth_pass = monitor.basic_auth_pass; bean.interval = monitor.interval; bean.retryInterval = monitor.retryInterval; + bean.resendInterval = monitor.resendInterval; bean.hostname = monitor.hostname; bean.maxretries = monitor.maxretries; bean.port = monitor.port; @@ -1082,6 +1083,7 @@ exports.entryPage = "dashboard"; let monitorListData = backupData.monitorList; let version17x = compareVersions.compare(backupData.version, "1.7.0", ">="); + let version1114 = compareVersions.compare(backupData.version, "1.11.4", ">="); // If the import option is "overwrite" it'll clear most of the tables, except "settings" and "user" if (importHandle == "overwrite") { @@ -1131,6 +1133,7 @@ exports.entryPage = "dashboard"; // Define default values let retryInterval = 0; + let resendInterval = 0; /* Only replace the default value with the backup file data for the specific version, where it appears the first time @@ -1139,6 +1142,9 @@ exports.entryPage = "dashboard"; if (version17x) { retryInterval = monitorListData[i].retryInterval; } + if (version1114) { + resendInterval = monitorListData[i].resendInterval; + } // --- End --- @@ -1154,6 +1160,7 @@ exports.entryPage = "dashboard"; basic_auth_pass: monitorListData[i].basic_auth_pass, interval: monitorListData[i].interval, retryInterval: retryInterval, + resendInterval: resendInterval, hostname: monitorListData[i].hostname, maxretries: monitorListData[i].maxretries, port: monitorListData[i].port, diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 4b6a920c8..b95c10980 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -137,6 +137,14 @@ +
+ + +
+

{{ $t("Advanced") }}