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