forked from shirou/gopsutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.go
74 lines (64 loc) · 2.49 KB
/
docker.go
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
package docker
import (
"encoding/json"
"errors"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/internal/common"
)
var ErrDockerNotAvailable = errors.New("docker not available")
var ErrCgroupNotAvailable = errors.New("cgroup not available")
var invoke common.Invoker = common.Invoke{}
const nanoseconds = 1e9
type CgroupCPUStat struct {
cpu.TimesStat
Usage float64
}
type CgroupMemStat struct {
ContainerID string `json:"containerID"`
Cache uint64 `json:"cache"`
RSS uint64 `json:"rss"`
RSSHuge uint64 `json:"rssHuge"`
MappedFile uint64 `json:"mappedFile"`
Pgpgin uint64 `json:"pgpgin"`
Pgpgout uint64 `json:"pgpgout"`
Pgfault uint64 `json:"pgfault"`
Pgmajfault uint64 `json:"pgmajfault"`
InactiveAnon uint64 `json:"inactiveAnon"`
ActiveAnon uint64 `json:"activeAnon"`
InactiveFile uint64 `json:"inactiveFile"`
ActiveFile uint64 `json:"activeFile"`
Unevictable uint64 `json:"unevictable"`
HierarchicalMemoryLimit uint64 `json:"hierarchicalMemoryLimit"`
TotalCache uint64 `json:"totalCache"`
TotalRSS uint64 `json:"totalRss"`
TotalRSSHuge uint64 `json:"totalRssHuge"`
TotalMappedFile uint64 `json:"totalMappedFile"`
TotalPgpgIn uint64 `json:"totalPgpgin"`
TotalPgpgOut uint64 `json:"totalPgpgout"`
TotalPgFault uint64 `json:"totalPgfault"`
TotalPgMajFault uint64 `json:"totalPgmajfault"`
TotalInactiveAnon uint64 `json:"totalInactiveAnon"`
TotalActiveAnon uint64 `json:"totalActiveAnon"`
TotalInactiveFile uint64 `json:"totalInactiveFile"`
TotalActiveFile uint64 `json:"totalActiveFile"`
TotalUnevictable uint64 `json:"totalUnevictable"`
MemUsageInBytes uint64 `json:"memUsageInBytes"`
MemMaxUsageInBytes uint64 `json:"memMaxUsageInBytes"`
MemLimitInBytes uint64 `json:"memoryLimitInBbytes"`
MemFailCnt uint64 `json:"memoryFailcnt"`
}
func (m CgroupMemStat) String() string {
s, _ := json.Marshal(m)
return string(s)
}
type CgroupDockerStat struct {
ContainerID string `json:"containerID"`
Name string `json:"name"`
Image string `json:"image"`
Status string `json:"status"`
Running bool `json:"running"`
}
func (c CgroupDockerStat) String() string {
s, _ := json.Marshal(c)
return string(s)
}