From f8f9f59464ab8fcc6bf57b159d51f2660b74152c Mon Sep 17 00:00:00 2001 From: No0Vad Date: Sat, 11 Sep 2021 18:54:55 +0200 Subject: [PATCH 1/6] Added support for a retry interval to monitors If a check fails and retries are used you can now specify a specific value for that. So you can check faster if the site goes back up again. --- db/patch-add-retry-interval-monitor.sql | 7 +++++++ server/database.js | 1 + server/model/monitor.js | 14 ++++++++++---- server/server.js | 1 + src/languages/en.js | 4 ++++ src/pages/EditMonitor.vue | 13 +++++++++++++ 6 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 db/patch-add-retry-interval-monitor.sql diff --git a/db/patch-add-retry-interval-monitor.sql b/db/patch-add-retry-interval-monitor.sql new file mode 100644 index 000000000..adb646232 --- /dev/null +++ b/db/patch-add-retry-interval-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD retry_interval INTEGER default 0 not null; + +COMMIT; \ No newline at end of file diff --git a/server/database.js b/server/database.js index e0bb0c9b8..579f1b06a 100644 --- a/server/database.js +++ b/server/database.js @@ -30,6 +30,7 @@ class Database { static patchList = { "patch-setting-value-type.sql": true, "patch-improve-performance.sql": true, + "patch-add-retry-interval-monitor.sql": true } /** diff --git a/server/model/monitor.js b/server/model/monitor.js index 89208a3fd..876d0ca19 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -43,6 +43,7 @@ class Monitor extends BeanModel { active: this.active, type: this.type, interval: this.interval, + retryInterval: this.retryInterval, keyword: this.keyword, ignoreTls: this.getIgnoreTls(), upsideDown: this.isUpsideDown(), @@ -293,12 +294,17 @@ class Monitor extends BeanModel { bean.important = false; } + let beatInterval = this.interval; + if (bean.status === UP) { - console.info(`Monitor #${this.id} '${this.name}': Successful Response: ${bean.ping} ms | Interval: ${this.interval} seconds | Type: ${this.type}`) + console.info(`Monitor #${this.id} '${this.name}': Successful Response: ${bean.ping} ms | Interval: ${beatInterval} seconds | Type: ${this.type}`) } else if (bean.status === PENDING) { - console.warn(`Monitor #${this.id} '${this.name}': Pending: ${bean.msg} | Max retries: ${this.maxretries} | Type: ${this.type}`) + if (this.retryInterval > 0) { + beatInterval = this.retryInterval; + } + console.warn(`Monitor #${this.id} '${this.name}': Pending: ${bean.msg} | Max retries: ${this.maxretries} | Retry: ${retries} | Retry Interval: ${beatInterval} seconds | Type: ${this.type}`) } else { - console.warn(`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Type: ${this.type}`) + console.warn(`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type}`) } io.to(this.user_id).emit("heartbeat", bean.toJSON()); @@ -310,7 +316,7 @@ class Monitor extends BeanModel { previousBeat = bean; if (! this.isStop) { - this.heartbeatInterval = setTimeout(beat, this.interval * 1000); + this.heartbeatInterval = setTimeout(beat, beatInterval * 1000); } } diff --git a/server/server.js b/server/server.js index 2949c4be7..67b99b176 100644 --- a/server/server.js +++ b/server/server.js @@ -324,6 +324,7 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString(); bean.type = monitor.type bean.url = monitor.url bean.interval = monitor.interval + bean.retryInterval = monitor.retryInterval; bean.hostname = monitor.hostname; bean.maxretries = monitor.maxretries; bean.port = monitor.port; diff --git a/src/languages/en.js b/src/languages/en.js index 585736857..31fc0ef45 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -1,8 +1,11 @@ export default { languageName: "English", checkEverySecond: "Check every {0} seconds.", + retryCheckEverySecond: "Retry every {0} seconds.", "Avg.": "Avg. ", retriesDescription: "Maximum retries before the service is marked as down and a notification is sent", + retryIntervalInactive: "Inactive", + retryIntervalDescription: "If retries are and used this value is greater then zero this interval will be used instead.", ignoreTLSError: "Ignore TLS/SSL error for HTTPS websites", upsideDownModeDescription: "Flip the status upside down. If the service is reachable, it is DOWN.", maxRedirectDescription: "Maximum number of redirects to follow. Set to 0 to disable redirects.", @@ -64,6 +67,7 @@ export default { Port: "Port", "Heartbeat Interval": "Heartbeat Interval", Retries: "Retries", + "Heartbeat Retry Interval": "Heartbeat Retry Interval", Advanced: "Advanced", "Upside Down Mode": "Upside Down Mode", "Max. Redirects": "Max. Redirects", diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 420c4900e..6eae8a893 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -106,6 +106,18 @@ +
+ + +
+ {{ $t("retryIntervalDescription") }} +
+
+

{{ $t("Advanced") }}

@@ -289,6 +301,7 @@ export default { name: "", url: "https://", interval: 60, + retryInterval: 0, maxretries: 0, notificationIDList: {}, ignoreTls: false, From 3d27561e5a276589e4c3627146bf628790b3d0b5 Mon Sep 17 00:00:00 2001 From: No0Vad Date: Sun, 12 Sep 2021 00:24:33 +0200 Subject: [PATCH 2/6] Update en.js Fixed spelling error --- src/languages/en.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/en.js b/src/languages/en.js index 31fc0ef45..08ef3b8c8 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -5,7 +5,7 @@ export default { "Avg.": "Avg. ", retriesDescription: "Maximum retries before the service is marked as down and a notification is sent", retryIntervalInactive: "Inactive", - retryIntervalDescription: "If retries are and used this value is greater then zero this interval will be used instead.", + retryIntervalDescription: "If retries are used and this value is greater then zero this interval will be used instead.", ignoreTLSError: "Ignore TLS/SSL error for HTTPS websites", upsideDownModeDescription: "Flip the status upside down. If the service is reachable, it is DOWN.", maxRedirectDescription: "Maximum number of redirects to follow. Set to 0 to disable redirects.", From 389d247463fdda737c21a0f847c29d356723fb24 Mon Sep 17 00:00:00 2001 From: No0Vad Date: Sun, 12 Sep 2021 17:05:23 +0200 Subject: [PATCH 3/6] Update server/database.js Co-authored-by: Adam Stachowicz --- server/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/database.js b/server/database.js index 579f1b06a..4cc01a5a5 100644 --- a/server/database.js +++ b/server/database.js @@ -30,7 +30,7 @@ class Database { static patchList = { "patch-setting-value-type.sql": true, "patch-improve-performance.sql": true, - "patch-add-retry-interval-monitor.sql": true + "patch-add-retry-interval-monitor.sql": true, } /** From 2617e1f4d80c1bebbb39deb26ca2ae75f9081fbf Mon Sep 17 00:00:00 2001 From: No0Vad Date: Mon, 13 Sep 2021 00:25:18 +0200 Subject: [PATCH 4/6] Update database.js --- server/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/database.js b/server/database.js index b8f3f9925..18da3298a 100644 --- a/server/database.js +++ b/server/database.js @@ -29,7 +29,7 @@ class Database { */ static patchList = { "patch-setting-value-type.sql": true, - "patch-improve-performance.sql": true, + "patch-improve-performance.sql": true, "patch-2fa.sql": true, "patch-add-retry-interval-monitor.sql": true, } From fc9b4617ca9726f3650b8da5e12e7e4249cd629a Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 14 Sep 2021 15:48:25 +0800 Subject: [PATCH 5/6] link interval and retryInterval --- src/pages/EditMonitor.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 82aa7d23a..73ab0479b 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -108,11 +108,11 @@
- +
{{ $t("retryIntervalDescription") }}
@@ -261,6 +261,12 @@ export default { "$route.fullPath"() { this.init(); }, + "monitor.interval"(value, oldValue) { + // Link interval and retryInerval if they are the same value. + if (this.monitor.retryInterval === oldValue) { + this.monitor.retryInterval = value; + } + } }, mounted() { this.init(); @@ -302,7 +308,7 @@ export default { name: "", url: "https://", interval: 60, - retryInterval: 0, + retryInterval: this.interval, maxretries: 0, notificationIDList: {}, ignoreTls: false, From 1300448bed9f7f05f5f8f6bc2862e2b0dbbc4d88 Mon Sep 17 00:00:00 2001 From: No0Vad Date: Wed, 15 Sep 2021 00:59:06 +0200 Subject: [PATCH 6/6] Adjustments to the retry interval The monitor logic for when to use "retryInterval" is updated. Also removed some texts when they are no longer needed. --- server/model/monitor.js | 2 +- src/languages/en.js | 2 -- src/pages/EditMonitor.vue | 6 +----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 876d0ca19..92ef9834d 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -299,7 +299,7 @@ class Monitor extends BeanModel { if (bean.status === UP) { console.info(`Monitor #${this.id} '${this.name}': Successful Response: ${bean.ping} ms | Interval: ${beatInterval} seconds | Type: ${this.type}`) } else if (bean.status === PENDING) { - if (this.retryInterval > 0) { + if (this.retryInterval !== this.interval) { beatInterval = this.retryInterval; } console.warn(`Monitor #${this.id} '${this.name}': Pending: ${bean.msg} | Max retries: ${this.maxretries} | Retry: ${retries} | Retry Interval: ${beatInterval} seconds | Type: ${this.type}`) diff --git a/src/languages/en.js b/src/languages/en.js index 88c3dc1ef..98a4010e6 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -4,8 +4,6 @@ export default { retryCheckEverySecond: "Retry every {0} seconds.", "Avg.": "Avg.", retriesDescription: "Maximum retries before the service is marked as down and a notification is sent", - retryIntervalInactive: "Inactive", - retryIntervalDescription: "If retries are used and this value is greater then zero this interval will be used instead.", ignoreTLSError: "Ignore TLS/SSL error for HTTPS websites", upsideDownModeDescription: "Flip the status upside down. If the service is reachable, it is DOWN.", maxRedirectDescription: "Maximum number of redirects to follow. Set to 0 to disable redirects.", diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 73ab0479b..045826286 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -109,13 +109,9 @@
-
- {{ $t("retryIntervalDescription") }} -

{{ $t("Advanced") }}