From 94a623c00e64988f644d15df413bf3d0445c1e21 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 17 Sep 2015 15:02:15 -0500 Subject: [PATCH] Check if file exists before running disk usage on it. Not all mounts are normal files. Closes #208 --- plugins/system/ps.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/system/ps.go b/plugins/system/ps.go index 1f06bafde..8a12c9459 100644 --- a/plugins/system/ps.go +++ b/plugins/system/ps.go @@ -2,6 +2,7 @@ package system import ( gonet "net" + "os" "strings" dc "github.com/fsouza/go-dockerclient" @@ -71,12 +72,14 @@ func (s *systemPS) DiskUsage() ([]*disk.DiskUsageStat, error) { var usage []*disk.DiskUsageStat for _, p := range parts { - du, err := disk.DiskUsage(p.Mountpoint) - if err != nil { - return nil, err + if _, err := os.Stat(p.Mountpoint); err == nil { + du, err := disk.DiskUsage(p.Mountpoint) + 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