forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats_collector_interface.go
60 lines (46 loc) · 1.11 KB
/
stats_collector_interface.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
package stats
import "time"
type CPULoad struct {
One float64
Five float64
Fifteen float64
}
type CPUStats struct {
User uint64
Nice uint64
Sys uint64
Wait uint64
Total uint64
}
type Usage struct {
Used uint64
Total uint64
}
type DiskStats struct {
DiskUsage Usage
InodeUsage Usage
}
type UptimeStats struct {
Secs uint64
}
type Collector interface {
StartCollecting(time.Duration, chan struct{})
GetCPULoad() (load CPULoad, err error)
GetCPUStats() (stats CPUStats, err error)
GetMemStats() (usage Usage, err error)
GetSwapStats() (usage Usage, err error)
GetDiskStats(mountedPath string) (stats DiskStats, err error)
GetUptimeStats() (stats UptimeStats, err error)
}
func (cpuStats CPUStats) UserPercent() Percentage {
return NewPercentage(cpuStats.User+cpuStats.Nice, cpuStats.Total)
}
func (cpuStats CPUStats) SysPercent() Percentage {
return NewPercentage(cpuStats.Sys, cpuStats.Total)
}
func (cpuStats CPUStats) WaitPercent() Percentage {
return NewPercentage(cpuStats.Wait, cpuStats.Total)
}
func (usage Usage) Percent() Percentage {
return NewPercentage(usage.Used, usage.Total)
}