0%

gopsutil_learn

go-gopsutil-learn

更多信息参考官方文档:gopsutil

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import (
"fmt"
"math"
"time"

"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/docker"
"github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/load"
"github.com/shirou/gopsutil/mem"
"github.com/shirou/gopsutil/net"
"github.com/shirou/gopsutil/process"

"github.com/fatih/color"
)

CPU

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
func cpuInformation() bool {
fmt.Println("*******************************************")

numPhysicalCores, err := cpu.Counts(false)
if err != nil {
color.Red("cpu.Counts(false) error")
return false
}
numLogicalCores, err := cpu.Counts(true)
if err != nil {
color.Red("cpu.Counts(true) error")
return false
}

// 打印CPU物理核心数和逻辑核心数
color.Yellow("Physical Cores:%v Logical Cores:%v\n", numPhysicalCores, numLogicalCores)
fmt.Println("-----------------------------------------")
// if percpu is set to false,only returns one value
percpu := true
usedPerCpus, err := cpu.Percent(time.Millisecond*1000, percpu)
if err != nil {
color.Red("cpu.Percent error")
return false
}

// 打印每个逻辑核心相应时间间隔的使用率
for index, usedPerCpu := range usedPerCpus {
color.Yellow("index:%v usedPerCpu:%f \n", index, usedPerCpu)
}
fmt.Println("-----------------------------------------")

// 打印物理CPU InfoStat的信息
cpuInfos, err := cpu.Info()
if err != nil {
color.Red("cpu.Info() error")
return false
}
for _, cpuInfo := range cpuInfos {
color.Yellow("CPU:%v\n", cpuInfo.CPU)
color.Yellow("VendorID:%s\n", cpuInfo.VendorID)
color.Yellow("Family:%s\n", cpuInfo.Family)
color.Yellow("Model:%s\n", cpuInfo.Model)
color.Yellow("Stepping:%v\n", cpuInfo.Stepping)
color.Yellow("PhysicalID:%s\n", cpuInfo.PhysicalID)
color.Yellow("CoreID:%s\n", cpuInfo.CoreID)
color.Yellow("Cores:%v\n", cpuInfo.Cores)
color.Yellow("ModelName:%s\n", cpuInfo.ModelName)
color.Yellow("Mhz:%f\n", cpuInfo.Mhz)
color.Yellow("CacheSize:%v\n", cpuInfo.CacheSize)
// cpuInfo.Flags
color.Yellow("Microcode:%s\n", cpuInfo.Microcode)
fmt.Println("-----------------------------------------")
}

// 打印逻辑核心 TimeStat信息
timeStatInfos, err := cpu.Times(percpu)
for _, timeStatInfo := range timeStatInfos {
color.Yellow("CPU:%s\n", timeStatInfo.CPU)
color.Yellow("User:%.2f\n", timeStatInfo.User)
color.Yellow("System:%.2f\n", timeStatInfo.System)
color.Yellow("Idle:%.2f\n", timeStatInfo.Idle)
color.Yellow("Nice:%.2f\n", timeStatInfo.Nice)
color.Yellow("Iowait:%.2f\n", timeStatInfo.Iowait)
color.Yellow("Irq:%.2f\n", timeStatInfo.Irq)
color.Yellow("Softirq:%.2f\n", timeStatInfo.Softirq)
color.Yellow("Steal:%.2f\n", timeStatInfo.Steal)
color.Yellow("Guest:%.2f\n", timeStatInfo.Guest)
color.Yellow("GuestNice:%.2f\n", timeStatInfo.GuestNice)
fmt.Println("-----------------------------------------")
}
fmt.Println("*******************************************")
return true
}

