-
Notifications
You must be signed in to change notification settings - Fork 10
/
fake_sigar.go
89 lines (77 loc) · 1.66 KB
/
fake_sigar.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
package golarm
import (
t "time"
"github.com/cloudfoundry/gosigar"
)
type fakeSigar struct {
}
func (f *fakeSigar) CollectCpuStats(collectionInterval t.Duration) (<-chan sigar.Cpu, chan<- struct{}) {
return nil, nil
}
func (f *fakeSigar) GetLoadAverage() (sigar.LoadAverage, error) {
return sigar.LoadAverage{
One: 1,
Five: 1,
Fifteen: 1,
}, nil
}
func (f *fakeSigar) GetMem() (sigar.Mem, error) {
return sigar.Mem{
Total: 100000000,
Used: 20000000,
Free: 80000000,
ActualFree: 80000000,
ActualUsed: 20000000,
}, nil
}
func (f *fakeSigar) GetSwap() (sigar.Swap, error) {
return sigar.Swap{
Total: 100000000,
Used: 20000000,
Free: 80000000,
}, nil
}
func (f *fakeSigar) GetFileSystemUsage(string) (sigar.FileSystemUsage, error) {
return sigar.FileSystemUsage{
Total: 500,
Used: 250,
Free: 250,
Avail: 250,
Files: 1,
FreeFiles: 1,
}, nil
}
func (f *fakeSigar) getProcState(pid int) (sigar.ProcState, error) {
return sigar.ProcState{
Name: "fakeProc",
State: sigar.RunStateRun,
Ppid: 500,
Tty: 69,
Priority: 1,
Nice: 0,
Processor: 1,
}, nil
}
func (f *fakeSigar) getProcMem(pid int) (sigar.ProcMem, error) {
return sigar.ProcMem{
Size: 100000000,
Resident: 100000000,
Share: 0,
MinorFaults: 0,
MajorFaults: 0,
PageFaults: 0,
}, nil
}
func (f *fakeSigar) getProcTime(pid int) (sigar.ProcTime, error) {
return sigar.ProcTime{
StartTime: 123456,
User: 123456,
Sys: 123456,
Total: 123456,
}, nil
}
func (f *fakeSigar) getUpTime() (sigar.Uptime, error) {
return sigar.Uptime{
Length: 120,
}, nil
}