From 4ec9894ea261aaa8f51d9812b20886781d62da43 Mon Sep 17 00:00:00 2001 From: Rohit Jnagal Date: Mon, 15 Dec 2014 23:26:30 +0000 Subject: [PATCH] Add systemd information to validate output. --- container/docker/factory.go | 5 +++++ validate/validate.go | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/container/docker/factory.go b/container/docker/factory.go index ef1ef604..32cb5037 100644 --- a/container/docker/factory.go +++ b/container/docker/factory.go @@ -50,6 +50,11 @@ func init() { } } +func UseSystemd() bool { + // init would run and initialize useSystemd before we can call this method. + return useSystemd +} + type dockerFactory struct { machineInfoFactory info.MachineInfoFactory diff --git a/validate/validate.go b/validate/validate.go index 0c36f5ed..9c52b04e 100644 --- a/validate/validate.go +++ b/validate/validate.go @@ -23,12 +23,12 @@ import ( "io/ioutil" "log" "net/http" - "os" "strings" "github.com/docker/libcontainer/cgroups" dclient "github.com/fsouza/go-dockerclient" "github.com/google/cadvisor/container/docker" + "github.com/google/cadvisor/utils" ) const ValidatePage = "/validate/" @@ -163,6 +163,11 @@ func validateDockerInfo() (string, string) { execDriver := info.Get("ExecutionDriver") storageDriver := info.Get("Driver") desc := fmt.Sprintf("Docker exec driver is %s. Storage driver is %s.\n", execDriver, storageDriver) + if docker.UseSystemd() { + desc += "\tsystemd is being used to create cgroups.\n" + } else { + desc += "\tCgroups are being created through cgroup filesystem.\n" + } if strings.Contains(execDriver, "native") { return Recommended, desc } else if strings.Contains(execDriver, "lxc") { @@ -184,7 +189,7 @@ func validateCgroupMounts() (string, string) { return Unknown, out } mnt = strings.TrimSuffix(mnt, "/cpu") - if _, err := os.Stat(mnt); err != nil { + if !utils.FileExists(mnt) { out := fmt.Sprintf("Cgroup mount directory %s inaccessible.\n", mnt) out += desc return Unsupported, out