Remove pointers from the SysInfo struct.
Because they can just be values. Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
parent
ef9b1b6b70
commit
482c54a691
2 changed files with 43 additions and 36 deletions
|
@ -6,10 +6,10 @@ type SysInfo struct {
|
||||||
// Whether the kernel supports AppArmor or not
|
// Whether the kernel supports AppArmor or not
|
||||||
AppArmor bool
|
AppArmor bool
|
||||||
|
|
||||||
*cgroupMemInfo
|
cgroupMemInfo
|
||||||
*cgroupCPUInfo
|
cgroupCPUInfo
|
||||||
*cgroupBlkioInfo
|
cgroupBlkioInfo
|
||||||
*cgroupCpusetInfo
|
cgroupCpusetInfo
|
||||||
|
|
||||||
// Whether IPv4 forwarding is supported or not, if this was disabled, networking will not work
|
// Whether IPv4 forwarding is supported or not, if this was disabled, networking will not work
|
||||||
IPv4ForwardingDisabled bool
|
IPv4ForwardingDisabled bool
|
||||||
|
|
|
@ -33,89 +33,96 @@ func New(quiet bool) *SysInfo {
|
||||||
return sysInfo
|
return sysInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkCgroupMem(quiet bool) *cgroupMemInfo {
|
// checkCgroupMem reads the memory information from the memory cgroup mount point.
|
||||||
info := &cgroupMemInfo{}
|
func checkCgroupMem(quiet bool) cgroupMemInfo {
|
||||||
mountPoint, err := cgroups.FindCgroupMountpoint("memory")
|
mountPoint, err := cgroups.FindCgroupMountpoint("memory")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !quiet {
|
if !quiet {
|
||||||
logrus.Warnf("Your kernel does not support cgroup memory limit: %v", err)
|
logrus.Warnf("Your kernel does not support cgroup memory limit: %v", err)
|
||||||
}
|
}
|
||||||
return info
|
return cgroupMemInfo{}
|
||||||
}
|
}
|
||||||
info.MemoryLimit = true
|
|
||||||
|
|
||||||
info.SwapLimit = cgroupEnabled(mountPoint, "memory.memsw.limit_in_bytes")
|
swapLimit := cgroupEnabled(mountPoint, "memory.memsw.limit_in_bytes")
|
||||||
if !quiet && !info.SwapLimit {
|
if !quiet && !swapLimit {
|
||||||
logrus.Warn("Your kernel does not support swap memory limit.")
|
logrus.Warn("Your kernel does not support swap memory limit.")
|
||||||
}
|
}
|
||||||
info.OomKillDisable = cgroupEnabled(mountPoint, "memory.oom_control")
|
oomKillDisable := cgroupEnabled(mountPoint, "memory.oom_control")
|
||||||
if !quiet && !info.OomKillDisable {
|
if !quiet && !oomKillDisable {
|
||||||
logrus.Warnf("Your kernel does not support oom control.")
|
logrus.Warnf("Your kernel does not support oom control.")
|
||||||
}
|
}
|
||||||
info.MemorySwappiness = cgroupEnabled(mountPoint, "memory.swappiness")
|
memorySwappiness := cgroupEnabled(mountPoint, "memory.swappiness")
|
||||||
if !quiet && !info.MemorySwappiness {
|
if !quiet && !memorySwappiness {
|
||||||
logrus.Warnf("Your kernel does not support memory swappiness.")
|
logrus.Warnf("Your kernel does not support memory swappiness.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return info
|
return cgroupMemInfo{
|
||||||
|
MemoryLimit: true,
|
||||||
|
SwapLimit: swapLimit,
|
||||||
|
OomKillDisable: oomKillDisable,
|
||||||
|
MemorySwappiness: memorySwappiness,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkCgroupCPU(quiet bool) *cgroupCPUInfo {
|
// checkCgroupCPU reads the cpu information from the cpu cgroup mount point.
|
||||||
info := &cgroupCPUInfo{}
|
func checkCgroupCPU(quiet bool) cgroupCPUInfo {
|
||||||
mountPoint, err := cgroups.FindCgroupMountpoint("cpu")
|
mountPoint, err := cgroups.FindCgroupMountpoint("cpu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !quiet {
|
if !quiet {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
return info
|
return cgroupCPUInfo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.CPUShares = cgroupEnabled(mountPoint, "cpu.shares")
|
cpuShares := cgroupEnabled(mountPoint, "cpu.shares")
|
||||||
if !quiet && !info.CPUShares {
|
if !quiet && !cpuShares {
|
||||||
logrus.Warn("Your kernel does not support cgroup cpu shares")
|
logrus.Warn("Your kernel does not support cgroup cpu shares")
|
||||||
}
|
}
|
||||||
|
|
||||||
info.CPUCfsPeriod = cgroupEnabled(mountPoint, "cpu.cfs_period_us")
|
cpuCfsPeriod := cgroupEnabled(mountPoint, "cpu.cfs_period_us")
|
||||||
if !quiet && !info.CPUCfsPeriod {
|
if !quiet && !cpuCfsPeriod {
|
||||||
logrus.Warn("Your kernel does not support cgroup cfs period")
|
logrus.Warn("Your kernel does not support cgroup cfs period")
|
||||||
}
|
}
|
||||||
|
|
||||||
info.CPUCfsQuota = cgroupEnabled(mountPoint, "cpu.cfs_quota_us")
|
cpuCfsQuota := cgroupEnabled(mountPoint, "cpu.cfs_quota_us")
|
||||||
if !quiet && !info.CPUCfsQuota {
|
if !quiet && !cpuCfsQuota {
|
||||||
logrus.Warn("Your kernel does not support cgroup cfs quotas")
|
logrus.Warn("Your kernel does not support cgroup cfs quotas")
|
||||||
}
|
}
|
||||||
return info
|
return cgroupCPUInfo{
|
||||||
|
CPUShares: cpuShares,
|
||||||
|
CPUCfsPeriod: cpuCfsPeriod,
|
||||||
|
CPUCfsQuota: cpuCfsQuota,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkCgroupBlkioInfo(quiet bool) *cgroupBlkioInfo {
|
// checkCgroupBlkioInfo reads the blkio information from the blkio cgroup mount point.
|
||||||
info := &cgroupBlkioInfo{}
|
func checkCgroupBlkioInfo(quiet bool) cgroupBlkioInfo {
|
||||||
mountPoint, err := cgroups.FindCgroupMountpoint("blkio")
|
mountPoint, err := cgroups.FindCgroupMountpoint("blkio")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !quiet {
|
if !quiet {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
return info
|
return cgroupBlkioInfo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.BlkioWeight = cgroupEnabled(mountPoint, "blkio.weight")
|
w := cgroupEnabled(mountPoint, "blkio.weight")
|
||||||
if !quiet && !info.BlkioWeight {
|
if !quiet && !w {
|
||||||
logrus.Warn("Your kernel does not support cgroup blkio weight")
|
logrus.Warn("Your kernel does not support cgroup blkio weight")
|
||||||
}
|
}
|
||||||
return info
|
return cgroupBlkioInfo{BlkioWeight: w}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkCgroupCpusetInfo(quiet bool) *cgroupCpusetInfo {
|
// checkCgroupCpusetInfo reads the cpuset information from the cpuset cgroup mount point.
|
||||||
info := &cgroupCpusetInfo{}
|
func checkCgroupCpusetInfo(quiet bool) cgroupCpusetInfo {
|
||||||
_, err := cgroups.FindCgroupMountpoint("cpuset")
|
_, err := cgroups.FindCgroupMountpoint("cpuset")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !quiet {
|
if !quiet {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
return info
|
return cgroupCpusetInfo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Cpuset = true
|
return cgroupCpusetInfo{Cpuset: true}
|
||||||
return info
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cgroupEnabled(mountPoint, name string) bool {
|
func cgroupEnabled(mountPoint, name string) bool {
|
||||||
|
|
Loading…
Reference in a new issue