Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
| ... | ... |
@@ -2672,11 +2672,11 @@ func (s *containerStats) Collect(stream io.ReadCloser) {
|
| 2672 | 2672 |
} |
| 2673 | 2673 |
} |
| 2674 | 2674 |
|
| 2675 |
-func (s *containerStats) Display(w io.Writer) {
|
|
| 2675 |
+func (s *containerStats) Display(w io.Writer) error {
|
|
| 2676 | 2676 |
s.mu.RLock() |
| 2677 | 2677 |
defer s.mu.RUnlock() |
| 2678 | 2678 |
if s.err != nil {
|
| 2679 |
- return |
|
| 2679 |
+ return s.err |
|
| 2680 | 2680 |
} |
| 2681 | 2681 |
fmt.Fprintf(w, "%s\t%.2f%%\t%s/%s\t%.2f%%\t%s/%s\n", |
| 2682 | 2682 |
s.Name, |
| ... | ... |
@@ -2684,6 +2684,7 @@ func (s *containerStats) Display(w io.Writer) {
|
| 2684 | 2684 |
units.BytesSize(s.Memory), units.BytesSize(s.MemoryLimit), |
| 2685 | 2685 |
s.MemoryPercentage, |
| 2686 | 2686 |
units.BytesSize(s.NetworkRx), units.BytesSize(s.NetworkTx)) |
| 2687 |
+ return nil |
|
| 2687 | 2688 |
} |
| 2688 | 2689 |
|
| 2689 | 2690 |
func (cli *DockerCli) CmdStats(args ...string) error {
|
| ... | ... |
@@ -2708,8 +2709,17 @@ func (cli *DockerCli) CmdStats(args ...string) error {
|
| 2708 | 2708 |
fmt.Fprint(cli.out, "\033[2J") |
| 2709 | 2709 |
fmt.Fprint(cli.out, "\033[H") |
| 2710 | 2710 |
fmt.Fprintln(w, "CONTAINER\tCPU %\tMEM USAGE/LIMIT\tMEM %\tNET I/O") |
| 2711 |
- for _, s := range cStats {
|
|
| 2712 |
- s.Display(w) |
|
| 2711 |
+ toRemove := []int{}
|
|
| 2712 |
+ for i, s := range cStats {
|
|
| 2713 |
+ if err := s.Display(w); err != nil {
|
|
| 2714 |
+ toRemove = append(toRemove, i) |
|
| 2715 |
+ } |
|
| 2716 |
+ } |
|
| 2717 |
+ for _, i := range toRemove {
|
|
| 2718 |
+ cStats = append(cStats[:i], cStats[i+1:]...) |
|
| 2719 |
+ } |
|
| 2720 |
+ if len(cStats) == 0 {
|
|
| 2721 |
+ return nil |
|
| 2713 | 2722 |
} |
| 2714 | 2723 |
w.Flush() |
| 2715 | 2724 |
} |
| ... | ... |
@@ -98,7 +98,7 @@ func (s *statsCollector) run() {
|
| 98 | 98 |
|
| 99 | 99 |
const nanoSeconds = 1e9 |
| 100 | 100 |
|
| 101 |
-// getSystemdCpuUSage returns the host system's cpu usage in nanoseconds |
|
| 101 |
+// getSystemCpuUSage returns the host system's cpu usage in nanoseconds |
|
| 102 | 102 |
// for the system to match the cgroup readings are returned in the same format. |
| 103 | 103 |
func (s *statsCollector) getSystemCpuUsage() (uint64, error) {
|
| 104 | 104 |
f, err := os.Open("/proc/stat")
|
| ... | ... |
@@ -5,7 +5,7 @@ |
| 5 | 5 |
docker-stats - Display live container stats based on resource usage. |
| 6 | 6 |
|
| 7 | 7 |
# SYNOPSIS |
| 8 |
-**docker top** |
|
| 8 |
+**docker stats** |
|
| 9 | 9 |
[**--help**] |
| 10 | 10 |
[CONTAINERS] |
| 11 | 11 |
|
| ... | ... |
@@ -26,7 +26,3 @@ Run **docker stats** with multiple containers. |
| 26 | 26 |
redis1 0.07% 796 KiB/64 MiB 1.21% 788 B/648 B |
| 27 | 27 |
redis2 0.07% 2.746 MiB/64 MiB 4.29% 1.266 KiB/648 B |
| 28 | 28 |
|
| 29 |
-# HISTORY |
|
| 30 |
-April 2014, Originally compiled by William Henry (whenry at redhat dot com) |
|
| 31 |
-based on docker.com source material and internal work. |
|
| 32 |
-June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> |