Skip to content

Commit

Permalink
handle diskSize == 0, happens when it does not exist or given fs does…
Browse files Browse the repository at this point in the history
…nt return it
  • Loading branch information
XANi committed Jun 12, 2017
1 parent d4f42d9 commit ef84bd6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugin/df/diskfree.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (state *state) UpdatePeriodic() uber.Update {
update.FullText = fmt.Sprintf(`<span color="#cccccc">%s</span>`, state.cfg.prefix)
for _, part := range state.cfg.mounts {
diskFree, diskTotal := getDiskStats(part)
if diskTotal == 0 {
update.FullText = update.FullText + fmt.Sprintf(`<span color="#ffcccc">%s:NaN</span>`,part)
continue
}
diskFreePercent := (diskFree * 100) / diskTotal
diskColor := `#aaffaa`
if diskFree < state.cfg.dfCriticalMB*1024*1024 || diskFreePercent < state.cfg.dfCriticalPercent {
Expand Down

0 comments on commit ef84bd6

Please sign in to comment.