http-server-status/internal/pkg/checks/memory.go
kekskurse b5196312d2
All checks were successful
continuous-integration/drone/push Build is passing
change memoer check output
2021-09-20 16:27:05 +02:00

30 lines
No EOL
540 B
Go

package checks
import (
"github.com/mackerelio/go-osstat/memory"
)
type MemoryConfig struct {
Max float64 `yaml:"max"`
}
type Memory struct {
Config MemoryConfig
}
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, res, nil
}
return true, res,nil
}
func (h Memory) Name() string {
return "Memory usage"
}