From b5196312d21998ca09c88484a9214e84436c76cd Mon Sep 17 00:00:00 2001 From: kekskurse Date: Mon, 20 Sep 2021 16:27:05 +0200 Subject: [PATCH] change memoer check output --- internal/pkg/checks/memory.go | 7 +++++-- template/index.html | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/internal/pkg/checks/memory.go b/internal/pkg/checks/memory.go index 91a46a3..97cac53 100644 --- a/internal/pkg/checks/memory.go +++ b/internal/pkg/checks/memory.go @@ -15,11 +15,14 @@ type Memory struct { func (h Memory) Execute() (ok bool, data interface{}, err error) { memory, err := memory.Get() p := float64(100) / float64(memory.Total) * float64(memory.Used) + res := make(map[string]interface{}) + res["row"] = memory + res["ram"] = p if p > h.Config.Max { - return false, memory, nil + return false, res, nil } - return true, memory,nil + return true, res,nil } func (h Memory) Name() string { diff --git a/template/index.html b/template/index.html index 73f8b6a..d237671 100644 --- a/template/index.html +++ b/template/index.html @@ -30,12 +30,11 @@
-
+
Check RAM
-
Check ram
-

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

+

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

@@ -76,11 +75,26 @@ $("#hddtitle").addClass("bg-danger"); $("#hddtitle").removeClass("bg-success"); } + + //ram + + if (o.Checks["Memory usage"].success) { + $("#ramtitle").addClass("bg-success"); + $("#ramtitle").removeClass("bg-error"); + } else { + $("#ramtitle").addClass("bg-danger"); + $("#ramtitle").removeClass("bg-success"); + } + + $("#rampercent").empty() + $("#rampercent").append('Ram
' +o.Checks["Memory usage"].data["ram"]+ '%
'); + + console.log(keys) console.log(o.Checks["Disc space"].success) - setTimeout("getData();", 2000); + setTimeout("getData();", 10000); } getData();