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

angerszhuuuu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git


The following commit(s) were added to refs/heads/main by this push:
     new d657f8268 [CELEBORN-586] Add SystemMiscSource to indicate system 
running status (#1488)
d657f8268 is described below

commit d657f8268ad8b70770aaa6970975ec156faf72bd
Author: Angerszhuuuu <[email protected]>
AuthorDate: Tue May 16 14:03:07 2023 +0800

    [CELEBORN-586] Add SystemMiscSource to indicate system running status 
(#1488)
---
 .../common/metrics/source/SystemMiscSource.scala   | 53 ++++++++++++++++++++++
 docs/monitoring.md                                 | 10 ++++
 .../celeborn/service/deploy/master/Master.scala    |  3 +-
 .../celeborn/service/deploy/worker/Worker.scala    |  3 +-
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git 
a/common/src/main/scala/org/apache/celeborn/common/metrics/source/SystemMiscSource.scala
 
b/common/src/main/scala/org/apache/celeborn/common/metrics/source/SystemMiscSource.scala
new file mode 100644
index 000000000..498617759
--- /dev/null
+++ 
b/common/src/main/scala/org/apache/celeborn/common/metrics/source/SystemMiscSource.scala
@@ -0,0 +1,53 @@
+/*
+ * 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.celeborn.common.metrics.source
+
+import java.lang.management.ManagementFactory
+
+import com.codahale.metrics.Gauge
+
+import org.apache.celeborn.common.CelebornConf
+
+class SystemMiscSource(conf: CelebornConf, role: String) extends 
AbstractSource(conf, role) {
+  override val sourceName = "system"
+
+  import SystemMiscSource._
+
+  addGauge(
+    SYSTEM_LOAD,
+    new Gauge[Double] {
+      override def getValue: Double = {
+        ManagementFactory.getOperatingSystemMXBean.getSystemLoadAverage
+      }
+    })
+
+  addGauge(
+    AVAILABLE_PROCESSORS,
+    new Gauge[Int] {
+      override def getValue: Int = {
+        ManagementFactory.getOperatingSystemMXBean.getAvailableProcessors
+      }
+    })
+  // start cleaner
+  startCleaner()
+}
+
+object SystemMiscSource {
+  val SYSTEM_LOAD = "LastMinuteSystemLoad"
+  val AVAILABLE_PROCESSORS = "AvailableProcessors"
+}
diff --git a/docs/monitoring.md b/docs/monitoring.md
index c9ac04c20..968f4abb4 100644
--- a/docs/monitoring.md
+++ b/docs/monitoring.md
@@ -103,6 +103,11 @@ These metrics are exposed by Celeborn master.
   - namespace=CPU
     - JVMCPUTime
 
+  - namespace=system
+    - LastMinuteSystemLoad
+      - Returns the system load average for the last minute.
+    - AvailableProcessors
+
   - namespace=JVM
     - This source provides information on JVM metrics using the
     [Dropwizard/Codahale Metric Sets for JVM 
instrumentation](https://metrics.dropwizard.io/4.2.0/manual/jvm.html)
@@ -186,6 +191,11 @@ These metrics are exposed by Celeborn worker.
   - namespace=CPU
     - JVMCPUTime
 
+  - namespace=system
+    - LastMinuteSystemLoad
+      - Returns the system load average for the last minute.
+    - AvailableProcessors
+
   - namespace=JVM
     - This source provides information on JVM metrics using the
       [Dropwizard/Codahale Metric Sets for JVM 
instrumentation](https://metrics.dropwizard.io/4.2.0/manual/jvm.html)
diff --git 
a/master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala 
b/master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala
index 5864e6574..7673d77ee 100644
--- 
a/master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala
+++ 
b/master/src/main/scala/org/apache/celeborn/service/deploy/master/Master.scala
@@ -32,7 +32,7 @@ import org.apache.celeborn.common.identity.UserIdentifier
 import org.apache.celeborn.common.internal.Logging
 import org.apache.celeborn.common.meta.{DiskInfo, WorkerInfo}
 import org.apache.celeborn.common.metrics.MetricsSystem
-import org.apache.celeborn.common.metrics.source.{JVMCPUSource, JVMSource, 
ResourceConsumptionSource}
+import org.apache.celeborn.common.metrics.source.{JVMCPUSource, JVMSource, 
ResourceConsumptionSource, SystemMiscSource}
 import org.apache.celeborn.common.protocol._
 import org.apache.celeborn.common.protocol.message.{ControlMessages, 
StatusCode}
 import org.apache.celeborn.common.protocol.message.ControlMessages._
@@ -157,6 +157,7 @@ private[celeborn] class Master(
   metricsSystem.registerSource(masterSource)
   metricsSystem.registerSource(new JVMSource(conf, MetricsSystem.ROLE_MASTER))
   metricsSystem.registerSource(new JVMCPUSource(conf, 
MetricsSystem.ROLE_MASTER))
+  metricsSystem.registerSource(new SystemMiscSource(conf, 
MetricsSystem.ROLE_MASTER))
 
   rpcEnv.setupEndpoint(RpcNameConstants.MASTER_EP, this)
 
diff --git 
a/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala 
b/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
index fceb56c3d..8b840e121 100644
--- 
a/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
+++ 
b/worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Worker.scala
@@ -35,7 +35,7 @@ import org.apache.celeborn.common.identity.UserIdentifier
 import org.apache.celeborn.common.internal.Logging
 import org.apache.celeborn.common.meta.{DiskInfo, WorkerInfo, 
WorkerPartitionLocationInfo}
 import org.apache.celeborn.common.metrics.MetricsSystem
-import org.apache.celeborn.common.metrics.source.{JVMCPUSource, JVMSource}
+import org.apache.celeborn.common.metrics.source.{JVMCPUSource, JVMSource, 
SystemMiscSource}
 import org.apache.celeborn.common.network.TransportContext
 import org.apache.celeborn.common.protocol.{PartitionType, 
PbRegisterWorkerResponse, RpcNameConstants, TransportModuleConstants}
 import org.apache.celeborn.common.protocol.message.ControlMessages._
@@ -84,6 +84,7 @@ private[celeborn] class Worker(
   metricsSystem.registerSource(workerSource)
   metricsSystem.registerSource(new JVMSource(conf, MetricsSystem.ROLE_WORKER))
   metricsSystem.registerSource(new JVMCPUSource(conf, 
MetricsSystem.ROLE_WORKER))
+  metricsSystem.registerSource(new SystemMiscSource(conf, 
MetricsSystem.ROLE_WORKER))
 
   val storageManager = new StorageManager(conf, workerSource)
 

Reply via email to