diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index 8f905aa..93bd37f 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -3,23 +3,43 @@ package sysinfo // SysInfo stores information about which features a kernel supports. // TODO Windows: Factor out platform specific capabilities. type SysInfo struct { + // Whether the kernel supports AppArmor or not AppArmor bool + *cgroupMemInfo - *cgroupCpuInfo - IPv4ForwardingDisabled bool - BridgeNfCallIptablesDisabled bool - BridgeNfCallIp6tablesDisabled bool - CgroupDevicesEnabled bool + *cgroupCPUInfo + + // Whether IPv4 forwarding is supported or not, if this was disabled, networking will not work + IPv4ForwardingDisabled bool + + // Whether bridge-nf-call-iptables is supported or not + BridgeNfCallIptablesDisabled bool + + // Whether bridge-nf-call-ip6tables is supported or not + BridgeNfCallIP6tablesDisabled bool + + // Whether the cgroup has the mountpoint of "devices" or not + CgroupDevicesEnabled bool } type cgroupMemInfo struct { - MemoryLimit bool - SwapLimit bool - OomKillDisable bool + // Whether memory limit is supported or not + MemoryLimit bool + + // Whether swap limit is supported or not + SwapLimit bool + + // Whether OOM killer disalbe is supported or not + OomKillDisable bool + + // Whether memory swappiness is supported or not MemorySwappiness bool } -type cgroupCpuInfo struct { - CpuCfsPeriod bool - CpuCfsQuota bool +type cgroupCPUInfo struct { + // Whether CPU CFS(Completely Fair Scheduler) period is supported or not + CPUCfsPeriod bool + + // Whether CPU CFS(Completely Fair Scheduler) quota is supported or not + CPUCfsQuota bool } diff --git a/sysinfo/sysinfo_freebsd.go b/sysinfo/sysinfo_freebsd.go index 25896f9..22ae0d9 100644 --- a/sysinfo/sysinfo_freebsd.go +++ b/sysinfo/sysinfo_freebsd.go @@ -1,6 +1,6 @@ package sysinfo -// TODO FreeBSD +// New returns an empty SysInfo for freebsd for now. func New(quiet bool) *SysInfo { sysInfo := &SysInfo{} return sysInfo diff --git a/sysinfo/sysinfo_linux.go b/sysinfo/sysinfo_linux.go index f864dcd..9498654 100644 --- a/sysinfo/sysinfo_linux.go +++ b/sysinfo/sysinfo_linux.go @@ -14,14 +14,14 @@ import ( func New(quiet bool) *SysInfo { sysInfo := &SysInfo{} sysInfo.cgroupMemInfo = checkCgroupMem(quiet) - sysInfo.cgroupCpuInfo = checkCgroupCpu(quiet) + sysInfo.cgroupCPUInfo = checkCgroupCPU(quiet) _, err := cgroups.FindCgroupMountpoint("devices") sysInfo.CgroupDevicesEnabled = err == nil sysInfo.IPv4ForwardingDisabled = !readProcBool("/proc/sys/net/ipv4/ip_forward") sysInfo.BridgeNfCallIptablesDisabled = !readProcBool("/proc/sys/net/bridge/bridge-nf-call-iptables") - sysInfo.BridgeNfCallIp6tablesDisabled = !readProcBool("/proc/sys/net/bridge/bridge-nf-call-ip6tables") + sysInfo.BridgeNfCallIP6tablesDisabled = !readProcBool("/proc/sys/net/bridge/bridge-nf-call-ip6tables") // Check if AppArmor is supported. if _, err := os.Stat("/sys/kernel/security/apparmor"); !os.IsNotExist(err) { @@ -58,8 +58,8 @@ func checkCgroupMem(quiet bool) *cgroupMemInfo { return info } -func checkCgroupCpu(quiet bool) *cgroupCpuInfo { - info := &cgroupCpuInfo{} +func checkCgroupCPU(quiet bool) *cgroupCPUInfo { + info := &cgroupCPUInfo{} mountPoint, err := cgroups.FindCgroupMountpoint("cpu") if err != nil { if !quiet { @@ -68,13 +68,13 @@ func checkCgroupCpu(quiet bool) *cgroupCpuInfo { return info } - info.CpuCfsPeriod = cgroupEnabled(mountPoint, "cpu.cfs_period_us") - if !quiet && !info.CpuCfsPeriod { + info.CPUCfsPeriod = cgroupEnabled(mountPoint, "cpu.cfs_period_us") + if !quiet && !info.CPUCfsPeriod { logrus.Warn("Your kernel does not support cgroup cfs period") } - info.CpuCfsQuota = cgroupEnabled(mountPoint, "cpu.cfs_quota_us") - if !quiet && !info.CpuCfsQuota { + info.CPUCfsQuota = cgroupEnabled(mountPoint, "cpu.cfs_quota_us") + if !quiet && !info.CPUCfsQuota { logrus.Warn("Your kernel does not support cgroup cfs quotas") } return info diff --git a/sysinfo/sysinfo_windows.go b/sysinfo/sysinfo_windows.go index b4d3151..8889318 100644 --- a/sysinfo/sysinfo_windows.go +++ b/sysinfo/sysinfo_windows.go @@ -1,6 +1,6 @@ package sysinfo -// TODO Windows +// New returns an empty SysInfo for windows for now. func New(quiet bool) *SysInfo { sysInfo := &SysInfo{} return sysInfo