From 9e8f455bbb1c32b41ffb0ec61512a4c861360bef Mon Sep 17 00:00:00 2001 From: Azareal Date: Thu, 16 Aug 2018 15:27:26 +1000 Subject: [PATCH] Added resource utilisation data to the Debug Page. --- common/pages.go | 6 ++++++ langs/english.json | 7 ++++++- routes/panel/debug.go | 6 +++++- templates/panel_debug.html | 25 +++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/common/pages.go b/common/pages.go index de92ad60..cb4f4f0b 100644 --- a/common/pages.go +++ b/common/pages.go @@ -3,6 +3,7 @@ package common import ( "html/template" "net/http" + "runtime" "sync" "time" ) @@ -394,8 +395,13 @@ type PanelDebugPage struct { GoVersion string DBVersion string Uptime string + OpenConns int DBAdapter string + + Goroutines int + CPUs int + MemStats runtime.MemStats } type PageSimple struct { diff --git a/langs/english.json b/langs/english.json index 54e43dab..4a9974a2 100644 --- a/langs/english.json +++ b/langs/english.json @@ -793,11 +793,16 @@ "panel_backups_head":"Backups", "panel_backups_download":"Download", "panel_backups_no_backups":"There aren't any backups available at this time.", + "panel_debug_head":"Debug", "panel_debug_go_version_label":"Go Version", "panel_debug_database_version_label":"DB Version", "panel_debug_uptime_label":"Uptime", + "panel_debug_open_database_connections_label":"Open DB Conns", - "panel_debug_adapter_label":"Adapter" + "panel_debug_adapter_label":"Adapter", + + "panel_debug_goroutine_count_label":"Goroutines", + "panel_debug_cpu_count_label":"CPUs" } } \ No newline at end of file diff --git a/routes/panel/debug.go b/routes/panel/debug.go index d4d346d5..a0d24a1e 100644 --- a/routes/panel/debug.go +++ b/routes/panel/debug.go @@ -36,7 +36,11 @@ func Debug(w http.ResponseWriter, r *http.Request, user common.User) common.Rout openConnCount := dbStats.OpenConnections // Disk I/O? // TODO: Fetch the adapter from Builder rather than getting it from a global? + goroutines := runtime.NumGoroutine() + cpus := runtime.NumCPU() + var memStats runtime.MemStats + runtime.ReadMemStats(&memStats) - pi := common.PanelDebugPage{basePage, goVersion, dbVersion, uptime, openConnCount, qgen.Builder.GetAdapter().GetName()} + pi := common.PanelDebugPage{basePage, goVersion, dbVersion, uptime, openConnCount, qgen.Builder.GetAdapter().GetName(), goroutines, cpus, memStats} return panelRenderTemplate("panel_debug", w, r, user, &pi) } diff --git a/templates/panel_debug.html b/templates/panel_debug.html index c92ea160..2d1a825d 100644 --- a/templates/panel_debug.html +++ b/templates/panel_debug.html @@ -17,11 +17,36 @@
{{lang "panel_debug_open_database_connections_label"}}
{{lang "panel_debug_adapter_label"}}
+ {{/** TODO: Use this for active database connections when Go 1.11 lands **/}}
???
{{.OpenConns}}
{{.DBAdapter}}
?
+ +
{{lang "panel_debug_goroutine_count_label"}}
+
{{lang "panel_debug_cpu_count_label"}}
+
HeapAlloc
+ +
{{.Goroutines}}
+
{{.CPUs}}
+
{{.MemStats.HeapAlloc}}
+ +
HeapSys
+
HeapIdle
+
HeapObjects
+ +
{{.MemStats.HeapSys}}
+
{{.MemStats.HeapIdle}}
+
{{.MemStats.HeapObjects}}
+ +
???
+
???
+
StackInuse
+ +
?
+
?
+
{{.MemStats.StackInuse}}