Memory

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
func memoryInformation() bool {
fmt.Println("*******************************************")

// Omit SwapMemory(SwapMemoryStat)

// Omit VirtualMemoryEx(VirtualMemoryExStat)

virtualMemoryStat, err := mem.VirtualMemory()
if err != nil {
color.Red("mem.VirtualMemory() error\n")
}

byteToGb := math.Pow(1024.0, 3.0)

color.Yellow("Total RAM:%v %.2fG\n", virtualMemoryStat.Total, (float64)(virtualMemoryStat.Total)/byteToGb)
color.Yellow("Available RAM:%v %.2fG\n", virtualMemoryStat.Available, (float64)(virtualMemoryStat.Available)/byteToGb)
color.Yellow("Used RAM:%v %.2fG\n", virtualMemoryStat.Used, (float64)(virtualMemoryStat.Used)/byteToGb)
color.Yellow("Used Percentage of RAM:%f\n", virtualMemoryStat.UsedPercent)
color.Yellow("Free:%v %.2fG\n", virtualMemoryStat.Free, (float64)(virtualMemoryStat.Free)/byteToGb)

// OS X/BSD specific numbers
color.Yellow("Active:%v\n", virtualMemoryStat.Active)
color.Yellow("Inactive:%v\n", virtualMemoryStat.Inactive)
color.Yellow("Wired:%v\n", virtualMemoryStat.Wired)

// FreeBSD specific numbers
color.Yellow("Laundry:%v\n", virtualMemoryStat.Laundry)

// Linux specific numbers
color.Yellow("Buffers:%v\n", virtualMemoryStat.Buffers)
color.Yellow("Cached:%v\n", virtualMemoryStat.Cached)
color.Yellow("Writeback:%v\n", virtualMemoryStat.Writeback)
color.Yellow("Dirty:%v\n", virtualMemoryStat.Dirty)
color.Yellow("WritebackTmp:%v\n", virtualMemoryStat.WritebackTmp)
color.Yellow("Shared:%v\n", virtualMemoryStat.Shared)
color.Yellow("Slab:%v\n", virtualMemoryStat.Slab)
color.Yellow("SReclaimable:%v\n", virtualMemoryStat.SReclaimable)
color.Yellow("SUnreclaim:%v\n", virtualMemoryStat.SUnreclaim)
color.Yellow("PageTables:%v\n", virtualMemoryStat.PageTables)
color.Yellow("SwapCached:%v\n", virtualMemoryStat.SwapCached)
color.Yellow("CommitLimit:%v\n", virtualMemoryStat.CommitLimit)
color.Yellow("CommittedAS:%v\n", virtualMemoryStat.CommittedAS)
color.Yellow("HighTotal:%v\n", virtualMemoryStat.HighTotal)
color.Yellow("HighFree:%v\n", virtualMemoryStat.HighFree)
color.Yellow("LowTotal:%v\n", virtualMemoryStat.LowTotal)
color.Yellow("LowFree:%v\n", virtualMemoryStat.LowFree)
color.Yellow("SwapTotal:%v\n", virtualMemoryStat.SwapTotal)
color.Yellow("SwapFree:%v\n", virtualMemoryStat.SwapFree)
color.Yellow("Mapped:%v\n", virtualMemoryStat.Mapped)
color.Yellow("VMallocTotal:%v\n", virtualMemoryStat.VMallocTotal)
color.Yellow("VMallocUsed:%v\n", virtualMemoryStat.VMallocUsed)
color.Yellow("VMallocChunk:%v\n", virtualMemoryStat.VMallocChunk)
color.Yellow("HugePagesTotal:%v\n", virtualMemoryStat.HugePagesTotal)
color.Yellow("HugePagesFree:%v\n", virtualMemoryStat.HugePagesFree)
color.Yellow("HugePageSize:%v\n", virtualMemoryStat.HugePageSize)

fmt.Println("*******************************************")
return true
}

