diff --git a/metrics/mock.go b/metrics/mock.go index 40aa87c..adeb3ca 100644 --- a/metrics/mock.go +++ b/metrics/mock.go @@ -1,3 +1,5 @@ +// +build !release + package metrics import ( @@ -45,14 +47,13 @@ func (c *Mock) run() { defer close(c.stream) for { - c.CPUUtil += rand.Intn(10) + c.CPUUtil += rand.Intn(2) if c.CPUUtil > 100 { c.CPUUtil = 0 } - c.CPUUtil += rand.Intn(2) c.NetTx += rand.Int63n(600) c.NetRx += rand.Int63n(600) - c.MemUsage += rand.Int63n(c.MemLimit / 16) + c.MemUsage += rand.Int63n(c.MemLimit / 32) if c.MemUsage > c.MemLimit { c.MemUsage = 0 } diff --git a/mocksource.go b/mocksource.go index 10a38c3..488ad65 100644 --- a/mocksource.go +++ b/mocksource.go @@ -1,3 +1,5 @@ +// +build !release + package main import ( @@ -24,11 +26,11 @@ func NewMockContainerSource() *MockContainerSource { // Create Mock containers func (cs *MockContainerSource) Init() { - total := 40 + total := 20 rand.Seed(int64(time.Now().Nanosecond())) for i := 0; i < total; i++ { - time.Sleep(1 * time.Second) + //time.Sleep(1 * time.Second) collector := metrics.NewMock() c := NewContainer(makeID(), collector) c.SetMeta("name", makeName()) @@ -95,6 +97,10 @@ func makeID() string { func makeName() string { n, err := codename.Get(codename.Sanitized) + nsp := strings.Split(n, "-") + if len(nsp) > 2 { + n = strings.Join(nsp[:2], "-") + } if err != nil { panic(err) }