33 lines
No EOL
615 B
Go
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"
|
|
} |