'cf app' 始终显示 0.0% cpu - 该值是如何测量的?

'cf app' shows always 0.0% cpu - how is that value measured?

我从未在我的应用程序中看到大于 0.0% cpu 的值。还通过 Google 搜索了 cf apps 的输出,但从未发现 0.0% 以外的内容。 这是来自 VM、容器或管理程序的 0.0%?这个值是如何计算的?这个值是由健康管理器收集的吗?我可以相信这个值吗?

Cloud Foundry 在 OpenStack 集群上运行。

       state     since                    cpu    memory         disk          de
#0     running   2015-08-28 10:36:33 AM   0.0%   280.8M of 1G   73.7M of 4G
#1     running   2015-08-28 10:36:10 AM   0.0%   289.9M of 1G   73.7M of 4G
#2     running   2015-09-01 09:00:17 PM   0.0%   277.3M of 1G   73.7M of 4G
#3     running   2015-08-31 11:04:17 PM   0.0%   250.4M of 1G   73.7M of 4G
#4     running   2015-09-02 06:03:21 PM   0.0%   51M of 1G      73.7M of 4G
#5     running   2015-08-28 10:36:12 AM   0.0%   348.4M of 1G   73.7M of 4G
#6     running   2015-08-28 10:36:12 AM   0.0%   301.4M of 1G   73.7M of 4G
#7     running   2015-08-31 10:01:45 PM   0.0%   201.2M of 1G   73.7M of 4G
#8     running   2015-09-02 06:03:26 PM   0.0%   50.8M of 1G    73.7M of 4G
#9     running   2015-09-02 06:03:25 PM   0.0%   51.2M of 1G    73.7M of 4G
#10    running   2015-08-28 10:36:07 AM   0.0%   334.1M of 1G   73.7M of 4G
#11    running   2015-09-02 06:02:54 PM   0.0%   51.3M of 1G    73.7M of 4G
#12    running   2015-09-02 06:02:55 PM   0.0%   53.6M of 1G    73.7M of 4G
#13    running   2015-08-28 10:36:08 AM   0.0%   314M of 1G     73.7M of 4G
#14    running   2015-08-28 10:36:45 AM   0.0%   345.9M of 1G   73.7M of 4G
#15    running   2015-08-28 10:36:10 AM   0.0%   412.6M of 1G   73.7M of 4G
#16    running   2015-08-28 10:36:04 AM   0.0%   286.3M of 1G   73.7M of 4G
#17    running   2015-08-28 10:36:11 AM   0.0%   294.5M of 1G   73.7M of 4G
#18    running   2015-08-28 10:36:06 AM   0.0%   304.4M of 1G   73.7M of 4G
#19    running   2015-09-02 06:02:49 PM   0.0%   51.1M of 1G    73.7M of 4G
#20    running   2015-09-01 09:03:20 PM   0.0%   173.8M of 1G   73.7M of 4G
#21    running   2015-08-28 10:36:07 AM   0.0%   292.3M of 1G   73.7M of 4G
#22    running   2015-08-28 10:36:05 AM   0.0%   289.1M of 1G   73.7M of 4G
#23    running   2015-09-01 09:02:07 PM   0.0%   213.8M of 1G   73.7M of 4G
#24    running   2015-09-02 06:03:21 PM   0.0%   51.1M of 1G    73.7M of 4G
#25    running   2015-08-28 10:36:52 AM   0.0%   337.3M of 1G   73.7M of 4G
#26    running   2015-08-28 10:36:52 AM   0.0%   337.1M of 1G   73.7M of 4G
#27    running   2015-08-31 10:47:15 AM   0.0%   302.7M of 1G   73.7M of 4G
#28    running   2015-08-28 10:36:13 AM   0.0%   316M of 1G     73.7M of 4G
#29    running   2015-08-28 10:36:16 AM   0.0%   325.1M of 1G   73.7M of 4G
#30    running   2015-08-28 10:36:17 AM   0.0%   328.5M of 1G   73.7M of 4G
#31    running   2015-09-02 06:02:55 PM   0.0%   53.4M of 1G    73.7M of 4G
#32    running   2015-08-28 10:36:52 AM   0.0%   258.7M of 1G   73.7M of 4G
#33    running   2015-08-28 10:36:48 AM   0.0%   273.7M of 1G   73.7M of 4G
#34    running   2015-08-31 10:01:37 PM   0.0%   216.8M of 1G   73.7M of 4G
#35    running   2015-08-28 10:36:21 AM   0.0%   428.4M of 1G   73.7M of 4G
#36    running   2015-09-02 08:10:51 AM   0.0%   228.2M of 1G   73.7M of 4G
#37    running   2015-08-28 10:36:14 AM   0.0%   262.6M of 1G   73.7M of 4G
#38    running   2015-08-28 10:36:56 AM   0.0%   284.8M of 1G   73.7M of 4G
#39    running   2015-09-02 10:51:07 AM   0.0%   174.3M of 1G   73.7M of 4G
#40    running   2015-09-01 09:03:20 PM   0.0%   210.1M of 1G   73.7M of 4G
#41    running   2015-08-28 10:36:21 AM   0.0%   295.3M of 1G   73.7M of 4G
#42    running   2015-08-28 10:36:22 AM   0.0%   301.7M of 1G   73.7M of 4G
#43    running   2015-08-28 10:36:59 AM   0.0%   307M of 1G     73.7M of 4G
#44    running   2015-08-28 10:36:29 AM   0.0%   293.8M of 1G   73.7M of 4G
#45    running   2015-09-02 08:10:45 AM   0.0%   178.8M of 1G   73.7M of 4G
#46    running   2015-08-28 10:36:54 AM   0.0%   313.5M of 1G   73.7M of 4G
#47    running   2015-08-31 11:04:17 PM   0.0%   274.8M of 1G   73.7M of 4G
#48    running   2015-09-02 06:02:52 PM   0.0%   50.9M of 1G    73.7M of 4G
#49    running   2015-08-28 10:36:17 AM   0.0%   335.8M of 1G   73.7M of 4G
#50    running   2015-08-28 10:36:19 AM   0.0%   310.7M of 1G   73.7M of 4G
#51    running   2015-08-28 10:36:23 AM   0.0%   310M of 1G     73.7M of 4G
#52    running   2015-09-02 06:02:48 PM   0.0%   51M of 1G      73.7M of 4G
#53    running   2015-08-28 10:37:04 AM   0.0%   269.4M of 1G   73.7M of 4G
#54    running   2015-08-28 10:37:04 AM   0.0%   299.8M of 1G   73.7M of 4G
#55    running   2015-08-28 10:37:05 AM   0.0%   361.6M of 1G   73.7M of 4G
#56    running   2015-08-28 10:36:28 AM   0.0%   321.6M of 1G   73.7M of 4G
#57    running   2015-08-28 10:36:21 AM   0.0%   309.4M of 1G   73.7M of 4G
#58    running   2015-08-28 10:36:28 AM   0.0%   330.3M of 1G   73.7M of 4G
#59    running   2015-08-28 10:36:29 AM   0.0%   338M of 1G     73.7M of 4G
#60    running   2015-08-28 10:36:32 AM   0.0%   362.5M of 1G   73.7M of 4G
#61    running   2015-08-28 10:37:05 AM   0.0%   279.8M of 1G   73.7M of 4G
#62    running   2015-08-28 10:37:01 AM   0.0%   271.7M of 1G   73.7M of 4G
#63    running   2015-08-28 10:36:23 AM   0.0%   324M of 1G     73.7M of 4G
#64    running   2015-08-28 10:36:26 AM   0.0%   341.1M of 1G   73.7M of 4G
#65    running   2015-09-02 06:02:54 PM   0.0%   51.7M of 1G    73.7M of 4G
#66    running   2015-09-02 06:02:52 PM   0.0%   50.9M of 1G    73.7M of 4G
#67    running   2015-09-01 09:03:38 PM   0.0%   247.5M of 1G   73.7M of 4G
#68    running   2015-08-28 10:36:40 AM   0.0%   324.8M of 1G   73.7M of 4G
#69    running   2015-08-31 10:34:18 PM   0.0%   257.6M of 1G   73.7M of 4G
#70    running   2015-08-28 10:36:34 AM   0.0%   281.4M of 1G   73.7M of 4G
#71    running   2015-08-28 10:36:35 AM   0.0%   340M of 1G     73.7M of 4G
#72    running   2015-09-02 06:02:52 PM   0.0%   50.7M of 1G    73.7M of 4G
#73    running   2015-08-28 10:37:12 AM   0.0%   299.8M of 1G   73.7M of 4G
#74    running   2015-09-02 06:04:09 PM   0.0%   52.3M of 1G    73.7M of 4G
#75    running   2015-09-02 06:02:38 PM   0.0%   50.9M of 1G    73.7M of 4G
#76    running   2015-09-02 06:02:26 PM   0.0%   50.9M of 1G    73.7M of 4G
#77    running   2015-09-02 06:53:44 PM   0.0%   50.9M of 1G    73.7M of 4G
#78    running   2015-08-28 10:36:38 AM   0.0%   365.7M of 1G   73.7M of 4G
#79    running   2015-08-28 10:37:15 AM   0.0%   331.1M of 1G   73.7M of 4G
#80    running   2015-08-28 10:36:45 AM   0.0%   323.8M of 1G   73.7M of 4G
#81    running   2015-08-28 10:36:38 AM   0.0%   316.3M of 1G   73.7M of 4G
#82    running   2015-09-02 06:02:55 PM   0.0%   53.5M of 1G    73.7M of 4G
#83    running   2015-08-28 10:36:33 AM   0.0%   305.5M of 1G   73.7M of 4G
#84    running   2015-08-28 10:37:17 AM   0.0%   268.2M of 1G   73.7M of 4G
#85    running   2015-08-28 10:37:18 AM   0.0%   298.7M of 1G   73.7M of 4G
#86    running   2015-08-31 11:04:17 PM   0.0%   226.8M of 1G   73.7M of 4G
#87    running   2015-09-02 06:55:09 PM   0.0%   50.7M of 1G    73.7M of 4G
#88    running   2015-08-28 10:36:42 AM   0.0%   306.8M of 1G   73.7M of 4G
#89    running   2015-08-28 10:36:43 AM   0.0%   315.4M of 1G   73.7M of 4G
#90    running   2015-08-28 10:37:18 AM   0.0%   301.5M of 1G   73.7M of 4G
#91    running   2015-08-28 10:36:44 AM   0.0%   319.6M of 1G   73.7M of 4G
#92    running   2015-08-28 10:36:36 AM   0.0%   316.8M of 1G   73.7M of 4G
#93    running   2015-09-01 10:26:51 PM   0.0%   221.7M of 1G   73.7M of 4G
#94    running   2015-08-28 10:36:39 AM   0.0%   327.1M of 1G   73.7M of 4G
#95    running   2015-09-02 06:02:18 PM   0.0%   50.9M of 1G    73.7M of 4G
#96    running   2015-09-02 06:03:20 PM   0.0%   50.8M of 1G    73.7M of 4G
#97    running   2015-09-02 06:04:09 PM   0.0%   52.1M of 1G    73.7M of 4G
#98    running   2015-08-28 10:37:17 AM   0.0%   205.5M of 1G   73.7M of 4G
#99    running   2015-08-28 10:37:18 AM   0.0%   273.6M of 1G   73.7M of 4G
#100   running   2015-08-28 10:37:19 AM   0.0%   268.5M of 1G   73.7M of 4G
#101   running   2015-09-02 06:03:25 PM   0.0%   51M of 1G      73.7M of 4G
#102   running   2015-09-02 06:02:56 PM   0.0%   50.9M of 1G    73.7M of 4G
#103   running   2015-09-02 06:02:54 PM   0.0%   51.6M of 1G    73.7M of 4G
#104   running   2015-09-02 10:50:44 AM   0.0%   228.9M of 1G   73.7M of 4G
#105   running   2015-09-02 06:04:09 PM   0.0%   52.1M of 1G    73.7M of 4G
#106   running   2015-08-31 10:45:14 AM   0.0%   292.2M of 1G   73.7M of 4G
#107   running   2015-09-01 09:01:30 PM   0.0%   215.8M of 1G   73.7M of 4G
#108   running   2015-08-28 10:37:29 AM   0.0%   328.8M of 1G   73.7M of 4G
#109   running   2015-08-28 10:36:52 AM   0.0%   315.8M of 1G   73.7M of 4G
#110   running   2015-08-28 10:36:52 AM   0.0%   291.6M of 1G   73.7M of 4G
#111   running   2015-08-28 10:36:53 AM   0.0%   309.3M of 1G   73.7M of 4G
#112   running   2015-08-28 10:37:26 AM   0.0%   337.6M of 1G   73.7M of 4G
#113   running   2015-08-28 10:36:53 AM   0.0%   401M of 1G     73.7M of 4G
#114   running   2015-09-02 06:04:09 PM   0.0%   53M of 1G      73.7M of 4G
#115   running   2015-09-01 09:01:07 PM   0.0%   231.7M of 1G   73.7M of 4G
#116   running   2015-08-28 10:36:51 AM   0.0%   360.8M of 1G   73.7M of 4G
#117   running   2015-08-28 10:36:42 AM   0.0%   348.9M of 1G   73.7M of 4G
#118   running   2015-09-01 03:33:07 PM   0.0%   236.6M of 1G   73.7M of 4G
#119   running   2015-08-28 10:36:56 AM   0.0%   373M of 1G     73.7M of 4G
#120   running   2015-08-28 10:36:48 AM   0.0%   341.9M of 1G   73.7M of 4G
#121   running   2015-08-28 10:36:56 AM   0.0%   311.8M of 1G   73.7M of 4G
#122   running   2015-08-31 10:45:57 AM   0.0%   285.6M of 1G   73.7M of 4G
#123   running   2015-08-31 10:01:37 PM   0.0%   259.2M of 1G   73.7M of 4G
#124   running   2015-08-28 10:36:48 AM   0.0%   344.7M of 1G   73.7M of 4G
#125   running   2015-08-28 10:37:26 AM   0.0%   283.9M of 1G   73.7M of 4G
#126   running   2015-09-02 06:02:14 PM   0.0%   50.9M of 1G    73.7M of 4G
#127   running   2015-08-28 10:37:25 AM   0.0%   311.4M of 1G   73.7M of 4G

我认为信息流是:

cf CLI <-> Cloud Controller <-> DEA <-> Warden <-> cgroup CPU Accounting

参见:

此处的统计数据显示容器中的进程在最后一秒花在 CPU(VM 的)上的时间百分比。如果您的应用程序要执行 CPU 更密集的操作,您可能会看到这个数字增加。例如,我推出了一个小型的 hello-world Golang 应用程序,它还在后台运行一个紧密循环,计算一些随机浮点数的正弦值,然后 cf app 显示 15.5% CPU 使用率:

package main

import (
    "fmt"
    "net/http"
    "os"
    "math"
    "math/rand"
)

func main() {
    go func() {
        for {
            println(math.Sin(rand.Float64()))
        }
    }()

    http.HandleFunc("/", hello)
    fmt.Println("listening...")
    err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)
    if err != nil {
        panic(err)
    }
}

func hello(res http.ResponseWriter, req *http.Request) {
    fmt.Fprintln(res, "go, world")
}