http-server-status/internal/pkg/checks/load.go
kekskurse 1558252809
All checks were successful
continuous-integration/drone/push Build is passing
Remove all Javascript
2021-11-25 02:01:27 +01:00

36 lines
No EOL
637 B
Go

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"`
}
type Load struct {
Config LoadConfig
}
func (h Load) Execute() (ok bool, data interface{}, err error) {
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"
}