change memoer check output
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Kekskurse 2021-09-20 16:27:05 +02:00
parent a1d2a82742
commit b5196312d2
Signed by: kekskurse
GPG key ID: 728ACCB59341E7E4
2 changed files with 23 additions and 6 deletions

View file

@ -15,11 +15,14 @@ type Memory struct {
func (h Memory) Execute() (ok bool, data interface{}, err error) { func (h Memory) Execute() (ok bool, data interface{}, err error) {
memory, err := memory.Get() memory, err := memory.Get()
p := float64(100) / float64(memory.Total) * float64(memory.Used) 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 { 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 { func (h Memory) Name() string {

View file

@ -30,12 +30,11 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header" id="ramtitle">
Check RAM Check RAM
</div> </div>
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Check ram</h5> <p class="card-text" id="rampercent">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div> </div>
</div> </div>
</div> </div>
@ -76,11 +75,26 @@
$("#hddtitle").addClass("bg-danger"); $("#hddtitle").addClass("bg-danger");
$("#hddtitle").removeClass("bg-success"); $("#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('<b>Ram</b><br><div class="progress"><div class="progress-bar" role="progressbar" style="width: '+o.Checks["Memory usage"].data["ram"]+'%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">' +o.Checks["Memory usage"].data["ram"]+ '%</div></div>');
console.log(keys) console.log(keys)
console.log(o.Checks["Disc space"].success) console.log(o.Checks["Disc space"].success)
setTimeout("getData();", 2000); setTimeout("getData();", 10000);
} }
getData(); getData();
</script> </script>