http-server-status/internal/pkg/checks/hdd.go
kekskurse df1f08922b
All checks were successful
continuous-integration/drone/push Build is passing
Return Data from Check possible and redirect to data.json
2021-09-20 13:19:05 +02:00

33 lines
No EOL
615 B
Go

package checks
import (
"github.com/rs/zerolog/log"
"github.com/shirou/gopsutil/disk"
)
type HDDConfig struct {
MaxPercent int `yaml:"max_percent"`
}
type HDD struct {
Config HDDConfig
}
func (h HDD) Execute() (ok bool, data interface{}, err error) {
parts, _ := disk.Partitions(true)
log.Debug().Int("max_percent", h.Config.MaxPercent).Msg("Execute HDD Check")
for _, p := range parts {
device := p.Mountpoint
s, _ := disk.Usage(device)
if s.UsedPercent > float64(h.Config.MaxPercent) {
return false, nil,nil
}
}
return true, nil,nil
}
func (h HDD) Name() string {
return "Disc space"
}