host

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
func hostInformation() bool {
fmt.Println("*******************************************")

bootTime, err := host.BootTime()
if err != nil {
color.Red("host.BootTime() error")
}
color.Yellow("The boot time expressed in seconds since the epoch:%v\n", bootTime)
fmt.Println("-----------------------------------------")

hostID, err := host.HostID()
if err != nil {
color.Red("host.HostID() error")
}
color.Yellow("host ID:%s\n", hostID)
fmt.Println("-----------------------------------------")

kernelArch, err := host.KernelArch()
if err != nil {
color.Red("host.KernelArch() error")
}
color.Yellow("KernelArch:%s\n", kernelArch)
fmt.Println("-----------------------------------------")

kernelVersion, err := host.KernelVersion()
if err != nil {
color.Red("host.KernelVersion() error")
}
color.Yellow("KernelVersion:%s\n", kernelVersion)
fmt.Println("-----------------------------------------")

platformInformation1, platformInformation2, platformInformation3, err := host.PlatformInformation()
if err != nil {
color.Red("host.PlatformInformation() error")
}
color.Yellow("PlatformInformation:\n%s\n%s\n%s\n", platformInformation1, platformInformation2, platformInformation3)
fmt.Println("-----------------------------------------")

upTime, err := host.Uptime()
if err != nil {
color.Red("host.Uptime() error")
}
color.Yellow("Uptime:%v\n", upTime)
fmt.Println("-----------------------------------------")

virtualization1, virtualization2, err := host.Virtualization()
if err != nil {
color.Red("host.Virtualization() error:%v\n", err)
}
color.Yellow("Virtualization:\n%s\n%s\n", virtualization1, virtualization2)
fmt.Println("-----------------------------------------")

infoStat, err := host.Info()
if err != nil {
color.Red("host.Info() error")
}
color.Yellow("Hostname:%s\n", infoStat.Hostname)
color.Yellow("Uptime:%v\n", infoStat.Uptime)
color.Yellow("BootTime:%v\n", infoStat.BootTime)
color.Yellow("Procs:%v\n", infoStat.Procs)
color.Yellow("OS:%s\n", infoStat.OS)
color.Yellow("Platform:%s\n", infoStat.Platform)
color.Yellow("PlatformFamily:%s\n", infoStat.PlatformFamily)
color.Yellow("PlatformVersion:%s\n", infoStat.PlatformVersion)
color.Yellow("KernelVersion:%s\n", infoStat.KernelVersion)
color.Yellow("KernelArch:%s\n", infoStat.KernelArch)
color.Yellow("VirtualizationSystem:%s\n", infoStat.VirtualizationSystem)
color.Yellow("VirtualizationRole:%s\n", infoStat.VirtualizationRole)
color.Yellow("HostID:%s\n", infoStat.HostID)
fmt.Println("-----------------------------------------")

// 打印TemperatureStat
temperatureStats, err := host.SensorsTemperatures()
if err != nil {
color.Red("host.SensorsTemperatures() error:%v", err)
}
for _, temperatureStat := range temperatureStats {
color.Yellow("SensorKey:%s\n", temperatureStat.SensorKey)
color.Yellow("Temperature:%f\n", temperatureStat.Temperature)
fmt.Println("-----------------------------------------")
}
// 打印UserStat

userStats, err := host.Users()
if err != nil {
color.Red("host.Users() error:%v", err)
}
for _, userStat := range userStats {
color.Yellow("User:%s\n", userStat.User)
color.Yellow("Terminal:%s\n", userStat.Terminal)
color.Yellow("Host:%s\n", userStat.Host)
color.Yellow("Start:%v\n", userStat.Started)
fmt.Println("-----------------------------------------")
}

fmt.Println("*******************************************")
return true
}

