diff --git a/db/patch-add-retry-interval-monitor.sql b/db/patch-add-retry-interval-monitor.sql new file mode 100644 index 00000000..adb64623 --- /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 7af75423..55d79df6 100644 --- a/server/database.js +++ b/server/database.js @@ -31,6 +31,7 @@ class Database { "patch-setting-value-type.sql": true, "patch-improve-performance.sql": true, "patch-2fa.sql": true, + "patch-add-retry-interval-monitor.sql": true, } /** diff --git a/server/model/monitor.js b/server/model/monitor.js index 6c4e17ee..c574df77 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -45,6 +45,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(), @@ -296,12 +297,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 !== 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}`) } 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()); @@ -313,7 +319,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 d6665a0c..b8d0c90f 100644 --- a/server/server.js +++ b/server/server.js @@ -487,6 +487,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 9d88c46e..025f002f 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -1,6 +1,7 @@ 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", ignoreTLSError: "Ignore TLS/SSL error for HTTPS websites", @@ -70,6 +71,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 cc836efe..2b80880c 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -106,6 +106,14 @@ +
+ + +
+

{{ $t("Advanced") }}

@@ -255,6 +263,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(); @@ -296,6 +310,7 @@ export default { name: "", url: "https://", interval: 60, + retryInterval: this.interval, maxretries: 0, notificationIDList: {}, ignoreTls: false,