Check if file exists before running disk usage on it. Not all mounts are normal files.
This commit is contained in:
parent
6cb0f2d392
commit
16231aa52b
|
@ -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,6 +72,7 @@ func (s *systemPS) DiskUsage() ([]*disk.DiskUsageStat, error) {
|
||||||
var usage []*disk.DiskUsageStat
|
var usage []*disk.DiskUsageStat
|
||||||
|
|
||||||
for _, p := range parts {
|
for _, p := range parts {
|
||||||
|
if _, err := os.Stat(p.Mountpoint); err == nil {
|
||||||
du, err := disk.DiskUsage(p.Mountpoint)
|
du, err := disk.DiskUsage(p.Mountpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -78,6 +80,7 @@ func (s *systemPS) DiskUsage() ([]*disk.DiskUsageStat, error) {
|
||||||
du.Fstype = p.Fstype
|
du.Fstype = p.Fstype
|
||||||
usage = append(usage, du)
|
usage = append(usage, du)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return usage, nil
|
return usage, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue