http-server-status/internal/pkg/checks/load.go

36 lines
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"
}