Add template for status page

This commit is contained in:
Lou Knauer 2022-03-24 10:35:52 +01:00
parent c9740e587d
commit b572ef2aef
4 changed files with 22 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
@ -39,6 +40,7 @@ var routes []Route = []Route{
{"/monitoring/systems/{cluster}", "monitoring/systems.tmpl", "Cluster <ID> - ClusterCockpit", false, setupClusterRoute}, {"/monitoring/systems/{cluster}", "monitoring/systems.tmpl", "Cluster <ID> - ClusterCockpit", false, setupClusterRoute},
{"/monitoring/node/{cluster}/{hostname}", "monitoring/node.tmpl", "Node <ID> - ClusterCockpit", false, setupNodeRoute}, {"/monitoring/node/{cluster}/{hostname}", "monitoring/node.tmpl", "Node <ID> - ClusterCockpit", false, setupNodeRoute},
{"/monitoring/analysis/{cluster}", "monitoring/analysis.tmpl", "Analaysis - ClusterCockpit", true, setupAnalysisRoute}, {"/monitoring/analysis/{cluster}", "monitoring/analysis.tmpl", "Analaysis - ClusterCockpit", true, setupAnalysisRoute},
{"/monitoring/status/{cluster}", "monitoring/status.tmpl", "Status of <ID> - ClusterCockpit", false, setupClusterRoute},
} }
func setupHomeRoute(i InfoType, r *http.Request) InfoType { func setupHomeRoute(i InfoType, r *http.Request) InfoType {
@ -118,6 +120,7 @@ func setupNodeRoute(i InfoType, r *http.Request) InfoType {
vars := mux.Vars(r) vars := mux.Vars(r)
i["cluster"] = vars["cluster"] i["cluster"] = vars["cluster"]
i["hostname"] = vars["hostname"] i["hostname"] = vars["hostname"]
i["id"] = fmt.Sprintf("%s (%s)", vars["cluster"], vars["hostname"])
from, to := r.URL.Query().Get("from"), r.URL.Query().Get("to") from, to := r.URL.Query().Get("from"), r.URL.Query().Get("to")
if from != "" || to != "" { if from != "" || to != "" {
i["from"] = from i["from"] = from

View File

@ -13,6 +13,7 @@ import (
"net/url" "net/url"
"os" "os"
"os/signal" "os/signal"
"runtime/debug"
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
@ -476,6 +477,9 @@ func main() {
api.OngoingArchivings.Wait() api.OngoingArchivings.Wait()
}() }()
if os.Getenv("GOGC") == "" {
debug.SetGCPercent(25)
}
systemdNotifiy(true, "running") systemdNotifiy(true, "running")
wg.Wait() wg.Wait()
log.Print("Gracefull shutdown completed!") log.Print("Gracefull shutdown completed!")

View File

@ -0,0 +1,14 @@
{{define "content"}}
<div id="svelte-app"></div>
{{end}}
{{define "stylesheets"}}
<link rel='stylesheet' href='/build/status.css'>
{{end}}
{{define "javascript"}}
<script>
const infos = {{ .Infos }};
const clusterCockpitConfig = {{ .Config }};
</script>
<script src='/build/status.js'></script>
{{end}}

View File

@ -48,6 +48,7 @@ func init() {
"monitoring/list.tmpl", "monitoring/list.tmpl",
"monitoring/user.tmpl", "monitoring/user.tmpl",
"monitoring/systems.tmpl", "monitoring/systems.tmpl",
"monitoring/status.tmpl",
"monitoring/node.tmpl", "monitoring/node.tmpl",
"monitoring/analysis.tmpl", "monitoring/analysis.tmpl",
} }