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

36 lines
No EOL
599 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, err error) {
load, err := loadavg.Get()
if load.Loadavg1 > h.Config.MaxLoad1 {
return false, nil
}
if load.Loadavg5 > h.Config.MaxLoad5 {
return false, nil
}
if load.Loadavg15 > h.Config.MaxLoad15 {
return false, nil
}
return true, nil
}
func (h Load) Name() string {
return "System Load"
}