From 78ad85a79d49252c812c2c4ebd30ced7ec6f8f94 Mon Sep 17 00:00:00 2001 From: pommee Date: Sun, 9 Feb 2025 13:10:04 +0100 Subject: [PATCH] fix: added db size to metrics and removed console logs --- internal/api/routes.go | 18 ++++++++++++++++++ website/clients.html | 10 +++++++--- website/domains.html | 10 +++++++--- website/index.html | 10 +++++++--- website/lists.html | 10 +++++++--- website/logs.html | 10 +++++++--- website/settings.html | 10 +++++++--- website/static/css/style.css | 1 + website/static/js/lists.js | 1 - website/static/js/logs.js | 2 -- website/static/js/serverStatus.js | 7 ++++++- website/static/js/upstream.js | 1 - website/static/js/util.js | 22 +++++++++++++++------- website/upstream.html | 10 +++++++--- 14 files changed, 89 insertions(+), 33 deletions(-) diff --git a/internal/api/routes.go b/internal/api/routes.go index 746ce05..c1ee874 100644 --- a/internal/api/routes.go +++ b/internal/api/routes.go @@ -115,6 +115,11 @@ func (apiServer *API) handleServer(c *gin.Context) { log.Error("%s", err) } + dbSize, err := getDBSize() + if err != nil { + log.Error("%s", err) + } + c.JSON(http.StatusOK, gin.H{ "portDNS": apiServer.Config.Port, "portWebsite": apiServer.DnsServer.Config.Port, @@ -123,6 +128,7 @@ func (apiServer *API) handleServer(c *gin.Context) { "usedMemPercentage": float64(vMem.Free) / 1024 / 1024 / 1024, "cpuUsage": cpuUsage[0], "cpuTemp": temp, + "dbSize": dbSize, }) } @@ -777,6 +783,18 @@ func getCPUTemperature() (float64, error) { return temp / 1000, nil } +func getDBSize() (float64, error) { + file, err := os.Stat("database.db") + if err != nil { + return 0, err + } + + sizeInBytes := file.Size() + sizeInMB := float64(sizeInBytes) / (1024 * 1024) + + return sizeInMB, nil +} + func getServerIP() (string, error) { addrs, err := net.InterfaceAddrs() if err != nil { diff --git a/website/clients.html b/website/clients.html index de3dd3d..32ffe44 100644 --- a/website/clients.html +++ b/website/clients.html @@ -25,18 +25,22 @@
-
+
-
+
-
+
+
+ + +
-
+
-
+
-
+
+
+ + +
-
+
-
+
-
+
+
+ + +
-
+
-
+
-
+
+
+ + +
-
+
-
+
-
+
+
+ + +
-
+
-
+
-
+
+
+ + +