disk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
func diskInformation() bool {
fmt.Println("*******************************************")
ioCountersStats, err := disk.IOCounters()
if err != nil {
color.Red("disk.IOCounters() error")
}
for ioCountersStatString, ioCountersStat := range ioCountersStats {
color.Yellow("%s\n", ioCountersStatString)
color.Yellow("ReadCount:%v\n", ioCountersStat.ReadCount)
color.Yellow("MergedReadCount:%v\n", ioCountersStat.MergedReadCount)
color.Yellow("WriteCount:%v\n", ioCountersStat.WriteCount)
color.Yellow("MergedWriteCount:%v\n", ioCountersStat.MergedWriteCount)
color.Yellow("ReadBytes:%v\n", ioCountersStat.ReadBytes)
color.Yellow("WriteBytes:%v\n", ioCountersStat.WriteBytes)
color.Yellow("ReadTime:%v\n", ioCountersStat.ReadTime)
color.Yellow("WriteTime:%v\n", ioCountersStat.WriteTime)
color.Yellow("IopsInProgress:%v\n", ioCountersStat.IopsInProgress)
color.Yellow("IoTime:%v\n", ioCountersStat.IoTime)
color.Yellow("WeightedIO:%v\n", ioCountersStat.WeightedIO)
color.Yellow("Name:%s\n", ioCountersStat.Name)
color.Yellow("SerialNumber:%s\n", ioCountersStat.SerialNumber)
color.Yellow("Label:%s\n", ioCountersStat.Label)
fmt.Println("-----------------------------------------")
}

// 打印Partitions
all := true
partitionStats, err := disk.Partitions(all)
if err != nil {
color.Red("disk.Partitions(all bool) error")
}
for _, partitionStat := range partitionStats {
color.Yellow("Device:%s\n", partitionStat.Device)
color.Yellow("Mountpoint:%s\n", partitionStat.Mountpoint)
color.Yellow("Fstype:%s\n", partitionStat.Fstype)
color.Yellow("Opts:%s\n", partitionStat.Opts)

// 打印Usage
usageStat, err := disk.Usage(partitionStat.Mountpoint)
if err != nil {
color.Red("disk.Usage(Mountpoint) error")
}
color.Yellow("Path:%s\n", usageStat.Path)
color.Yellow("Fstype:%s\n", usageStat.Fstype)
color.Yellow("Total:%v\n", usageStat.Total)
color.Yellow("Free:%v\n", usageStat.Free)
color.Yellow("Used:%v\n", usageStat.Used)
color.Yellow("UsedPercent:%f\n", usageStat.UsedPercent)
color.Yellow("InodesTotal:%v\n", usageStat.InodesTotal)
color.Yellow("InodesUsed:%v\n", usageStat.InodesUsed)
color.Yellow("InodesFree:%v\n", usageStat.InodesFree)
color.Yellow("InodesUsedPercent:%f\n", usageStat.InodesUsedPercent)
fmt.Println("-----------------------------------------")
}

fmt.Println("*******************************************")
return true
}

