http-server-status/internal/pkg/checks/hdd.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

34 lines
No EOL
619 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 "DiscSpace"
}