-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtypes.go
50 lines (42 loc) · 1.47 KB
/
types.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
package dockerstats
import (
"fmt"
)
// Stats contains the statistics of a currently running Docker container.
type Stats struct {
Container string `json:"container"`
Memory MemoryStats `json:"memory"`
CPU string `json:"cpu"`
IO IOStats `json:"io"`
PIDs int `json:"pids"`
}
// String returns a human-readable string containing the details of a Stats value.
func (s Stats) String() string {
return fmt.Sprintf("Container=%v Memory={%v} CPU=%v IO={%v} PIDs=%v", s.Container, s.Memory, s.CPU, s.IO, s.PIDs)
}
// MemoryStats contains the statistics of a running Docker container related to
// memory usage.
type MemoryStats struct {
Raw string `json:"raw"`
Percent string `json:"percent"`
}
// String returns a human-readable string containing the details of a MemoryStats value.
func (m MemoryStats) String() string {
return fmt.Sprintf("Raw=%v Percent=%v", m.Raw, m.Percent)
}
// IOStats contains the statistics of a running Docker container related to
// IO, including network and block.
type IOStats struct {
Network string `json:"network"`
Block string `json:"block"`
}
// String returns a human-readable string containing the details of a IOStats value.
func (i IOStats) String() string {
return fmt.Sprintf("Network=%v Block=%v", i.Network, i.Block)
}
// StatsResult is the value recieved when using Monitor to listen for
// Docker statistics.
type StatsResult struct {
Stats []Stats `json:"stats"`
Error error `json:"error"`
}