net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
func netInformation() bool {
fmt.Println("*******************************************")
connectionStats, err := net.Connections("inet")
if err != nil {
color.Red("net.Connections() error:%v\n", err)
}
for _, connectionStat := range connectionStats {
color.Yellow("Fd:%v\n", connectionStat.Fd)
color.Yellow("Family:%v\n", connectionStat.Family)
color.Yellow("Type:%v\n", connectionStat.Type)
color.Yellow("Laddr:%s:%v\n", connectionStat.Laddr.IP, connectionStat.Laddr.Port)
color.Yellow("Raddr:%s:%v\n", connectionStat.Raddr.IP, connectionStat.Raddr.Port)
color.Yellow("Status:%s\n", connectionStat.Status)
color.Yellow("Uids:%v\n", connectionStat.Uids)
color.Yellow("Pid:%v\n", connectionStat.Pid)
fmt.Println("-----------------------------------------")
}

pernic := true
ioCountersStats, err := net.IOCounters(pernic)
if err != nil {
color.Red("net.IOCounters error")
}
for _, ioCountersStat := range ioCountersStats {
color.Yellow("Name:%s\n", ioCountersStat.Name)
color.Yellow("BytesSent:%v\n", ioCountersStat.BytesSent)
color.Yellow("BytesRecv:%v\n", ioCountersStat.BytesRecv)
color.Yellow("PacketsSent:%v\n", ioCountersStat.PacketsSent)
color.Yellow("PacketsRecv:%v\n", ioCountersStat.PacketsRecv)
color.Yellow("Errin:%v\n", ioCountersStat.Errin)
color.Yellow("Errout:%v\n", ioCountersStat.Errout)
color.Yellow("Dropin:%v\n", ioCountersStat.Dropin)
color.Yellow("Dropout:%v\n", ioCountersStat.Dropout)
color.Yellow("Fifoin:%v\n", ioCountersStat.Fifoin)
color.Yellow("Fifoout:%v\n", ioCountersStat.Fifoout)
fmt.Println("-----------------------------------------")
}

interfaceStats, err := net.Interfaces()
if err != nil {
color.Red("net.Interfaces error")
}
for _, interfaceStat := range interfaceStats {
color.Yellow("Index:%v\n", interfaceStat.Index)
color.Yellow("MTU:%v\n", interfaceStat.MTU)
color.Yellow("Name:%s\n", interfaceStat.Name)
color.Yellow("HardwareAddr:%s\n", interfaceStat.HardwareAddr)
color.Yellow("Flags:%v\n", interfaceStat.Flags)
color.Yellow("Addrs:%v\n", interfaceStat.Addrs)
fmt.Println("-----------------------------------------")
}

protoCountersStats, err := net.ProtoCounters([]string{"tcp", "ip"})
if err != nil {
color.Red("net.ProtoCounters error:%v", err)
}
for _, protoCountersStat := range protoCountersStats {
color.Yellow("Protocol:%s\n", protoCountersStat.Protocol)
color.Yellow("Stats:%v\n", protoCountersStat.Stats)
fmt.Println("-----------------------------------------")
}

fmt.Println("*******************************************")
return true
}

process

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
func processInformation() bool {
fmt.Println("*******************************************")
// 打印所有pid
pids, err := process.Pids()
if err != nil {
color.Red("process.Pids() error")
}
color.Yellow("%v\n", pids)
fmt.Println("-----------------------------------------")
// NewProcess 获取指定pid的进程信息

processes, err := process.Processes()
for _, p := range processes {
color.Yellow("Pid:%v\n", p.Pid)
// Children
cmdline, _ := p.Cmdline()
color.Yellow("Cmdline:%s\n", cmdline)
cwd, _ := p.Cwd()
color.Yellow("Working directory:%s\n", cwd)
exe, _ := p.Exe()
color.Yellow("Executable path:%s\n", exe)
// IsRunning/Kill MemoryInfo/MemoryInfoEx
connectionStats, _ := p.Connections()
for _, connectionStat := range connectionStats {
color.Yellow("Fd:%v\n", connectionStat.Fd)
color.Yellow("Family:%v\n", connectionStat.Family)
color.Yellow("Type:%v\n", connectionStat.Type)
color.Yellow("Laddr:%s:%v\n", connectionStat.Laddr.IP, connectionStat.Laddr.Port)
color.Yellow("Raddr:%s:%v\n", connectionStat.Raddr.IP, connectionStat.Raddr.Port)
color.Yellow("Status:%s\n", connectionStat.Status)
color.Yellow("Uids:%v\n", connectionStat.Uids)
color.Yellow("Pid:%v\n", connectionStat.Pid)
fmt.Println("A network connection----------------")
}
// CreateTime
memoryMapsStats, err := p.MemoryMaps(false)
if err != nil {
color.Red("Process.MemoryMaps() error:%v\n", err)
} else {
for _, memoryMapsStat := range *memoryMapsStats {
fmt.Println(memoryMapsStat)
}
}

memoryPercent, err := p.MemoryPercent()
if err != nil {
color.Red("Process.MemoryPercent() error:%v\n", err)
} else {
color.Yellow("used RAW:%.2f\n", memoryPercent)
}

pernic := true
netIoCountersStats, err := p.NetIOCounters(pernic)
if err != nil {
color.Red("Process.NetIOCounters() error:%v\n", err)
} else {
for _, netIoCountersStat := range netIoCountersStats {
if (netIoCountersStat.BytesSent != 0) || (netIoCountersStat.BytesRecv != 0) {
color.Yellow("The process is communicating by:%s BytesSent:%v BytesRecv:%v PacketsSent:%v PacketsRecv:%v\n", netIoCountersStat.Name, netIoCountersStat.BytesSent, netIoCountersStat.BytesRecv, netIoCountersStat.PacketsSent, netIoCountersStat.PacketsRecv)
}
}
}
// NumCtxSwitches/NumFDs/NumThreads/PageFaults/Rlimit/RlimitUsage//SendSignal/Status
numThreads, err := p.NumThreads() // 如何获取线程ID?
if err != nil {
color.Red("Process.NumThreads() error:%v\n", err)
} else {
color.Yellow("NumThreads:%v\n", numThreads)
}

openFilesStats, err := p.OpenFiles()
if err != nil {
color.Red("Process.OpenFiles() error:%v\n", err)
} else {
fmt.Println("* * * * * Opening files by the process * * * * *")
for _, openFilesStat := range openFilesStats {
color.Yellow("Path:%s\n", openFilesStat.Path)
color.Yellow("Fd:%v\n", openFilesStat.Fd)
}
fmt.Println("* * * * * Opening files by the process * * * * *")
}

parent, err := p.Parent()
if err != nil {
color.Red("Process.Parent() error:%v\n", err)
} else {
color.Yellow("Parent ID:%v\n", parent.Pid)
}

fmt.Println("-----------------------------------------")
}

fmt.Println("*******************************************")
return true
}

