You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/01/30 08:27:26 UTC

[incubator-skywalking] branch master updated: fixed CPU UsagePercent Error (#2222)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 5003d6d  fixed CPU UsagePercent Error (#2222)
5003d6d is described below

commit 5003d6da31b18543215b213847cd632db1f52165
Author: 兵 <di...@hotmail.com>
AuthorDate: Wed Jan 30 16:27:19 2019 +0800

    fixed CPU UsagePercent Error (#2222)
    
    fixed CPU UsagePercent Error
    The cpu usage storage longitude should be one percent, not one in ten thousand. When the storage unit is one ten thousandth, as long as the usage rate does not exceed 100%. Stored values are less than one. When the current query is forced to be converted to a long type, it will always be 0. This is not correct.
---
 .../org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java
index c6e8cbd..8b12dff 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java
@@ -46,6 +46,6 @@ public abstract class CPUMetricAccessor {
         long now = System.nanoTime();
 
         CPU.Builder cpuBuilder = CPU.newBuilder();
-        return cpuBuilder.setUsagePercent(cpuCost * 1.0d / ((now - lastSampleTimeNs) * cpuCoreNum)).build();
+        return cpuBuilder.setUsagePercent(cpuCost * 1.0d / ((now - lastSampleTimeNs) * cpuCoreNum) * 100).build();
     }
 }