...
1 package docker
2
3 import (
4 "encoding/json"
5 "errors"
6
7 "github.com/shirou/gopsutil/cpu"
8 "github.com/shirou/gopsutil/internal/common"
9 )
10
11 var ErrDockerNotAvailable = errors.New("docker not available")
12 var ErrCgroupNotAvailable = errors.New("cgroup not available")
13
14 var invoke common.Invoker = common.Invoke{}
15
16 const nanoseconds = 1e9
17
18 type CgroupCPUStat struct {
19 cpu.TimesStat
20 Usage float64
21 }
22
23 type CgroupMemStat struct {
24 ContainerID string `json:"containerID"`
25 Cache uint64 `json:"cache"`
26 RSS uint64 `json:"rss"`
27 RSSHuge uint64 `json:"rssHuge"`
28 MappedFile uint64 `json:"mappedFile"`
29 Pgpgin uint64 `json:"pgpgin"`
30 Pgpgout uint64 `json:"pgpgout"`
31 Pgfault uint64 `json:"pgfault"`
32 Pgmajfault uint64 `json:"pgmajfault"`
33 InactiveAnon uint64 `json:"inactiveAnon"`
34 ActiveAnon uint64 `json:"activeAnon"`
35 InactiveFile uint64 `json:"inactiveFile"`
36 ActiveFile uint64 `json:"activeFile"`
37 Unevictable uint64 `json:"unevictable"`
38 HierarchicalMemoryLimit uint64 `json:"hierarchicalMemoryLimit"`
39 TotalCache uint64 `json:"totalCache"`
40 TotalRSS uint64 `json:"totalRss"`
41 TotalRSSHuge uint64 `json:"totalRssHuge"`
42 TotalMappedFile uint64 `json:"totalMappedFile"`
43 TotalPgpgIn uint64 `json:"totalPgpgin"`
44 TotalPgpgOut uint64 `json:"totalPgpgout"`
45 TotalPgFault uint64 `json:"totalPgfault"`
46 TotalPgMajFault uint64 `json:"totalPgmajfault"`
47 TotalInactiveAnon uint64 `json:"totalInactiveAnon"`
48 TotalActiveAnon uint64 `json:"totalActiveAnon"`
49 TotalInactiveFile uint64 `json:"totalInactiveFile"`
50 TotalActiveFile uint64 `json:"totalActiveFile"`
51 TotalUnevictable uint64 `json:"totalUnevictable"`
52 MemUsageInBytes uint64 `json:"memUsageInBytes"`
53 MemMaxUsageInBytes uint64 `json:"memMaxUsageInBytes"`
54 MemLimitInBytes uint64 `json:"memoryLimitInBbytes"`
55 MemFailCnt uint64 `json:"memoryFailcnt"`
56 }
57
58 func (m CgroupMemStat) String() string {
59 s, _ := json.Marshal(m)
60 return string(s)
61 }
62
63 type CgroupDockerStat struct {
64 ContainerID string `json:"containerID"`
65 Name string `json:"name"`
66 Image string `json:"image"`
67 Status string `json:"status"`
68 Running bool `json:"running"`
69 }
70
71 func (c CgroupDockerStat) String() string {
72 s, _ := json.Marshal(c)
73 return string(s)
74 }
75
View as plain text