http-server-status/internal/pkg/checks/hdd.go
kekskurse a4a6c9c261
All checks were successful
continuous-integration/drone/push Build is passing
dev: hdd just physical stuff
2021-09-20 14:06:11 +02:00

34 lines
No EOL
620 B
Go

package checks
import (
"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) {
success := true
parts, _ := disk.Partitions(false)
usage := make(map[string]float64)
for _, p := range parts {
device := p.Mountpoint
s, _ := disk.Usage(device)
usage[device] = s.UsedPercent
if s.UsedPercent > float64(h.Config.MaxPercent) {
success = false
//return false, parts,nil
}
}
return success, usage,nil
}
func (h HDD) Name() string {
return "Disc space"
}