From 21b8dd0529f128df267f53a473c073e1c670fb13 Mon Sep 17 00:00:00 2001 From: kekskurse Date: Mon, 20 Sep 2021 15:45:01 +0200 Subject: [PATCH] gui --- config.yml | 2 +- main.go | 7 +++- template/index.html | 86 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 template/index.html diff --git a/config.yml b/config.yml index a808d58..ef5e15c 100644 --- a/config.yml +++ b/config.yml @@ -3,7 +3,7 @@ http: checks: hdd: - max_percent: 100 + max_percent: 90 load: max_load_1: 10 max_load_5: 8 diff --git a/main.go b/main.go index 15e40c6..f28143b 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + _ "embed" "encoding/json" "github.com/rs/zerolog/log" checks "http-server-status/internal/pkg/checks" @@ -8,6 +9,9 @@ import ( "sync" ) +//go:embed template/index.html +var s string + var checkList []checks.Check func init() { @@ -19,7 +23,7 @@ func init() { func main() { http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { - http.Redirect(writer, request, "/data.json", http.StatusSeeOther) + writer.Write([]byte(s)) }) http.HandleFunc("/data.json", handler) err := http.ListenAndServe(c.HTTP.Listen, nil) @@ -47,6 +51,7 @@ func handler(w http.ResponseWriter, r *http.Request) { } + type ResultReturn struct { Success bool `json:"success"` Data interface{} `json:"data"` diff --git a/template/index.html b/template/index.html new file mode 100644 index 0000000..1263782 --- /dev/null +++ b/template/index.html @@ -0,0 +1,86 @@ + + + + + + + + +
+
+
+

HTTP Status Page

+
+
+
+
+
+
+ Check HDD +
+
+

+ HDD 1: +

+
25%
+
+

+
+
+
+
+
+
+ Check RAM +
+
+
Check ram
+

Some quick example text to build on the card title and make up the bulk of the card's content.

+
+
+
+
+
+ + + \ No newline at end of file