http-server-status/internal/pkg/checks/memory.go
kekskurse 07fccbcc29
All checks were successful
continuous-integration/drone/push Build is passing
Add Config
2021-09-20 12:38:41 +02:00

27 lines
No EOL
441 B
Go

package checks
import (
"github.com/mackerelio/go-osstat/memory"
)
type MemmoryConfig struct {
Max float64 `yaml:"max"`
}
type Memory struct {
Config MemmoryConfig
}
func (h Memory) Execute() (ok bool, err error) {
memory, err := memory.Get()
p := float64(100) / float64(memory.Total) * float64(memory.Used)
if p > h.Config.Max {
return false, nil
}
return true, nil
}
func (h Memory) Name() string {
return "Memory usage"
}