This commit is contained in:
parent
df1f08922b
commit
7643c96afb
2 changed files with 8 additions and 5 deletions
|
@ -14,18 +14,21 @@ type HDD struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h HDD) Execute() (ok bool, data interface{}, err error) {
|
func (h HDD) Execute() (ok bool, data interface{}, err error) {
|
||||||
|
success := true
|
||||||
parts, _ := disk.Partitions(true)
|
parts, _ := disk.Partitions(true)
|
||||||
log.Debug().Int("max_percent", h.Config.MaxPercent).Msg("Execute HDD Check")
|
log.Debug().Int("max_percent", h.Config.MaxPercent).Msg("Execute HDD Check")
|
||||||
|
usage := make(map[string]float64)
|
||||||
for _, p := range parts {
|
for _, p := range parts {
|
||||||
device := p.Mountpoint
|
device := p.Mountpoint
|
||||||
s, _ := disk.Usage(device)
|
s, _ := disk.Usage(device)
|
||||||
|
usage[device] = s.UsedPercent
|
||||||
if s.UsedPercent > float64(h.Config.MaxPercent) {
|
if s.UsedPercent > float64(h.Config.MaxPercent) {
|
||||||
return false, nil,nil
|
success = false
|
||||||
|
//return false, parts,nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil,nil
|
return success, usage,nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h HDD) Name() string {
|
func (h HDD) Name() string {
|
||||||
|
|
|
@ -16,10 +16,10 @@ func (h Memory) Execute() (ok bool, data interface{}, err error) {
|
||||||
memory, err := memory.Get()
|
memory, err := memory.Get()
|
||||||
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
p := float64(100) / float64(memory.Total) * float64(memory.Used)
|
||||||
if p > h.Config.Max {
|
if p > h.Config.Max {
|
||||||
return false, nil, nil
|
return false, memory, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil,nil
|
return true, memory,nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h Memory) Name() string {
|
func (h Memory) Name() string {
|
||||||
|
|
Loading…
Reference in a new issue