add cpu.cfs_period_us support

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
This commit is contained in:
Ma Shimiao 2015-04-08 16:58:59 +08:00
parent eef8989683
commit cec0cd69cb

View file

@ -15,6 +15,7 @@ import (
type SysInfo struct {
MemoryLimit bool
SwapLimit bool
CpuCfsPeriod bool
CpuCfsQuota bool
IPv4ForwardingDisabled bool
AppArmor bool
@ -50,8 +51,15 @@ func New(quiet bool) *SysInfo {
logrus.Warnf("%v", err)
}
} else {
_, err1 := ioutil.ReadFile(path.Join(cgroupCpuMountpoint, "cpu.cfs_quota_us"))
sysInfo.CpuCfsQuota = err1 == nil
_, err := ioutil.ReadFile(path.Join(cgroupCpuMountpoint, "cpu.cfs_period_us"))
logrus.Warnf("%s", cgroupCpuMountpoint)
sysInfo.CpuCfsPeriod = err == nil
if !sysInfo.CpuCfsPeriod && !quiet {
logrus.Warnf("WARING: Your kernel does not support cgroup cfs period")
}
_, err = ioutil.ReadFile(path.Join(cgroupCpuMountpoint, "cpu.cfs_quota_us"))
logrus.Warnf("%s", cgroupCpuMountpoint)
sysInfo.CpuCfsQuota = err == nil
if !sysInfo.CpuCfsQuota && !quiet {
logrus.Warn("Your kernel does not support cgroup cfs quotas")
}