Browse Source

[Feature][Monitoring] Added disk available capacity monitoring (#10287)

* Added disk available capacity monitoring

* resolve conflict
Added disk available capacity monitoring

* resolve conflict
Added disk available capacity monitoring

* resolve conflict
Added disk available capacity monitoring
3.1.0-release
retime123 3 years ago committed by GitHub
parent
commit
67c4f2b259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
  2. 15
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HeartBeat.java
  3. 18
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java
  4. 7
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/os/OSUtilsTest.java
  5. 3
      dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HeartBeatTest.java
  6. 2
      dolphinscheduler-ui/src/locales/en_US/monitor.ts
  7. 2
      dolphinscheduler-ui/src/locales/zh_CN/monitor.ts
  8. 15
      dolphinscheduler-ui/src/views/monitor/servers/master/index.tsx
  9. 15
      dolphinscheduler-ui/src/views/monitor/servers/worker/index.tsx

2
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

@ -389,7 +389,7 @@ public final class Constants {
/**
* heartbeat for zk info length
*/
public static final int HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH = 13;
public static final int HEARTBEAT_FOR_ZOOKEEPER_INFO_LENGTH = 14;
/**
* jar

15
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HeartBeat.java

@ -41,6 +41,16 @@ public class HeartBeat {
private int workerWaitingTaskCount; // worker waiting task count
private int workerExecThreadCount; // worker thread pool thread count
private double diskAvailable;
public double getDiskAvailable() {
return diskAvailable;
}
public void setDiskAvailable(double diskAvailable) {
this.diskAvailable = diskAvailable;
}
public long getStartupTime() {
return startupTime;
}
@ -176,6 +186,7 @@ public class HeartBeat {
this.loadAverage = OSUtils.loadAverage();
this.availablePhysicalMemorySize = OSUtils.availablePhysicalMemorySize();
this.memoryUsage = OSUtils.memoryUsage();
this.diskAvailable = OSUtils.diskAvailable();
this.processId = OSUtils.getProcessID();
}
@ -216,7 +227,8 @@ public class HeartBeat {
builder.append(processId).append(Constants.COMMA);
builder.append(workerHostWeight).append(Constants.COMMA);
builder.append(workerExecThreadCount).append(Constants.COMMA);
builder.append(workerWaitingTaskCount);
builder.append(workerWaitingTaskCount).append(Constants.COMMA);
builder.append(diskAvailable);
return builder.toString();
}
@ -243,6 +255,7 @@ public class HeartBeat {
heartBeat.workerHostWeight = Integer.parseInt(parts[10]);
heartBeat.workerExecThreadCount = Integer.parseInt(parts[11]);
heartBeat.workerWaitingTaskCount = Integer.parseInt(parts[12]);
heartBeat.diskAvailable = Double.parseDouble(parts[13]);
return heartBeat;
}
}

18
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java

@ -26,6 +26,7 @@ import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
@ -92,6 +93,23 @@ public class OSUtils {
return Double.parseDouble(df.format(memoryUsage));
}
/**
* get disk usage
* Keep 2 decimal
*
* @return disk free size, unit: GB
*/
public static double diskAvailable() {
File file = new File(".");
long freeSpace = file.getFreeSpace(); //unallocated / free disk space in bytes.
double diskAvailable = freeSpace / 1024.0 / 1024 / 1024;
DecimalFormat df = new DecimalFormat(TWO_DECIMAL);
df.setRoundingMode(RoundingMode.HALF_UP);
return Double.parseDouble(df.format(diskAvailable));
}
/**
* get available physical memory size
* <p>

7
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/os/OSUtilsTest.java

@ -42,6 +42,13 @@ public class OSUtilsTest {
Assert.assertTrue(memoryUsage >= 0.0);
}
@Test
public void diskAvailable() {
double diskAvailable = OSUtils.diskAvailable();
logger.info("diskAvailable : {}", diskAvailable);
Assert.assertTrue(diskAvailable >= 0.0);
}
@Test
public void loadAverage() {
double loadAverage = OSUtils.loadAverage();

3
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HeartBeatTest.java

@ -55,7 +55,7 @@ public class HeartBeatTest {
@Test
public void testDecodeHeartBeat() throws Exception {
String heartBeatInfo = "0.35,0.58,3.09,6.47,5.0,1.0,1634033006749,1634033006857,1,29732,1,199,200";
String heartBeatInfo = "0.35,0.58,3.09,6.47,5.0,1.0,1634033006749,1634033006857,1,29732,1,199,200,65.86";
HeartBeat heartBeat = HeartBeat.decodeHeartBeat(heartBeatInfo);
double delta = 0.001;
@ -71,6 +71,7 @@ public class HeartBeatTest {
assertEquals(29732, heartBeat.getProcessId());
assertEquals(199, heartBeat.getWorkerExecThreadCount());
assertEquals(200, heartBeat.getWorkerWaitingTaskCount());
assertEquals(65.86, heartBeat.getDiskAvailable(), delta);
}
}

2
dolphinscheduler-ui/src/locales/en_US/monitor.ts

@ -19,6 +19,7 @@ export default {
master: {
cpu_usage: 'CPU Usage',
memory_usage: 'Memory Usage',
disk_available: 'Disk Available',
load_average: 'Load Average',
create_time: 'Create Time',
last_heartbeat_time: 'Last Heartbeat Time',
@ -32,6 +33,7 @@ export default {
worker: {
cpu_usage: 'CPU Usage',
memory_usage: 'Memory Usage',
disk_available: 'Disk Available',
load_average: 'Load Average',
create_time: 'Create Time',
last_heartbeat_time: 'Last Heartbeat Time',

2
dolphinscheduler-ui/src/locales/zh_CN/monitor.ts

@ -19,6 +19,7 @@ export default {
master: {
cpu_usage: '处理器使用量',
memory_usage: '内存使用量',
disk_available: '磁盘可用容量',
load_average: '平均负载量',
create_time: '创建时间',
last_heartbeat_time: '最后心跳时间',
@ -32,6 +33,7 @@ export default {
worker: {
cpu_usage: '处理器使用量',
memory_usage: '内存使用量',
disk_available: '磁盘可用容量',
load_average: '平均负载量',
create_time: '创建时间',
last_heartbeat_time: '最后心跳时间',

15
dolphinscheduler-ui/src/views/monitor/servers/master/index.tsx

@ -98,7 +98,7 @@ const master = defineComponent({
</NSpace>
</NSpace>
</NCard>
<NGrid x-gap='12' cols='3'>
<NGrid x-gap='12' cols='4'>
<NGi>
<Card title={t('monitor.master.cpu_usage')}>
<div class={styles.card}>
@ -125,6 +125,19 @@ const master = defineComponent({
</div>
</Card>
</NGi>
<NGi>
<Card title={t('monitor.master.disk_available')}>
<div class={[styles.card, styles['load-average']]}>
{item && (
<NNumberAnimation
precision={2}
from={0}
to={JSON.parse(item.resInfo).diskAvailable}
/>
)}
</div>
</Card>
</NGi>
<NGi>
<Card title={t('monitor.master.load_average')}>
<div class={[styles.card, styles['load-average']]}>

15
dolphinscheduler-ui/src/views/monitor/servers/worker/index.tsx

@ -102,7 +102,7 @@ const worker = defineComponent({
</NSpace>
</NSpace>
</NCard>
<NGrid x-gap='12' cols='3'>
<NGrid x-gap='12' cols='4'>
<NGi>
<Card title={t('monitor.worker.cpu_usage')}>
<div class={styles.card}>
@ -129,6 +129,19 @@ const worker = defineComponent({
</div>
</Card>
</NGi>
<NGi>
<Card title={t('monitor.worker.disk_available')}>
<div class={[styles.card, styles['load-average']]}>
{item && (
<NNumberAnimation
precision={2}
from={0}
to={JSON.parse(item.resInfo).diskAvailable}
/>
)}
</div>
</Card>
</NGi>
<NGi>
<Card title={t('monitor.worker.load_average')}>
<div class={[styles.card, styles['load-average']]}>

Loading…
Cancel
Save