-
Notifications
You must be signed in to change notification settings - Fork 0
/
SomeStruct.go
95 lines (89 loc) · 3.11 KB
/
SomeStruct.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//main 这里只存放解析json 的结构体
//这些结构体是根据dockerAPI返回的JSON手工打造的, 目前我公司感兴趣的指标进行了细化,其它都以interface{}代替, 以后如有更多需求,只需细化这些机构体即可
//20170412 yihongfei
package main
//DockerInspectStruct 这个结构体对应Inspect json串结构
type DockerInspectStruct struct {
ID string `json:"Id"`
Created string
Path string
Args []string
State map[string]interface{}
HostConfig map[string]interface{}
Image string
ResolvConfPath string
HostnamePath string
HostsPath string
LogPath string
Name string
RestartCount int
Driver string
MountLabel string
ProcessLabel string
ExecIDs interface{}
GraphDriver map[string]interface{}
Mounts []interface{}
Config DockerInspectStructConfig
NetworkSettings DockerInspectStructNetworkSettings
}
//DockerInspectStructNetworkSettings 本结构体对应 docker inspect 197db54aab6c0510686b3 其中的NetworkSettings 部分
type DockerInspectStructNetworkSettings struct {
Bridge string
SandboxID string
HairpinMode bool
LinkLocalIPv6Address string
LinkLocalIPv6PrefixLen int
Ports interface{}
SandboxKey string
SecondaryIPAddresses interface{}
SecondaryIPv6Addresses interface{}
EndpointID string
Gateway string
GlobalIPv6Address string
GlobalIPv6PrefixLen int
IPAddress string
IPPrefixLen int
IPv6Gateway string
MacAddress string
Networks interface{}
}
//DockerInspectStructConfig 就是 DockerInspectStruct 结构体中config的详细结构
type DockerInspectStructConfig struct {
Hostname string
Domainname string
User string
AttachStdin bool
AttachStdout bool
AttachStderr bool
ExposedPorts interface{}
Tty bool
OpenStdin bool
StdinOnce bool
Env []interface{}
Cmd []interface{}
Image string
Volumes interface{}
WorkingDir string
Entrypoint []interface{}
OnBuild bool
Labels map[string]string
}
//AllDockerBriefStruct 存放类似docker ps 出来的json信息, (echo -e "GET /containers/json HTTP/1.1\r\nHost: www.test.com\r\n")|nc -U //var/run/docker.sock
type AllDockerBriefStruct struct {
ID string `json:"Id"`
Names []string
Image string
ImageID string
Command string
Created int64
Ports []interface{}
Labels interface{}
State string
Status string
HostConfig map[string]string
NetworkSettings map[string]interface{}
Mounts []interface{}
}
//
// cadvisor 可以获取宿主的信息的秘诀! curl http://localhost:18080/api/v1.2/machine 这个结构体可以深挖一下,是否可以获取虚拟机的信息呢?
// cadvisor api 2.0 更能更强大 https://github.com/google/cadvisor/blob/master/docs/api_v2.md 完全可以用上。