From f28ded09c3b82d9ec9de5ef9aa9d3b7b664ca571 Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Mon, 20 Apr 2015 08:16:47 -0700 Subject: [PATCH] Add support cpu cfs quota Signed-off-by: Lei Jitang --- sysinfo/sysinfo.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index 16839bc..d1dcea3 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -13,6 +13,7 @@ import ( type SysInfo struct { MemoryLimit bool SwapLimit bool + CpuCfsQuota bool IPv4ForwardingDisabled bool AppArmor bool } @@ -39,6 +40,19 @@ func New(quiet bool) *SysInfo { } } + if cgroupCpuMountpoint, err := cgroups.FindCgroupMountpoint("cpu"); err != nil { + if !quiet { + logrus.Warnf("WARING: %s\n", err) + } + } else { + _, err1 := ioutil.ReadFile(path.Join(cgroupCpuMountpoint, "cpu.cfs_quota_us")) + logrus.Warnf("%s", cgroupCpuMountpoint) + sysInfo.CpuCfsQuota = err1 == nil + if !sysInfo.CpuCfsQuota && !quiet { + logrus.Warnf("WARING: Your kernel does not support cgroup cfs quotas") + } + } + // Check if AppArmor is supported. if _, err := os.Stat("/sys/kernel/security/apparmor"); os.IsNotExist(err) { sysInfo.AppArmor = false