From 9a30f52a27ed818d3d7c8c51304fba1623992913 Mon Sep 17 00:00:00 2001 From: "Joris W. van Rijn" Date: Tue, 20 May 2025 10:04:19 +0200 Subject: [PATCH] improved status texts --- src/components/services/Gatus.vue | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/services/Gatus.vue b/src/components/services/Gatus.vue index 24f416c..51e0e47 100644 --- a/src/components/services/Gatus.vue +++ b/src/components/services/Gatus.vue @@ -6,13 +6,15 @@ - @@ -32,6 +34,7 @@ export default { return { up: 0, down: 0, + avgRespTime: 0, }; }, computed: { @@ -39,24 +42,21 @@ export default { return this.up + this.down; }, percentageGood: function () { - if (this.up == 0) { - return 0; - } + if (this.up == 0) return 0; return Math.round((this.up / this.total) * 100); }, status: function () { - if (this.up == 0 && this.down == 0) { - return ""; - } + if (this.up == 0 && this.down == 0) return false; if (this.down == this.total) return "bad"; if (this.up == this.total) return "good"; return "warn"; }, statusMessage: function () { - if (this.up == 0 && this.down == 0) { - return ""; - } - return `${this.up}/${this.total} endpoints are up`; + if (this.up == 0 && this.down == 0) return false; + return { + up: `${this.up}/${this.total} up`, + avgRes: `${Math.round(this.avgRespTime * 100) / 100} ms avg.`, + }; }, }, created() { @@ -74,6 +74,9 @@ export default { endpoints[i].results[endpoints[i].results.length - 1]; if (latestResult.success) { this.up++; + const duration = latestResult.duration / 1000000; // convert to ms + console.log(`${endpoints[i].name}: ${duration}ms`); + this.avgRespTime = (this.avgRespTime + duration) / this.up; } else { this.down++; }