diff options
-rw-r--r-- | http_handle_index.go | 6 | ||||
-rw-r--r-- | templates/index.tmpl | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/http_handle_index.go b/http_handle_index.go index 4632526..623c619 100644 --- a/http_handle_index.go +++ b/http_handle_index.go @@ -5,6 +5,7 @@ package main import ( "net/http" + "runtime" ) func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any) { @@ -17,5 +18,10 @@ func handle_index(w http.ResponseWriter, r *http.Request, params map[string]any) return } params["groups"] = groups + + // Memory currently allocated + memstats := runtime.MemStats{} + runtime.ReadMemStats(&memstats) + params["mem"] = memstats.Alloc render_template(w, "index", params) } diff --git a/templates/index.tmpl b/templates/index.tmpl index 2aa5729..917e7fe 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -53,12 +53,15 @@ <th scope="row">SSH fingerprint</th> <td><code>{{- .global.server_public_key_fingerprint -}}</code></td> </tr> + <tr> + <th scope="row">Memory usage</th> + <td> + Allocated {{ .mem }} bytes <a href="/:/gc/" class="btn btn-danger">Collect garbage</a> + </td> + </tr> </tbody> </table> </div> - <div class="padding-wrapper"> - <a href="/:/gc" class="btn btn-danger">Run the garbage collector</a> - </div> <footer> {{- template "footer" . -}} </footer> |