Check if file exists before running disk usage on it. Not all mounts are normal files.

Closes #208
This commit is contained in:
Tim Allen 2015-09-17 15:02:15 -05:00 committed by Cameron Sparr
parent 6cb0f2d392
commit 94a623c00e
1 changed files with 8 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package system
import ( import (
gonet "net" gonet "net"
"os"
"strings" "strings"
dc "github.com/fsouza/go-dockerclient" dc "github.com/fsouza/go-dockerclient"
@ -71,12 +72,14 @@ func (s *systemPS) DiskUsage() ([]*disk.DiskUsageStat, error) {
var usage []*disk.DiskUsageStat var usage []*disk.DiskUsageStat
for _, p := range parts { for _, p := range parts {
du, err := disk.DiskUsage(p.Mountpoint) if _, err := os.Stat(p.Mountpoint); err == nil {
if err != nil { du, err := disk.DiskUsage(p.Mountpoint)
return nil, err if err != nil {
return nil, err
}
du.Fstype = p.Fstype
usage = append(usage, du)
} }
du.Fstype = p.Fstype
usage = append(usage, du)
} }
return usage, nil return usage, nil