package checks import ( "github.com/mackerelio/go-osstat/loadavg" ) type LoadConfig struct { MaxLoad1 float64 `yaml:"max_load_1"` MaxLoad5 float64 `yaml:"max_load_5"` MaxLoad15 float64 `yaml:"max_load_15"` Enabled bool `yaml:"enabled"` } type Load struct { Config LoadConfig } func (h Load) Execute() (ok bool, data interface{}, err error) { if h.Config.Enabled == false { return true, nil, nil } load, err := loadavg.Get() if load.Loadavg1 > h.Config.MaxLoad1 { return false,load, nil } if load.Loadavg5 > h.Config.MaxLoad5 { return false, load, nil } if load.Loadavg15 > h.Config.MaxLoad15 { return false, load,nil } return true,load, nil } func (h Load) Name() string { return "SystemLoad" }