From 8ef19b781d4c8ab3ba89d8d885b31ef7d5dd4bbe Mon Sep 17 00:00:00 2001 From: mjarkk Date: Fri, 5 Jul 2019 08:10:21 +0200 Subject: [PATCH 1/2] Added a litmit to the StatsHistory --- pkg/commands/docker.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index 6408bb53..22ebb58a 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -179,7 +179,12 @@ func (c *DockerCommand) createClientStatMonitor(container *Container) { } c.ContainerMutex.Lock() - container.StatHistory = append(container.StatHistory, recordedStats) + toSlice := len(container.StatHistory) - 50 + if toSlice < 0 { + toSlice = 0 + } + container.StatHistory = append(container.StatHistory[toSlice:], recordedStats) + container.EraseOldHistory() c.ContainerMutex.Unlock() } From 58baf82519a5078a5eb778752ca5126d056b37cd Mon Sep 17 00:00:00 2001 From: mjarkk Date: Fri, 5 Jul 2019 16:58:06 +0200 Subject: [PATCH 2/2] Added the sugestion from @jesseduffeild --- pkg/commands/docker.go | 7 +------ pkg/config/app_config.go | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index 22ebb58a..6408bb53 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -179,12 +179,7 @@ func (c *DockerCommand) createClientStatMonitor(container *Container) { } c.ContainerMutex.Lock() - toSlice := len(container.StatHistory) - 50 - if toSlice < 0 { - toSlice = 0 - } - container.StatHistory = append(container.StatHistory[toSlice:], recordedStats) - + container.StatHistory = append(container.StatHistory, recordedStats) container.EraseOldHistory() c.ContainerMutex.Unlock() } diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 3976ad98..77007f60 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -289,6 +289,11 @@ type CustomCommand struct { // the boolean zero value and this will be ignored when parsing the user's // config func GetDefaultConfig() UserConfig { + duration, err := time.ParseDuration("3m") + if err != nil { + panic(err) + } + return UserConfig{ Gui: GuiConfig{ ScrollHeight: 2, @@ -336,6 +341,7 @@ func GetDefaultConfig() UserConfig { Method: "never", }, Stats: StatsConfig{ + MaxDuration: duration, Graphs: []GraphConfig{ { Caption: "CPU (%)",