diff --git a/.gitignore b/.gitignore index 8d435974f..9caa313cb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist-ssr /data !/data/.gitkeep +.vscode \ No newline at end of file diff --git a/db/kuma.db b/db/kuma.db index 07c93cf89..6e02ccc01 100644 Binary files a/db/kuma.db and b/db/kuma.db differ diff --git a/server/model/monitor.js b/server/model/monitor.js index 162772875..4545541e3 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -16,7 +16,6 @@ const {Notification} = require("../notification") * 1 = UP */ class Monitor extends BeanModel { - async toJSON() { let notificationIDList = {}; @@ -35,6 +34,7 @@ class Monitor extends BeanModel { url: this.url, hostname: this.hostname, port: this.port, + maxretries: this.maxretries, weight: this.weight, active: this.active, type: this.type, @@ -46,6 +46,7 @@ class Monitor extends BeanModel { start(io) { let previousBeat = null; + let retries = 0; const beat = async () => { console.log(`Monitor ${this.id}: Heartbeat`) @@ -109,12 +110,18 @@ class Monitor extends BeanModel { bean.status = 1; } + retries = 0; + } catch (error) { + if ((this.maxretries > 0) && (retries < this.maxretries)) { + retries++; + bean.status = 2; + } bean.msg = error.message; } - // Mark as important if status changed - if (! previousBeat || previousBeat.status !== bean.status) { + // Mark as important if status changed, ignore pending pings + if ((! previousBeat || previousBeat.status !== bean.status) && bean.status !== 2) { bean.important = true; // Do not send if first beat is UP @@ -233,7 +240,7 @@ class Monitor extends BeanModel { } total += value; - if (row.status === 0) { + if (row.status === 0 || row.status === 2) { downtime += value; } } diff --git a/server/server.js b/server/server.js index bd5894775..567ff490c 100644 --- a/server/server.js +++ b/server/server.js @@ -219,6 +219,7 @@ let needSetup = false; bean.url = monitor.url bean.interval = monitor.interval bean.hostname = monitor.hostname; + bean.maxretries = monitor.maxretries; bean.port = monitor.port; bean.keyword = monitor.keyword; diff --git a/src/assets/vars.scss b/src/assets/vars.scss index 31b0262d8..ebec378a5 100644 --- a/src/assets/vars.scss +++ b/src/assets/vars.scss @@ -1,7 +1,8 @@ $primary: #5CDD8B; $danger: #DC3545; +$warning: #f8a306; $link-color: #111; $border-radius: 50rem; $highlight: #7ce8a4; -$highlight-white: #e7faec; +$highlight-white: #e7faec; \ No newline at end of file diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index 48ffd2926..03cdceca6 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -3,7 +3,7 @@
span { - width: 45px; + width: 54px; } diff --git a/src/components/Uptime.vue b/src/components/Uptime.vue index ad8114fcb..322b35f70 100644 --- a/src/components/Uptime.vue +++ b/src/components/Uptime.vue @@ -30,6 +30,8 @@ export default { return "danger" } else if (this.lastHeartBeat.status === 1) { return "primary" + } else if (this.lastHeartBeat.status === 2) { + return "warning" } else { return "secondary" } diff --git a/src/mixins/socket.js b/src/mixins/socket.js index f0a3b1a6a..42de1eb3f 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -274,6 +274,11 @@ export default { text: "Down", color: "danger" }; + } else if (lastHeartBeat.status === 2) { + result[monitorID] = { + text: "Pending", + color: "warning" + }; } else { result[monitorID] = unknown; } diff --git a/src/pages/DashboardHome.vue b/src/pages/DashboardHome.vue index 820842bac..87380c7c2 100644 --- a/src/pages/DashboardHome.vue +++ b/src/pages/DashboardHome.vue @@ -90,6 +90,8 @@ export default { result.up++; } else if (beat.status === 0) { result.down++; + } else if (beat.status === 2) { + result.up++; } else { result.unknown++; } diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 01af50610..e4898c33d 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -48,6 +48,11 @@
+
+ + +
+
@@ -61,7 +66,7 @@

Notifications

Not available, please setup.

-
+