load

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
func loadInformation() bool {
fmt.Println("*******************************************")
avgStat, err := load.Avg()
if err != nil {
color.Red("load.Avg() error:%v\n", err)
} else {
color.Yellow("load1:%f\n", avgStat.Load1)
color.Yellow("load5:%f\n", avgStat.Load5)
color.Yellow("load15:%f\n", avgStat.Load15)
}
fmt.Println("-----------------------------------------")

miscStat, err := load.Misc()
if err != nil {
color.Red("load.Misc() error:%v\n", err)
} else {
color.Yellow("ProcsTotal:%v\n", miscStat.ProcsTotal)
color.Yellow("ProcsRunning:%v\n", miscStat.ProcsRunning)
color.Yellow("ProcsBlocked:%v\n", miscStat.ProcsBlocked)
color.Yellow("Ctxt:%v\n", miscStat.Ctxt)
}

fmt.Println("-----------------------------------------")
fmt.Println("*******************************************")
return true
}

docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
func dockerInformation() bool {
fmt.Println("*******************************************")
groupDockerStats, err := docker.GetDockerStat()
if err != nil {
color.Red("docker.GetDockerStat() error:%v\n", err)
} else {
for _, groupDockerStat := range groupDockerStats {
color.Yellow("ContainerID:%s\n", groupDockerStat.ContainerID)
color.Yellow("Name:%s\n", groupDockerStat.Name)
color.Yellow("Image:%s\n", groupDockerStat.Image)
color.Yellow("Status:%s\n", groupDockerStat.Status)
color.Yellow("Running:%v\n", groupDockerStat.Running)
fmt.Println("-----------------------------------------")
}
}

dockerIDList, err := docker.GetDockerIDList()
if err != nil {
color.Red("docker.GetDockerIDList() error:%v\n", err)
} else {
for _, dockerID := range dockerIDList {
groupMemStat, err := docker.CgroupMemDocker(dockerID)
if err != nil {
color.Red("docker.CgroupMemDocker(container ID) error:%v\n", err)
} else {
fmt.Println(groupMemStat)
}
fmt.Println("-----------------------------------------")
}
}

fmt.Println("*******************************************")
return true
}