heyile commented on a change in pull request #987: [SCB-1017]add os cpu net 
info in the metrics with linux os
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/987#discussion_r233089028
 
 

 ##########
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##########
 @@ -102,14 +111,67 @@ protected void printLog(List<Meter> meters) {
     DefaultPublishModel model = factory.createDefaultPublishModel();
 
     printThreadPoolMetrics(model, sb);
-
+    printOsLog(factory.getTree(), sb);
     printConsumerLog(model, sb);
     printProducerLog(model, sb);
     printEdgeLog(model, sb);
 
     LOGGER.info(sb.toString());
   }
 
+  protected void printOsLog(MeasurementTree tree, StringBuilder sb) {
+    if (!DynamicPropertyFactory.getInstance()
+        .getBooleanProperty(METRICS_OS_ENABLED, false)
+        .get()) {
+      return;
+    }
+    MeasurementNode OsNode = 
tree.findChild(OsStatisticsMeter.OS_STATISTICS_NAME);
+    if (OsNode != null && !OsNode.getMeasurements().isEmpty()) {
+      MeasurementNode netNode = OsNode.findChild("net");
+      MeasurementNode cpuNode = OsNode.findChild("cpu");
+      if (cpuNode != null && !cpuNode.getMeasurements().isEmpty()) {
+        double rate = cpuNode.findChild("allCpu", 
OsCpuMeter.tagCpuRate.value()).summary();
+        String ratePercentStr = "calc ...";
 
 Review comment:
   just give a tip... NumberFormat have removed 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to