Ver código fonte

Merge pull request #14950 from ottok/master

Multiple fixes to 'docker stats' output
Alexander Morozov 10 anos atrás
pai
commit
8505183252

+ 2 - 2
api/client/stats.go

@@ -110,7 +110,7 @@ func (s *containerStats) Display(w io.Writer) error {
 	if s.err != nil {
 		return s.err
 	}
-	fmt.Fprintf(w, "%s\t%.2f%%\t%s/%s\t%.2f%%\t%s/%s\n",
+	fmt.Fprintf(w, "%s\t%.2f%%\t%s / %s\t%.2f%%\t%s / %s\n",
 		s.Name,
 		s.CPUPercentage,
 		units.HumanSize(s.Memory), units.HumanSize(s.MemoryLimit),
@@ -142,7 +142,7 @@ func (cli *DockerCli) CmdStats(args ...string) error {
 			fmt.Fprint(cli.out, "\033[2J")
 			fmt.Fprint(cli.out, "\033[H")
 		}
-		io.WriteString(w, "CONTAINER\tCPU %\tMEM USAGE/LIMIT\tMEM %\tNET I/O\n")
+		io.WriteString(w, "CONTAINER\tCPU %\tMEM USAGE / LIMIT\tMEM %\tNET I/O\n")
 	}
 	for _, n := range names {
 		s := &containerStats{Name: n}

+ 1 - 1
api/client/stats_unit_test.go

@@ -22,7 +22,7 @@ func TestDisplay(t *testing.T) {
 		t.Fatalf("c.Display() gave error: %s", err)
 	}
 	got := b.String()
-	want := "app\t30.00%\t104.9 MB/2.147 GB\t4.88%\t104.9 MB/838.9 MB\n"
+	want := "app\t30.00%\t104.9 MB / 2.147 GB\t4.88%\t104.9 MB / 838.9 MB\n"
 	if got != want {
 		t.Fatalf("c.Display() = %q, want %q", got, want)
 	}

+ 4 - 4
docs/articles/runmetrics.md

@@ -21,13 +21,13 @@ and network IO metrics.
 The following is a sample output from the `docker stats` command
 
     $ docker stats redis1 redis2
-    CONTAINER           CPU %               MEM USAGE/LIMIT     MEM %               NET I/O
-    redis1              0.07%               796 KB/64 MB        1.21%               788 B/648 B
-    redis2              0.07%               2.746 MB/64 MB      4.29%               1.266 KB/648 B
+    CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O
+    redis1              0.07%               796 KB / 64 MB        1.21%               788 B / 648 B
+    redis2              0.07%               2.746 MB / 64 MB      4.29%               1.266 KB / 648 B
 
 
 The [docker stats](/reference/commandline/stats/) reference page has
-more details about the `docker stats` command. 
+more details about the `docker stats` command.
 
 ## Control groups
 

+ 4 - 4
docs/reference/commandline/stats.md

@@ -21,9 +21,9 @@ weight=1
 Running `docker stats` on multiple containers
 
     $ docker stats redis1 redis2
-    CONTAINER           CPU %               MEM USAGE/LIMIT     MEM %               NET I/O
-    redis1              0.07%               796 KB/64 MB        1.21%               788 B/648 B
-    redis2              0.07%               2.746 MB/64 MB      4.29%               1.266 KB/648 B
+    CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O
+    redis1              0.07%               796 KB / 64 MB        1.21%               788 B / 648 B
+    redis2              0.07%               2.746 MB / 64 MB      4.29%               1.266 KB / 648 B
 
 
 The `docker stats` command will only return a live stream of data for running
@@ -31,4 +31,4 @@ containers. Stopped containers will not return any data.
 
 > **Note:**
 > If you want more detailed information about a container's resource
-> usage, use the API endpoint.
+> usage, use the API endpoint.

+ 3 - 4
man/docker-stats.1.md

@@ -25,7 +25,6 @@ Display a live stream of one or more containers' resource usage statistics
 Run **docker stats** with multiple containers.
 
     $ docker stats redis1 redis2
-    CONTAINER           CPU %               MEM USAGE/LIMIT     MEM %               NET I/O
-    redis1              0.07%               796 KB/64 MB        1.21%               788 B/648 B
-    redis2              0.07%               2.746 MB/64 MB      4.29%               1.266 KB/648 B
-
+    CONTAINER           CPU %               MEM USAGE / LIMIT     MEM %               NET I/O
+    redis1              0.07%               796 KB / 64 MB        1.21%               788 B / 648 B
+    redis2              0.07%               2.746 MB / 64 MB      4.29%               1.266 KB / 648 B

+ 1 - 1
pkg/units/size.go

@@ -49,7 +49,7 @@ func CustomSize(format string, size float64, base float64, _map []string) string
 }
 
 // HumanSize returns a human-readable approximation of a size
-// using SI standard (eg. "44kB", "17MB").
+// capped at 4 valid numbers (eg. "2.746 MB", "796 KB").
 func HumanSize(size float64) string {
 	return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs)
 }