Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero out stats values in the cli #10251

Merged
merged 1 commit into from
Jan 22, 2015
Merged

Conversation

crosbymichael
Copy link
Contributor

Based on some feedback, when you have a container via the cli that you
are monitoring for stats, if you stop the container it will stay in the
display but report the last datapoint that was received.

This PR changes the display to zero out the values for containers where
an update has not been received within a specified duration, i.e. 2
seconds. This signals the user that the container has stopped as it
reports cpu and memory usage of 0.

Signed-off-by: Michael Crosby crosbymichael@gmail.com

@crosbymichael crosbymichael added this to the 1.5.0 milestone Jan 21, 2015
var (
previousCpu uint64
previousSystem uint64
start = true
dec = json.NewDecoder(stream)
updates = make(chan *d, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a struct of a pointer and an error interface, you don't need to make it a chan of pointer, chan of struct should be enough. So make(chan d, 1).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google style guide proposing use pointers always if there are pointers fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is the advice i follow

Based on some feedback, when you have a container via the cli that you
are monitoring for stats, if you stop the container it will stay in the
display but report the last datapoint that was received.

This PR changes the display to zero out the values for containers where
an update has not been received within a specified duration, i.e. 2
seconds.  This signals the user that the container has stopped as it
reports cpu and memory usage of 0.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
@LK4D4
Copy link
Contributor

LK4D4 commented Jan 21, 2015

LGTM
Also I tested locally because it is too boring to write tests for such cli-things :)

@jessfraz
Copy link
Contributor

LGTM

jessfraz pushed a commit that referenced this pull request Jan 22, 2015
Zero out stats values in the cli
@jessfraz jessfraz merged commit 0f5eba6 into moby:master Jan 22, 2015
@crosbymichael crosbymichael deleted the stats-zero branch January 22, 2015 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants