[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-18 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16691256#comment-16691256
 ] 

ASF GitHub Bot commented on SCB-1017:
-

liubao68 closed 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
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java
 
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java
index ae545eb0e..e38080460 100644
--- 
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java
+++ 
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java
@@ -148,7 +148,7 @@ public static void run() {
 for (String metricLine : metricLines) {
   if (!metricLine.startsWith("#")) {
 String[] metricKeyAndValue = metricLine.split(" ");
-if (!metricKeyAndValue[0].startsWith("jvm")) {
+if (!metricKeyAndValue[0].startsWith("jvm") && 
!metricKeyAndValue[0].startsWith("os")) {
   if (Double.parseDouble(metricKeyAndValue[1]) < 0) {
 TestMgr.check("true", "false");
 break;
diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
index 6024b6d29..c03061ab8 100644
--- 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java
@@ -234,4 +234,14 @@ public static boolean canTcpListen(InetAddress address, 
int port) {
   return false;
 }
   }
+
+  public static String humanReadableBytes(long bytes) {
+int unit = 1024;
+if (bytes < unit) {
+  return bytes + " B";
+}
+int exp = (int) (Math.log(bytes) / Math.log(unit));
+char pre = "KMGTPE".charAt(exp - 1);
+return String.format("%.3f %cB", bytes / Math.pow(unit, exp), pre);
+  }
 }
diff --git 
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
 
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
index a9f8fba66..15c6a9ed5 100644
--- 
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
+++ 
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
@@ -108,6 +108,44 @@ public void testCanTcpListenYes() throws IOException {
 Assert.assertTrue(NetUtils.canTcpListen(address, port));
   }
 
+  @Test
+  public void humanReadableBytes() throws IOException {
+Assert.assertEquals("0 B", NetUtils.humanReadableBytes(0L));
+Assert.assertEquals("1 B", NetUtils.humanReadableBytes(1L));
+Assert.assertEquals("1023 B", NetUtils.humanReadableBytes(1023L));
+
+Assert.assertEquals("1.000 KB", NetUtils.humanReadableBytes(1024L));
+Assert.assertEquals("1.001 KB", NetUtils.humanReadableBytes(1025L));
+Assert.assertEquals("1023.999 KB", NetUtils.humanReadableBytes(1024L * 
1024 - 1));
+
+Assert.assertEquals("1.000 MB", NetUtils.humanReadableBytes(1024L * 1024));
+Assert.assertEquals("1.000 MB", NetUtils.humanReadableBytes(1024L * 1024 + 
1));
+Assert.assertEquals("1.001 MB", NetUtils.humanReadableBytes(1024L * 1024 + 
1024));
+Assert.assertEquals("1023.999 MB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 - 1024));
+Assert.assertEquals("1024.000 MB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 - 1));
+
+Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024));
+Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 + 1));
+Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 + 1024));
+Assert.assertEquals("1023.999 GB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 * 1024 - 1024 * 1024));
+Assert.assertEquals("1024.000 GB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 * 1024 - 1024));
+Assert.assertEquals("1.000 TB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 * 1024));
+Assert.assertEquals("1.001 TB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 * 1024 + 1024 * 1024 * 1024));
+Assert.assertEquals("1023.999 TB",
+

[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686170#comment-16686170
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233341233
 
 

 ##
 File path: 
foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/net/TestNetUtils.java
 ##
 @@ -108,6 +108,48 @@ public void testCanTcpListenYes() throws IOException {
 Assert.assertTrue(NetUtils.canTcpListen(address, port));
   }
 
+  @Test
+  public void humanReadableBytes() throws IOException {
+Assert.assertEquals("0 B", NetUtils.humanReadableBytes(0L));
+Assert.assertEquals("1 B", NetUtils.humanReadableBytes(1L));
+Assert.assertEquals("1023 B", NetUtils.humanReadableBytes(1023L));
+
+Assert.assertEquals("1.000 KB", NetUtils.humanReadableBytes(1024L));
+Assert.assertEquals("1.001 KB", NetUtils.humanReadableBytes(1025L));
+Assert.assertEquals("1023.999 KB", NetUtils.humanReadableBytes(1024L * 
1024 - 1));
+
+Assert.assertEquals("1.000 MB", NetUtils.humanReadableBytes(1024L * 1024));
+Assert.assertEquals("1.000 MB", NetUtils.humanReadableBytes(1024L * 1024 + 
1));
+Assert.assertEquals("1.001 MB", NetUtils.humanReadableBytes(1024L * 1024 + 
1024));
+Assert.assertEquals("1023.999 MB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 - 1024));
+Assert.assertEquals("1024.000 MB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 - 1));
+
+Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024));
+Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 + 1));
+Assert.assertEquals("1.000 GB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 + 1024));
+Assert.assertEquals("1023.999 GB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 * 1024 - 1024 * 1024));
+Assert.assertEquals("1024.000 GB", NetUtils.humanReadableBytes(1024L * 
1024 * 1024 * 1024 - 1024));
+Assert.assertEquals("1.000 TB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 * 1024));
+Assert.assertEquals("1.001 TB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 * 1024 + 1024 * 1024 * 1024));
+Assert.assertEquals("1023.999 TB",
+NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 - 1024L 
* 1024 * 1024));
+
+Assert.assertEquals("1.000 PB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 * 1024 * 1024));
+Assert.assertEquals("1.001 PB",
+NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 + 1024L 
* 1024 * 1024 * 1024));
+Assert.assertEquals("1023.999 PB",
+NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024 - 
1024L * 1024 * 1024 * 1024));
+
+Assert.assertEquals("1.000 EB", NetUtils.humanReadableBytes(1024L * 1024 * 
1024 * 1024 * 1024 * 1024));
+Assert.assertEquals("1.001 EB",
+NetUtils.humanReadableBytes(1024L * 1024 * 1024 * 1024 * 1024 * 1024 + 
1024L * 1024 * 1024 * 1024 * 1024));
+Assert.assertEquals("8.000 EB", 
NetUtils.humanReadableBytes(Long.MAX_VALUE));
+  }
+
+  public static void main(String[] args) {
 
 Review comment:
   remove main function


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685381#comment-16685381
 ] 

ASF GitHub Bot commented on SCB-1017:
-

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_r233088462
 
 

 ##
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##
 @@ -47,6 +53,8 @@
 
   public static final String ENABLED = 
"servicecomb.metrics.publisher.defaultLog.enabled";
 
+  public static final String METRICS_OS_ENABLED = 
"servicecomb.metrics.publisher.defaultLog.printOs.enabled";
 
 Review comment:
   ok


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685380#comment-16685380
 ] 

ASF GitHub Bot commented on SCB-1017:
-

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 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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685365#comment-16685365
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233083251
 
 

 ##
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##
 @@ -102,14 +111,67 @@ protected void printLog(List 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 ...";
+NumberFormat nt = NumberFormat.getPercentInstance();
+if (rate > 0.0) {
+  nt.setMaximumFractionDigits(3);
+  ratePercentStr = nt.format(rate);
+}
+sb.append("os:\n")
+.append(String.format("  cpu: %s\n", ratePercentStr));
+  }
+  if (netNode != null && !netNode.getMeasurements().isEmpty()) {
+sb.append("  net:\ninterface send  
 recv\n");
+for (MeasurementNode iNode : netNode.getChildren().values()) {
+  double sendRate = 
iNode.findChild(OsNetMeter.tagBytesTransmit.value()).summary();
+  double receiveRate = 
iNode.findChild(OsNetMeter.tagBytesReceive.value()).summary();
+  if (sendRate == 0.0 && receiveRate == 0.0) {
+//interface with rate 0.0 should be skipped
+continue;
+  }
+  String sendRateStr = "calc ...";
+  String receiveRateStr = "calc ...";
+  if (sendRate != OsNetMeter.DEFAULT_INIT_RATE || receiveRate != 
OsNetMeter.DEFAULT_INIT_RATE) {
+sendRateStr = getRealTimeNetStr(sendRate);
+receiveRateStr = getRealTimeNetStr(receiveRate);
+  }
+  sb.append(String.format("%-29s %-42s %s\n",
+  iNode.getName(), sendRateStr, receiveRateStr));
+}
+  }
+}
+  }
+
+  private String getRealTimeNetStr(Double netBytes) {
 
 Review comment:
 public static String humanReadableBytes(long bytes) {
   int unit = 1024;
   if (bytes < unit) {
 return bytes + " B";
   }
   
   int exp = (int) (Math.log(bytes) / Math.log(unit));
   char pre = "KMGTPE".charAt(exp - 1);
   return String.format("%.3f %cB", bytes / Math.pow(unit, exp), pre);
 }
   
   put it to org.apache.servicecomb.foundation.common.net.NetUtils


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685366#comment-16685366
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233083251
 
 

 ##
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##
 @@ -102,14 +111,67 @@ protected void printLog(List 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 ...";
+NumberFormat nt = NumberFormat.getPercentInstance();
+if (rate > 0.0) {
+  nt.setMaximumFractionDigits(3);
+  ratePercentStr = nt.format(rate);
+}
+sb.append("os:\n")
+.append(String.format("  cpu: %s\n", ratePercentStr));
+  }
+  if (netNode != null && !netNode.getMeasurements().isEmpty()) {
+sb.append("  net:\ninterface send  
 recv\n");
+for (MeasurementNode iNode : netNode.getChildren().values()) {
+  double sendRate = 
iNode.findChild(OsNetMeter.tagBytesTransmit.value()).summary();
+  double receiveRate = 
iNode.findChild(OsNetMeter.tagBytesReceive.value()).summary();
+  if (sendRate == 0.0 && receiveRate == 0.0) {
+//interface with rate 0.0 should be skipped
+continue;
+  }
+  String sendRateStr = "calc ...";
+  String receiveRateStr = "calc ...";
+  if (sendRate != OsNetMeter.DEFAULT_INIT_RATE || receiveRate != 
OsNetMeter.DEFAULT_INIT_RATE) {
+sendRateStr = getRealTimeNetStr(sendRate);
+receiveRateStr = getRealTimeNetStr(receiveRate);
+  }
+  sb.append(String.format("%-29s %-42s %s\n",
+  iNode.getName(), sendRateStr, receiveRateStr));
+}
+  }
+}
+  }
+
+  private String getRealTimeNetStr(Double netBytes) {
 
 Review comment:
   ```
 public static String humanReadableBytes(long bytes) {
   int unit = 1024;
   if (bytes < unit) {
 return bytes + " B";
   }
   
   int exp = (int) (Math.log(bytes) / Math.log(unit));
   char pre = "KMGTPE".charAt(exp - 1);
   return String.format("%.3f %cB", bytes / Math.pow(unit, exp), pre);
 }
   ```
   
   put it to org.apache.servicecomb.foundation.common.net.NetUtils


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685363#comment-16685363
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233082550
 
 

 ##
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##
 @@ -102,14 +111,67 @@ protected void printLog(List 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);
 
 Review comment:
   extract cpu/net to two print method


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685362#comment-16685362
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233082171
 
 

 ##
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##
 @@ -102,14 +111,67 @@ protected void printLog(List 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:
   why "calc ..."?
   why NumberFormat ?


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685360#comment-16685360
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233081553
 
 

 ##
 File path: 
metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 ##
 @@ -47,6 +53,8 @@
 
   public static final String ENABLED = 
"servicecomb.metrics.publisher.defaultLog.enabled";
 
+  public static final String METRICS_OS_ENABLED = 
"servicecomb.metrics.publisher.defaultLog.printOs.enabled";
 
 Review comment:
   why need this flag?


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16685358#comment-16685358
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r233080475
 
 

 ##
 File path: 
demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/SpringmvcClient.java
 ##
 @@ -148,7 +148,7 @@ public static void run() {
 for (String metricLine : metricLines) {
   if (!metricLine.startsWith("#")) {
 String[] metricKeyAndValue = metricLine.split(" ");
-if (!metricKeyAndValue[0].startsWith("jvm")) {
+if (!metricKeyAndValue[0].startsWith("jvm") && 
!metricKeyAndValue[0].startsWith("servicecomb_os")) {
 
 Review comment:
   rename "servicecomb_os" to "os"


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16683123#comment-16683123
 ] 

ASF GitHub Bot commented on SCB-1017:
-

coveralls edited a comment on issue #987: [SCB-1017]add os cpu net info in the 
metrics with linux os
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/987#issuecomment-437564255
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20040576/badge)](https://coveralls.io/builds/20040576)
   
   Coverage decreased (-0.1%) to 86.518% when pulling 
**3f98bdfc4256dc7a0dc542ecf346495c63c6c49c on heyile:metrics_cpu** into 
**dd4554de29df215b23287db00965052a75a51bdd on apache:master**.
   


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16683086#comment-16683086
 ] 

ASF GitHub Bot commented on SCB-1017:
-

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_r232513021
 
 

 ##
 File path: 
foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
 ##
 @@ -41,13 +47,37 @@
 
   private ScheduledExecutorService executorService;
 
+  //cpu
+  private ScheduledExecutorService cpuExcutorService;
+
+  //network
+  private ScheduledExecutorService netExcutorService;
+
+  private CpuNode cpuNode;
+
+  private final Map netNodeMap = new HashMap<>();
+
   public void start(CompositeRegistry globalRegistry, EventBus eventBus) {
 this.globalRegistry = globalRegistry;
 this.eventBus = eventBus;
+cpuNode = CpuNode.getINSTANCE();
 this.executorService = Executors.newScheduledThreadPool(1,
 new ThreadFactoryBuilder()
 .setNameFormat("spectator-poller-%d")
 .build());
+if (!System.getProperty("os.name").toLowerCase().startsWith("win")) {
 
 Review comment:
   ok


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16683087#comment-16683087
 ] 

ASF GitHub Bot commented on SCB-1017:
-

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_r232513052
 
 

 ##
 File path: 
foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/publish/spectator/CpuNode.java
 ##
 @@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.foundation.metrics.publish.spectator;
+
+import java.text.NumberFormat;
+
+public class CpuNode {
+
+  private static CpuNode INSTANCE = new CpuNode();
 
 Review comment:
   as I only need a single CpuNode instance, I was going to use the Singleton 
Pattern of java


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682868#comment-16682868
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r232487203
 
 

 ##
 File path: 
foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/publish/spectator/CpuNode.java
 ##
 @@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.foundation.metrics.publish.spectator;
+
+import java.text.NumberFormat;
+
+public class CpuNode {
+
+  private static CpuNode INSTANCE = new CpuNode();
 
 Review comment:
   why need a global instance?


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682862#comment-16682862
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r232486851
 
 

 ##
 File path: 
foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/util/SystemOsUtil.java
 ##
 @@ -0,0 +1,74 @@
+package org.apache.servicecomb.foundation.metrics.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Map;
+
+import org.apache.servicecomb.foundation.metrics.publish.spectator.CpuNode;
+import org.apache.servicecomb.foundation.metrics.publish.spectator.NetNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SystemOsUtil {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(SystemOsUtil.class);
+
+  private static final String linuxCpuCmd = "cat /proc/stat";
 
 Review comment:
   just read file directly


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682860#comment-16682860
 ] 

ASF GitHub Bot commented on SCB-1017:
-

wujimin 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_r232486639
 
 

 ##
 File path: 
foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
 ##
 @@ -41,13 +47,37 @@
 
   private ScheduledExecutorService executorService;
 
+  //cpu
+  private ScheduledExecutorService cpuExcutorService;
+
+  //network
+  private ScheduledExecutorService netExcutorService;
+
+  private CpuNode cpuNode;
+
+  private final Map netNodeMap = new HashMap<>();
+
   public void start(CompositeRegistry globalRegistry, EventBus eventBus) {
 this.globalRegistry = globalRegistry;
 this.eventBus = eventBus;
+cpuNode = CpuNode.getINSTANCE();
 this.executorService = Executors.newScheduledThreadPool(1,
 new ThreadFactoryBuilder()
 .setNameFormat("spectator-poller-%d")
 .build());
+if (!System.getProperty("os.name").toLowerCase().startsWith("win")) {
 
 Review comment:
   try org.apache.commons.lang3.SystemUtils#IS_OS_LINUX


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682753#comment-16682753
 ] 

ASF GitHub Bot commented on SCB-1017:
-

coveralls edited a comment on issue #987: [SCB-1017]add os cpu net info in the 
metrics with linux os
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/987#issuecomment-437564255
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20030840/badge)](https://coveralls.io/builds/20030840)
   
   Coverage decreased (-0.1%) to 86.511% when pulling 
**439e088a1bdce1199f514561ced586ea99c577b7 on heyile:metrics_cpu** into 
**dd4554de29df215b23287db00965052a75a51bdd on apache:master**.
   


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682750#comment-16682750
 ] 

ASF GitHub Bot commented on SCB-1017:
-

heyile opened a new 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
 
 
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682749#comment-16682749
 ] 

ASF GitHub Bot commented on SCB-1017:
-

heyile closed 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
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
index 7f13bf17c..b218ea741 100644
--- 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
+++ 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
@@ -18,12 +18,17 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.foundation.metrics.publish.spectator.CpuNode;
+import org.apache.servicecomb.foundation.metrics.publish.spectator.NetNode;
+import org.apache.servicecomb.foundation.metrics.util.SystemOsUtil;
 
 import com.google.common.collect.Lists;
 import com.google.common.eventbus.EventBus;
@@ -33,6 +38,7 @@
 import com.netflix.spectator.api.Meter;
 
 public class MetricsBootstrap {
+
   private CompositeRegistry globalRegistry;
 
   private EventBus eventBus;
@@ -41,13 +47,37 @@
 
   private ScheduledExecutorService executorService;
 
+  //cpu
+  private ScheduledExecutorService cpuExcutorService;
+
+  //network
+  private ScheduledExecutorService netExcutorService;
+
+  private CpuNode cpuNode;
+
+  private final Map netNodeMap = new HashMap<>();
+
   public void start(CompositeRegistry globalRegistry, EventBus eventBus) {
 this.globalRegistry = globalRegistry;
 this.eventBus = eventBus;
+cpuNode = CpuNode.getINSTANCE();
 this.executorService = Executors.newScheduledThreadPool(1,
 new ThreadFactoryBuilder()
 .setNameFormat("spectator-poller-%d")
 .build());
+if (!System.getProperty("os.name").toLowerCase().startsWith("win")) {
+  // linux OS
+  this.cpuExcutorService = Executors.newScheduledThreadPool(1,
+  new ThreadFactoryBuilder()
+  .setNameFormat("cpu-poller-%d")
+  .build()
+  );
+  this.netExcutorService = Executors.newScheduledThreadPool(1,
+  new ThreadFactoryBuilder()
+  .setNameFormat("net-poller-%d")
+  .build()
+  );
+}
 
 loadMetricsInitializers();
 startPoll();
@@ -76,6 +106,17 @@ protected void startPoll() {
 0,
 config.getMsPollInterval(),
 TimeUnit.MILLISECONDS);
+if (!System.getProperty("os.name").toLowerCase().startsWith("win")) {
+  //Linux OS
+  cpuExcutorService.scheduleAtFixedRate(this::pollCpu,
+  0,
+  config.getMsCPUInterval(),
+  TimeUnit.MILLISECONDS);
+  netExcutorService.scheduleAtFixedRate(this::pollNet,
+  0,
+  config.getMsNetInterval(),
+  TimeUnit.MILLISECONDS);
+}
   }
 
   protected void pollMeters() {
@@ -86,8 +127,17 @@ protected void pollMeters() {
 for (Meter meter : meters) {
   meter.measure().forEach(measurements::add);
 }
-PolledEvent event = new PolledEvent(meters, measurements);
+
+PolledEvent event = new PolledEvent(meters, measurements, cpuNode, 
netNodeMap, config.isPrintOsInfo());
 
 eventBus.post(event);
   }
+
+  protected void pollCpu() {
+SystemOsUtil.refreshCpu(this.cpuNode);
+  }
+
+  protected void pollNet() {
+SystemOsUtil.refreshNet(this.netNodeMap, config.getMsNetInterval());
+  }
 }
diff --git 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
index d1b6be72f..17ddd090b 100644
--- 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
+++ 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
@@ -21,16 +21,54 @@
 public class MetricsBootstrapConfig {
   public static final String METRICS_WINDOW_TIME = 
"servicecomb.metrics.window_time";
 
+  

[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-09 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682253#comment-16682253
 ] 

ASF GitHub Bot commented on SCB-1017:
-

coveralls commented on issue #987: [SCB-1017]add os cpu net info in the metrics 
with linux os
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/987#issuecomment-437564255
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20021765/badge)](https://coveralls.io/builds/20021765)
   
   Coverage decreased (-0.1%) to 86.511% when pulling 
**439e088a1bdce1199f514561ced586ea99c577b7 on heyile:metrics_cpu** into 
**dd4554de29df215b23287db00965052a75a51bdd on apache:master**.
   


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1017) [SCB-1017] add os cpu net info in the metrics with linux os

2018-11-09 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1017?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682229#comment-16682229
 ] 

ASF GitHub Bot commented on SCB-1017:
-

heyile opened a new 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
 
 
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


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


> [SCB-1017] add os cpu net info  in the metrics with linux os
> 
>
> Key: SCB-1017
> URL: https://issues.apache.org/jira/browse/SCB-1017
> Project: Apache ServiceComb
>  Issue Type: Improvement
>Reporter: 何一乐
>Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)