fix memory swap issue
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Kekskurse 2021-09-20 23:22:02 +02:00
parent 4f861883fc
commit 27929b8039
Signed by: kekskurse
GPG Key ID: 728ACCB59341E7E4
1 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package checks
import (
"fmt"
"github.com/mackerelio/go-osstat/memory"
)
@ -15,12 +16,18 @@ type Memory struct {
func (h Memory) Execute() (ok bool, data interface{}, err error) {
memory, err := memory.Get()
fmt.Println(memory)
p := float64(100) / float64(memory.Total) * float64(memory.Used)
ps := float64(100) / float64(memory.SwapTotal) * float64(memory.SwapUsed)
res := make(map[string]interface{})
res["row"] = memory
res["ram"] = p
res["swap"] = ps
if memory.SwapTotal == 0 {
res["swap"] = 100
}
fmt.Println(ps)
if p > h.Config.Max {
return false, res, nil
}