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

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb-web-workbench.git

commit 21d9ebedf396eb936e72fcbbee7ad4d4a12bed3e
Author: loveher147 <[email protected]>
AuthorDate: Mon May 30 10:40:30 2022 +0800

    新增监控指标展示功能
    
    - 该版本适配低于0.13版本的iotdb并提供数据库管理功能,但不提供监控管理(低于0.13版本iotdb不支持监控);
    - 仍然存在部分接口返回后端假数据,等待清华提供接口后替换为真实数据。
---
 .../iotdb/admin/controller/IotDBController.java    |   57 +-
 .../iotdb/admin/controller/MetricsController.java  |  170 ++
 .../apache/iotdb/admin/mapper/ViewModeMapper.java  |   13 +
 .../iotdb/admin/model/dto/DataModelDetailDTO.java  |   15 +
 .../apache/iotdb/admin/model/dto/QueryInfoDTO.java |   19 +
 .../apache/iotdb/admin/model/entity/ViewMode.java  |   30 +
 .../iotdb/admin/model/metricsDo/QueryDataDo.java   |   18 +
 .../apache/iotdb/admin/model/vo/DataModelVO.java   |   10 +
 .../org/apache/iotdb/admin/model/vo/GroupInfo.java |   16 +
 .../apache/iotdb/admin/model/vo/GroupInfoVO.java   |    6 +-
 .../iotdb/admin/model/vo/JVMMetricsListDataVO.java |   14 +
 .../model/vo/MetircsQueryClassificationVO.java     |   15 +
 .../iotdb/admin/model/vo/MetricsChartDataVO.java   |   23 +
 .../iotdb/admin/model/vo/MetricsConnectionVO.java  |   15 +
 .../iotdb/admin/model/vo/MetricsDataCountVO.java   |   20 +
 .../admin/model/vo/MetricsDataForDiagramVO.java    |   16 +
 .../iotdb/admin/model/vo/MetricsDataForListVO.java |   16 +
 .../iotdb/admin/model/vo/MetricsListDataVO.java    |   17 +
 .../admin/model/vo/QueryClassificationVO.java      |   14 +
 .../apache/iotdb/admin/model/vo/QueryData1VO.java  |   15 +
 .../iotdb/admin/model/vo/QueryDataForListVO.java   |   16 +
 .../iotdb/admin/model/vo/QueryDataStrVO.java       |   21 +
 .../iotdb/admin/model/vo/QueryDataStrVO1.java      |   15 +
 .../apache/iotdb/admin/model/vo/QueryDataVO.java   |   21 +
 .../apache/iotdb/admin/model/vo/QueryInfoVO.java   |   19 +
 .../iotdb/admin/model/vo/QueryMetricsVO.java       |   14 +
 .../apache/iotdb/admin/service/IotDBService.java   |    3 +
 .../iotdb/admin/service/MetricsResultService.java  |   23 +
 .../apache/iotdb/admin/service/MetricsService.java |   41 +
 .../iotdb/admin/service/impl/IotDBServiceImpl.java |   60 +
 .../service/impl/MetricsResultServiceImpl.java     |  283 ++++
 .../admin/service/impl/MetricsServiceImpl.java     | 1746 ++++++++++++++++++++
 32 files changed, 2764 insertions(+), 17 deletions(-)

diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java 
b/backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java
index 5b4d0d0..8930913 100644
--- 
a/backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java
@@ -95,28 +95,57 @@ public class IotDBController {
     return BaseVO.success("Get IoTDB data model successfully", dataModelVO);
   }
 
+  @GetMapping("/dataModel/detail")
+  @ApiOperation("Get IoTDB data model in detail")
+  public BaseVO<DataModelVO> getDataModelDetail(
+          @PathVariable("serverId") Integer serverId,
+          @RequestParam(value = "path", required = false, defaultValue = 
"root") String path,
+          @RequestParam(value = "pageSize", required = false, defaultValue = 
"10") Integer pageSize,
+          @RequestParam(value = "pageNum", required = false, defaultValue = 
"1") Integer pageNum,
+          HttpServletRequest request)
+          throws BaseException {
+    check(request, serverId);
+    Connection connection = connectionService.getById(serverId);
+    DataModelVO dataModelVO = iotDBService.getDataModelDetail(connection, 
path, pageSize, pageNum);
+    return BaseVO.success("Get IoTDB data model successfully", dataModelVO);
+  }
+
   @GetMapping("/storageGroups/info")
   @ApiOperation("Get information of the storage group list")
-  public BaseVO<List<GroupInfoVO>> getAllStorageGroupsInfo(
-      @PathVariable("serverId") Integer serverId, HttpServletRequest request) 
throws BaseException {
+  public BaseVO<GroupInfoVO> getAllStorageGroupsInfo(
+          @PathVariable("serverId") Integer serverId,
+          @RequestParam(value = "pageSize", required = false, defaultValue = 
"15") Integer pageSize,
+          @RequestParam(value = "pageNum", required = false, defaultValue = 
"1") Integer pageNum,
+          HttpServletRequest request)
+          throws BaseException {
     check(request, serverId);
     Connection connection = connectionService.getById(serverId);
     List<String> groupNames = iotDBService.getAllStorageGroups(connection);
-    List<GroupInfoVO> groupInfoList = new ArrayList<>();
-    if (groupNames == null || groupNames.size() == 0) {
-      return BaseVO.success("Get successfully", groupInfoList);
+    List<String> subGroupNames = new ArrayList<>();
+    int size = groupNames.size();
+    int pageStart = pageNum == 1 ? 0 : (pageNum - 1) * pageSize;
+    int pageEnd = size < pageNum * pageSize ? size : pageNum * pageSize;
+    if (size > pageStart) {
+      subGroupNames = groupNames.subList(pageStart, pageEnd);
+    }
+    List<GroupInfo> groupInfoList = new ArrayList<>();
+    GroupInfoVO groupInfoVO = new GroupInfoVO();
+    if (subGroupNames == null || subGroupNames.size() == 0) {
+      return BaseVO.success("Get successfully", groupInfoVO);
     }
     String host = connection.getHost();
-    List<Integer> deviceCounts = iotDBService.getDevicesCount(connection, 
groupNames);
-    List<String> descriptions = groupService.getGroupDescription(host, 
groupNames);
-    for (int i = 0; i < groupNames.size(); i++) {
-      GroupInfoVO groupInfoVO = new GroupInfoVO();
-      groupInfoVO.setGroupName(groupNames.get(i));
-      groupInfoVO.setDeviceCount(deviceCounts.get(i));
-      groupInfoVO.setDescription(descriptions.get(i));
-      groupInfoList.add(groupInfoVO);
+    List<Integer> deviceCounts = iotDBService.getDevicesCount(connection, 
subGroupNames);
+    List<String> descriptions = groupService.getGroupDescription(host, 
subGroupNames);
+    for (int i = 0; i < subGroupNames.size(); i++) {
+      GroupInfo groupInfo = new GroupInfo();
+      groupInfo.setGroupName(subGroupNames.get(i));
+      groupInfo.setDeviceCount(deviceCounts.get(i));
+      groupInfo.setDescription(descriptions.get(i));
+      groupInfoList.add(groupInfo);
     }
-    return BaseVO.success("Get successfully", groupInfoList);
+    groupInfoVO.setGroupInfoList(groupInfoList);
+    groupInfoVO.setGroupCount(size);
+    return BaseVO.success("Get successfully", groupInfoVO);
   }
 
   @GetMapping("/storageGroups")
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/controller/MetricsController.java
 
b/backend/src/main/java/org/apache/iotdb/admin/controller/MetricsController.java
new file mode 100644
index 0000000..5c5a968
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/controller/MetricsController.java
@@ -0,0 +1,170 @@
+/*
+ * 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.iotdb.admin.controller;
+
+import org.apache.iotdb.admin.common.exception.BaseException;
+import org.apache.iotdb.admin.common.utils.AuthenticationUtils;
+import org.apache.iotdb.admin.model.entity.Connection;
+import org.apache.iotdb.admin.model.vo.*;
+import org.apache.iotdb.admin.service.ConnectionService;
+import org.apache.iotdb.admin.service.IotDBService;
+import org.apache.iotdb.admin.service.MetricsService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-22-上午 9:55
+ */
+@RestController
+@Api(value = "metrics related")
+public class MetricsController {
+
+  @Autowired private ConnectionService connectionService;
+  @Autowired private IotDBService iotDBService;
+  @Autowired private MetricsService metricsService;
+
+  private static final Logger logger = 
LoggerFactory.getLogger(MetricsController.class);
+
+  @GetMapping("/servers/metrics/connection")
+  @ApiOperation("[metrics]Get All Connection")
+  public BaseVO<List<MetricsConnectionVO>> 
getConnectionList(HttpServletRequest request)
+      throws BaseException {
+    Integer userId = AuthenticationUtils.getUserId(request);
+    AuthenticationUtils.userAuthentication(userId, request);
+    List<ConnVO> allConnections = connectionService.getAllConnections(userId);
+    ArrayList<MetricsConnectionVO> metricsConnectionVOS = new ArrayList<>();
+    for (ConnVO connVO : allConnections) {
+      MetricsConnectionVO temp = new MetricsConnectionVO();
+      temp.setId(connVO.getId());
+      temp.setName(connVO.getAlias());
+      metricsConnectionVOS.add(temp);
+    }
+    return BaseVO.success("Get Successfully", metricsConnectionVOS);
+  }
+
+  @GetMapping("/servers/{serverId}/metrics/datacount")
+  @ApiOperation("[metrics]Get Datacount")
+  public BaseVO<MetricsDataCountVO> getMetricsConnectionDataCount(
+      @PathVariable("serverId") Integer serverId, HttpServletRequest request) 
throws BaseException {
+    check(request, serverId);
+    MetricsDataCountVO metricsDataCountVO = 
metricsService.getMetricsDataCount(serverId);
+    return BaseVO.success("Get IoTDB data statistics successfully", 
metricsDataCountVO);
+  }
+
+  @GetMapping("/servers/{serverId}/metrics/QueryClassification")
+  @ApiOperation("[metrics]Get all query classifications")
+  public BaseVO<MetircsQueryClassificationVO> getAllQueryClassification(
+      @PathVariable("serverId") Integer serverId, HttpServletRequest request) 
throws BaseException {
+    check(request, serverId);
+    MetircsQueryClassificationVO metircsQueryClassificationVO =
+        metricsService.getMetircsQueryClassification(serverId);
+    return BaseVO.success("Get IoTDB data statistics successfully", 
metircsQueryClassificationVO);
+  }
+
+  
@GetMapping("/servers/{serverId}/metrics/{queryClassificationId}/selectcount")
+  @ApiOperation("[Metrics]Get detail information of query sql")
+  public BaseVO<QueryInfoVO> getQueryInfo(
+      @PathVariable("serverId") Integer serverId,
+      @PathVariable("queryClassificationId") Integer queryClassificationId,
+      @RequestParam(value = "pageSize", required = false, defaultValue = "10") 
Integer pageSize,
+      @RequestParam(value = "pageNum", required = false, defaultValue = "1") 
Integer pageNum,
+      @RequestParam(value = "filterString", required = false) String 
filterString,
+      @RequestParam(value = "startTime", required = false, defaultValue = 
"-1") String startTimeStr,
+      @RequestParam(value = "endTime", required = false, defaultValue = "-1") 
String endTimeStr,
+      @RequestParam(value = "executionResult", required = false) Integer 
executionResult,
+      HttpServletRequest request)
+      throws BaseException {
+    check(request, serverId);
+    QueryInfoVO queryInfoVO =
+        metricsService.getQueryInfo(
+            serverId,
+            queryClassificationId,
+            pageSize,
+            pageNum,
+            filterString,
+            startTimeStr,
+            endTimeStr,
+            executionResult);
+    return BaseVO.success("Get IoTDB query statement data statistics 
successfully", queryInfoVO);
+  }
+
+  @GetMapping("/servers/{serverId}/metrics/diagram")
+  @ApiOperation("Get metrics data for diagram")
+  public BaseVO<MetricsDataForDiagramVO> getMetricsDataForDiagram(
+      @PathVariable("serverId") Integer serverId,
+      @RequestParam Integer metricId,
+      HttpServletRequest request)
+      throws BaseException {
+    check(request, serverId);
+    Connection connection = connectionService.getById(serverId);
+    MetricsDataForDiagramVO metricsDataForDiagramVO =
+        iotDBService.getMetricDataByMetricId(connection, metricId);
+    metricsDataForDiagramVO.setServerId(serverId);
+    return BaseVO.success("Get metrics data for diagram successfully", 
metricsDataForDiagramVO);
+  }
+
+  @GetMapping("/servers/{serverId}/metrics/list/{metricsType}")
+  @ApiOperation("Get metrics data for list")
+  public BaseVO<MetricsDataForListVO> getMetricsDataForList(
+      @PathVariable("serverId") Integer serverId,
+      @PathVariable("metricsType") Integer metricsType,
+      HttpServletRequest request)
+      throws BaseException {
+    check(request, serverId);
+    MetricsDataForListVO metricsDataForListVO =
+        metricsService.getMetricsDataForList(serverId, metricsType);
+    return BaseVO.success("Get metrics data for list successfully", 
metricsDataForListVO);
+  }
+
+  @GetMapping("/servers/{serverId}/metrics/list/query/{mode}")
+  @ApiOperation("Get query metrics data for list")
+  public BaseVO<QueryDataForListVO> getQueryMetricsDataForList(
+      @PathVariable("serverId") Integer serverId, @PathVariable("mode") 
Integer mode)
+      throws BaseException {
+    QueryDataForListVO queryDataForListVO = new QueryDataForListVO();
+    queryDataForListVO.setMode(mode);
+    queryDataForListVO.setServerId(serverId);
+
+    if (mode == 1) {
+      List<QueryMetricsVO> queryMetricsVOs = 
iotDBService.getTopQueryMetricsData();
+      queryDataForListVO.setQueryMetricsVOs(queryMetricsVOs);
+
+    } else if (mode == 0) {
+      List<QueryMetricsVO> queryMetricsVOs = 
iotDBService.getSlowQueryMetricsData();
+      queryDataForListVO.setQueryMetricsVOs(queryMetricsVOs);
+    }
+    return BaseVO.success("Get query metrics data for list successfully", 
queryDataForListVO);
+  }
+
+  private void check(HttpServletRequest request, Integer serverId) throws 
BaseException {
+    Integer userId = AuthenticationUtils.getUserId(request);
+    connectionService.check(serverId, userId);
+  }
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/mapper/ViewModeMapper.java 
b/backend/src/main/java/org/apache/iotdb/admin/mapper/ViewModeMapper.java
new file mode 100644
index 0000000..66f9ea3
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/mapper/ViewModeMapper.java
@@ -0,0 +1,13 @@
+package org.apache.iotdb.admin.mapper;
+
+import org.apache.iotdb.admin.model.entity.ViewMode;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Erickin
+ * @create 2022-04-22-上午 10:32
+ */
+@Component
+public interface ViewModeMapper extends BaseMapper<ViewMode> {}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/dto/DataModelDetailDTO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/dto/DataModelDetailDTO.java
new file mode 100644
index 0000000..b33cce1
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/dto/DataModelDetailDTO.java
@@ -0,0 +1,15 @@
+package org.apache.iotdb.admin.model.dto;
+
+import lombok.Data;
+import org.apache.iotdb.admin.model.vo.DataModelVO;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class DataModelDetailDTO implements Serializable {
+  private List<DataModelVO> dataModelVOList;
+  private Integer pageNum;
+  private Integer pageSize;
+  private Integer total;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/dto/QueryInfoDTO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/dto/QueryInfoDTO.java
new file mode 100644
index 0000000..7f3210b
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/dto/QueryInfoDTO.java
@@ -0,0 +1,19 @@
+package org.apache.iotdb.admin.model.dto;
+
+import org.apache.iotdb.admin.model.vo.QueryDataStrVO;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-下午 5:12
+ */
+@Data
+public class QueryInfoDTO {
+  private Long latestRunningTime;
+  private Integer totalCount;
+  private Integer totalPage;
+  List<QueryDataStrVO> filteredQueryDataStrVOSList;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/entity/ViewMode.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/entity/ViewMode.java
new file mode 100644
index 0000000..56c9ae6
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/entity/ViewMode.java
@@ -0,0 +1,30 @@
+package org.apache.iotdb.admin.model.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Null;
+import javax.validation.constraints.Pattern;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-22-上午 10:35
+ */
+@Data
+@TableName("view_mode")
+public class ViewMode implements Serializable {
+  private static final long serialVersionUID = 1L;
+
+  @Null
+  @TableId(type = IdType.AUTO)
+  private Integer id;
+
+  @NotBlank
+  @Pattern(regexp = "^[^ ]+$", message = "The account name cannot contain 
spaces")
+  private String name;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/metricsDo/QueryDataDo.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/metricsDo/QueryDataDo.java
new file mode 100644
index 0000000..2be1e09
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/metricsDo/QueryDataDo.java
@@ -0,0 +1,18 @@
+package org.apache.iotdb.admin.model.metricsDo;
+
+import org.apache.iotdb.admin.model.vo.QueryDataVO;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-上午 9:28
+ */
+@Data
+public class QueryDataDo {
+  private List<QueryDataVO> QueryDataVOs;
+  private Long latestTimeStamp;
+  private Integer count;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/DataModelVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/DataModelVO.java
index 2763728..60f9a60 100644
--- a/backend/src/main/java/org/apache/iotdb/admin/model/vo/DataModelVO.java
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/DataModelVO.java
@@ -47,6 +47,16 @@ public class DataModelVO implements Serializable {
 
   private List<DataModelVO> children;
 
+  private Integer showNum;
+
+  private Integer pageNum;
+
+  private Integer pageSize;
+
+  private Integer total;
+
+  private Integer totalSonNodeCount;
+
   public DataModelVO(String name) {
     this.name = name;
     this.isGroup = false;
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfo.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfo.java
new file mode 100644
index 0000000..62e3cb2
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfo.java
@@ -0,0 +1,16 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class GroupInfo implements Serializable {
+  private String groupName;
+  private Integer deviceCount;
+  private String description;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfoVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfoVO.java
index 512deb7..87f4823 100644
--- a/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfoVO.java
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/GroupInfoVO.java
@@ -24,12 +24,12 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.util.List;
 
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
 public class GroupInfoVO implements Serializable {
-  private String groupName;
-  private Integer deviceCount;
-  private String description;
+  private Integer groupCount;
+  private List<GroupInfo> groupInfoList;
 }
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/JVMMetricsListDataVO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/JVMMetricsListDataVO.java
new file mode 100644
index 0000000..3661555
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/JVMMetricsListDataVO.java
@@ -0,0 +1,14 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 5:26
+ */
+@Data
+public class JVMMetricsListDataVO extends MetricsListDataVO implements 
Serializable {
+  private String metricType;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetircsQueryClassificationVO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetircsQueryClassificationVO.java
new file mode 100644
index 0000000..851c833
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetircsQueryClassificationVO.java
@@ -0,0 +1,15 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-上午 10:00
+ */
+@Data
+public class MetircsQueryClassificationVO {
+  private Integer serverId;
+  private List<QueryClassificationVO> classificationList;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsChartDataVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsChartDataVO.java
new file mode 100644
index 0000000..9bfa81f
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsChartDataVO.java
@@ -0,0 +1,23 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-上午 10:15
+ */
+@Data
+public class MetricsChartDataVO implements Serializable {
+  private List<String> timeList;
+  private List<String> metricnameList;
+  private List<String> unitList;
+  private HashMap<String, List<String>> dataList;
+}
+
+// List<String> timeList;
+// List<String> metricnameList;
+// HashMap<String, List<Integer> dataList;
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsConnectionVO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsConnectionVO.java
new file mode 100644
index 0000000..8045fdb
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsConnectionVO.java
@@ -0,0 +1,15 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-上午 9:12
+ */
+@Data
+public class MetricsConnectionVO implements Serializable {
+  Integer id;
+  String name;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataCountVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataCountVO.java
new file mode 100644
index 0000000..82f6337
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataCountVO.java
@@ -0,0 +1,20 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-上午 9:38
+ */
+@Data
+public class MetricsDataCountVO {
+  private Integer serverId;
+  private Boolean status;
+  private String url;
+  private Integer port;
+  private Integer storageGroupCount;
+  private Integer deviceCount;
+  private Integer monitorCount;
+  private Integer dataCount;
+  private String version;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataForDiagramVO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataForDiagramVO.java
new file mode 100644
index 0000000..08135e3
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataForDiagramVO.java
@@ -0,0 +1,16 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-上午 10:12
+ */
+@Data
+public class MetricsDataForDiagramVO implements Serializable {
+  private Integer serverId;
+  private Integer metricId;
+  private MetricsChartDataVO chartData;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataForListVO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataForListVO.java
new file mode 100644
index 0000000..269cde1
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsDataForListVO.java
@@ -0,0 +1,16 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 8:12
+ */
+@Data
+public class MetricsDataForListVO {
+  private Integer serverId;
+  private Integer metricsType;
+  private List<MetricsListDataVO> listInfo;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsListDataVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsListDataVO.java
new file mode 100644
index 0000000..7bde7ca
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/MetricsListDataVO.java
@@ -0,0 +1,17 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 5:24
+ */
+@Data
+public class MetricsListDataVO implements Serializable {
+  private String name;
+  private String latestScratchTime;
+  private String latestResult;
+  private Integer detailAvailable;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryClassificationVO.java
 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryClassificationVO.java
new file mode 100644
index 0000000..17993c0
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryClassificationVO.java
@@ -0,0 +1,14 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-上午 10:02
+ */
+@Data
+public class QueryClassificationVO {
+  private Integer id;
+  private String name;
+  private Integer flag;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryData1VO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryData1VO.java
new file mode 100644
index 0000000..b14e3c4
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryData1VO.java
@@ -0,0 +1,15 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-下午 3:56
+ */
+@Data
+public class QueryData1VO extends QueryDataVO implements Serializable {
+  private Integer precompiledTime;
+  private Integer optimizedTime;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataForListVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataForListVO.java
new file mode 100644
index 0000000..b200a0d
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataForListVO.java
@@ -0,0 +1,16 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 9:22
+ */
+@Data
+public class QueryDataForListVO {
+  private Integer serverId;
+  private Integer mode;
+  private List<QueryMetricsVO> queryMetricsVOs;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataStrVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataStrVO.java
new file mode 100644
index 0000000..5aecf44
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataStrVO.java
@@ -0,0 +1,21 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-28-下午 10:02
+ */
+@Data
+public class QueryDataStrVO implements Serializable {
+  private Integer id;
+  private String statement;
+  private String runningTime;
+  private Boolean isSlowQuery;
+  private Integer totalTime;
+  private Integer analysisTime;
+  private Integer executionTime;
+  private Integer executionResult;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataStrVO1.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataStrVO1.java
new file mode 100644
index 0000000..a14537a
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataStrVO1.java
@@ -0,0 +1,15 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-29-下午 2:10
+ */
+@Data
+public class QueryDataStrVO1 extends QueryDataStrVO implements Serializable {
+  private Integer precompiledTime;
+  private Integer optimizedTime;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataVO.java
new file mode 100644
index 0000000..081be81
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryDataVO.java
@@ -0,0 +1,21 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-下午 8:36
+ */
+@Data
+public class QueryDataVO implements Serializable {
+  private Integer id;
+  private String statement;
+  private Long runningTime;
+  private Boolean isSlowQuery;
+  private Integer totalTime;
+  private Integer analysisTime;
+  private Integer executionTime;
+  private Integer executionResult;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryInfoVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryInfoVO.java
new file mode 100644
index 0000000..e2b3529
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryInfoVO.java
@@ -0,0 +1,19 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-25-下午 5:13
+ */
+@Data
+public class QueryInfoVO {
+  private Integer queryClassificationId;
+  private String latestRunningTime;
+  private Integer totalCount;
+  private Integer totalPage;
+  private Integer serverId;
+  private List<QueryDataStrVO> filteredQueryDataStrVOSList;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryMetricsVO.java 
b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryMetricsVO.java
new file mode 100644
index 0000000..cdf3e12
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/model/vo/QueryMetricsVO.java
@@ -0,0 +1,14 @@
+package org.apache.iotdb.admin.model.vo;
+
+import lombok.Data;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 9:20
+ */
+@Data
+public class QueryMetricsVO {
+  private String SQLStatement;
+  private String runningTime;
+  private Integer executionTime;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/service/IotDBService.java 
b/backend/src/main/java/org/apache/iotdb/admin/service/IotDBService.java
index 0b050d7..2a97117 100644
--- a/backend/src/main/java/org/apache/iotdb/admin/service/IotDBService.java
+++ b/backend/src/main/java/org/apache/iotdb/admin/service/IotDBService.java
@@ -62,6 +62,9 @@ public interface IotDBService {
 
   void setIotDBRole(Connection connection, IotDBRole iotDBRole) throws 
BaseException;
 
+  DataModelVO getDataModelDetail(
+          Connection connection, String path, Integer pageSize, Integer 
pageNum) throws BaseException;
+
   UserRolesVO getRolesOfUser(Connection connection, String userName) throws 
BaseException;
 
   void userGrant(Connection connection, String userName, UserGrantDTO 
userGrantDTO)
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/service/MetricsResultService.java
 
b/backend/src/main/java/org/apache/iotdb/admin/service/MetricsResultService.java
new file mode 100644
index 0000000..1180f23
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/service/MetricsResultService.java
@@ -0,0 +1,23 @@
+package org.apache.iotdb.admin.service;
+
+import org.apache.iotdb.admin.common.exception.BaseException;
+import org.apache.iotdb.admin.model.entity.Connection;
+import org.apache.iotdb.admin.model.vo.MetricsListDataVO;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 4:07
+ */
+public interface MetricsResultService {
+  List<MetricsListDataVO> getJVMMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getCPUMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getMemMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getDiskMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getWriteMetricsDataList(Connection connection) 
throws BaseException;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/service/MetricsService.java 
b/backend/src/main/java/org/apache/iotdb/admin/service/MetricsService.java
new file mode 100644
index 0000000..50f8663
--- /dev/null
+++ b/backend/src/main/java/org/apache/iotdb/admin/service/MetricsService.java
@@ -0,0 +1,41 @@
+package org.apache.iotdb.admin.service;
+
+import org.apache.iotdb.admin.common.exception.BaseException;
+import org.apache.iotdb.admin.model.entity.Connection;
+import org.apache.iotdb.admin.model.vo.*;
+
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 4:07
+ */
+public interface MetricsService {
+  List<MetricsListDataVO> getJVMMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getCPUMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getMemMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getDiskMetricsDataList(Connection connection) throws 
BaseException;
+
+  List<MetricsListDataVO> getWriteMetricsDataList(Connection connection) 
throws BaseException;
+
+  MetircsQueryClassificationVO getMetircsQueryClassification(Integer serverId);
+
+  QueryInfoVO getQueryInfo(
+      Integer serverId,
+      Integer queryClassificationId,
+      Integer pageSize,
+      Integer pageNum,
+      String filterString,
+      String startTimeStr,
+      String endTimeStr,
+      Integer executionResult)
+      throws BaseException;
+
+  MetricsDataCountVO getMetricsDataCount(Integer serverId) throws 
BaseException;
+
+  MetricsDataForListVO getMetricsDataForList(Integer serverId, Integer 
metricsType)
+      throws BaseException;
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java
 
b/backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java
index e904462..4318825 100644
--- 
a/backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java
@@ -765,6 +765,66 @@ public class IotDBServiceImpl implements IotDBService {
     }
   }
 
+  @Override
+  public DataModelVO getDataModelDetail(
+          Connection connection, String path, Integer pageSize, Integer 
pageNum) throws BaseException {
+    SessionPool sessionPool = null;
+    try {
+      sessionPool = getSessionPool(connection);
+      DataModelVO root = new DataModelVO(path);
+      setNodeInfo(root, sessionPool, path);
+      List<DataModelVO> childrenDataModel = null;
+      DataModelDetailDTO childrenDataModelDetail =
+              getChildrenDataModelDetail(root, path, sessionPool, pageSize, 
pageNum);
+      childrenDataModel =
+              childrenDataModelDetail == null ? null : 
childrenDataModelDetail.getDataModelVOList();
+      if (childrenDataModelDetail != null) {
+        root.setPageNum(childrenDataModelDetail.getPageNum());
+        root.setPageSize(childrenDataModelDetail.getPageSize());
+        root.setTotal(childrenDataModelDetail.getTotal());
+      }
+      root.setChildren(childrenDataModel);
+      root.setTotalSonNodeCount(
+              getChildrenNode(path, sessionPool) == null
+                      ? 0
+                      : getChildrenNode(path, sessionPool).size());
+      root.setGroupCount(path.equals("root") ? getGroupCount(sessionPool) : 
null);
+      root.setPath(path);
+      return root;
+    } finally {
+      closeSessionPool(sessionPool);
+    }
+  }
+
+  private DataModelDetailDTO getChildrenDataModelDetail(
+          DataModelVO root, String path, SessionPool sessionPool, Integer 
pageSize, Integer pageNum)
+          throws BaseException {
+    Set<String> childrenNode = getChildrenNode(path, sessionPool);
+    if (childrenNode == null) {
+      return null;
+    }
+    List<DataModelVO> childrenlist = new ArrayList<>();
+    List<String> childrenNodeList = new ArrayList<>(childrenNode);
+    List<String> childrenNodeSubList = new ArrayList<>();
+    int size = childrenNode.size();
+    int pageStart = pageNum == 1 ? 0 : (pageNum - 1) * pageSize;
+    int pageEnd = size < pageNum * pageSize ? size : pageNum * pageSize;
+    if (size > pageStart) {
+      childrenNodeSubList = childrenNodeList.subList(pageStart, pageEnd);
+    }
+    for (String child : childrenNodeSubList) {
+      DataModelVO childNode = new DataModelVO(child);
+      setNodeInfo(childNode, sessionPool, path + "." + child);
+      childrenlist.add(childNode);
+    }
+    DataModelDetailDTO dataModelDetailDTO = new DataModelDetailDTO();
+    dataModelDetailDTO.setDataModelVOList(childrenlist);
+    dataModelDetailDTO.setPageNum(pageNum);
+    dataModelDetailDTO.setPageSize(pageSize);
+    dataModelDetailDTO.setTotal(size);
+    return dataModelDetailDTO;
+  }
+
   @Override
   public UserRolesVO getRolesOfUser(Connection connection, String userName) 
throws BaseException {
     SessionPool sessionPool = getSessionPool(connection);
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsResultServiceImpl.java
 
b/backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsResultServiceImpl.java
new file mode 100644
index 0000000..de26ba5
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsResultServiceImpl.java
@@ -0,0 +1,283 @@
+package org.apache.iotdb.admin.service.impl;
+
+import org.apache.iotdb.admin.common.exception.BaseException;
+import org.apache.iotdb.admin.model.entity.Connection;
+import org.apache.iotdb.admin.model.vo.JVMMetricsListDataVO;
+import org.apache.iotdb.admin.model.vo.MetricsListDataVO;
+import org.apache.iotdb.admin.service.MetricsResultService;
+
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 4:41
+ */
+@Service
+public class MetricsResultServiceImpl implements MetricsResultService {
+
+  public JVMMetricsListDataVO getCurrentThreadsCount(long currentTimeMillis) 
throws BaseException {
+    String name = "JVM当前线程数";
+    String metricType = "线程";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 1;
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:8086\".\"jvm.threads.daemon\","
+            + " root._metric.\"127.0.0.1:8086\".\"jvm.threads.live\" "
+            + "order by time desc limit 1";
+    try {
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    String latestResult = "[Just Test] 前台:20个,后台:39个,线程总数:59个";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getYGCHappendCountAndCostTime(long 
currentTimeMillis)
+      throws BaseException {
+    // TODO 暂时写死
+    String name = "YGC发生次数及总耗时";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 2;
+    String latestResult = "[Just Test] 20次 200s";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getUsedBufferSize(long currentTimeMillis) throws 
BaseException {
+    String name = "已经使用的缓冲区大小";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 3;
+    String latestResult = "[Just Test] 20G";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMTotalUnloadClass(long currentTimeMillis) 
throws BaseException {
+    String name = "JVM累计卸载的class数量";
+    String metricType = "Classes";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 4;
+    String latestResult = "[Just Test] 30次";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public MetricsListDataVO getCPUUsed(long currentTimeMillis) throws 
BaseException {
+    String name = "CPU使用率";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 1;
+    String latestResult = "[Just Test] 50%";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getCPUCores(long currentTimeMillis) throws 
BaseException {
+    String name = "CPU核数";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 0;
+    String latestResult = "[Just Test] 4核";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getIotDBProcessMemUsed(long currentTimeMillis) 
throws BaseException {
+    String name = "IoTDB进程内存占用比例";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 1;
+    String latestResult = "[Just Test] 70%";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getTotalMem(long currentTimeMillis) throws 
BaseException {
+    String name = "物理内存大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 0;
+    String latestResult = "[Just Test] 4G";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getDiskAvaliable(long currentTimeMillis) throws 
BaseException {
+    String name = "磁盘剩余";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 1;
+    String latestResult = "[Just Test] 2G";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getDiskTotalSize(long currentTimeMillis) throws 
BaseException {
+    String name = "磁盘总大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 0;
+    String latestResult = "[Just Test] 4G";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO writeSucceedProportion(long currentTimeMillis) 
throws BaseException {
+    String name = "写入成功率";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 0;
+    String latestResult = "[Just Test] 80%";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO writeLatency(long currentTimeMillis) throws 
BaseException {
+    String name = "写入延迟(最近一分钟)";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    String latestScratchTime = simpleDateFormat.format(currentTimeMillis);
+    Integer detailAvailable = 1;
+    String latestResult = "[Just Test] 90%";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getJVMMetricsDataList(Connection connection) 
throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    long currentTimeMillis = System.currentTimeMillis();
+    JVMMetricsListDataVO currentThreadsCount = 
getCurrentThreadsCount(currentTimeMillis);
+    JVMMetricsListDataVO ygcHappendCountAndCostTime =
+        getYGCHappendCountAndCostTime(currentTimeMillis);
+    JVMMetricsListDataVO usedBufferSize = getUsedBufferSize(currentTimeMillis);
+    JVMMetricsListDataVO jvmTotalUnloadClass = 
getJVMTotalUnloadClass(currentTimeMillis);
+    // TODO 把所有指标都加进来
+    list.add(currentThreadsCount);
+    list.add(ygcHappendCountAndCostTime);
+    list.add(usedBufferSize);
+    list.add(jvmTotalUnloadClass);
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getCPUMetricsDataList(Connection connection) 
throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    long currentTimeMillis = System.currentTimeMillis();
+    MetricsListDataVO cpuUsed = getCPUUsed(currentTimeMillis);
+    MetricsListDataVO cpuCores = getCPUCores(currentTimeMillis);
+    list.add(cpuUsed);
+    list.add(cpuCores);
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getMemMetricsDataList(Connection connection) 
throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    long currentTimeMillis = System.currentTimeMillis();
+    MetricsListDataVO iotDBProcessMemUsed = 
getIotDBProcessMemUsed(currentTimeMillis);
+    MetricsListDataVO totalMem = getTotalMem(currentTimeMillis);
+    list.add(iotDBProcessMemUsed);
+    list.add(totalMem);
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getDiskMetricsDataList(Connection connection)
+      throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    long currentTimeMillis = System.currentTimeMillis();
+    MetricsListDataVO metricsListDataVO = getDiskAvaliable(currentTimeMillis);
+    MetricsListDataVO diskTotalSize = getDiskTotalSize(currentTimeMillis);
+    list.add(metricsListDataVO);
+    list.add(diskTotalSize);
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getWriteMetricsDataList(Connection connection)
+      throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    long currentTimeMillis = System.currentTimeMillis();
+    MetricsListDataVO writeSucceedProportion = 
writeSucceedProportion(currentTimeMillis);
+    MetricsListDataVO writeLatency = writeLatency(currentTimeMillis);
+    list.add(writeSucceedProportion);
+    list.add(writeLatency);
+    return list;
+  }
+}
diff --git 
a/backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsServiceImpl.java
 
b/backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsServiceImpl.java
new file mode 100644
index 0000000..5dd025d
--- /dev/null
+++ 
b/backend/src/main/java/org/apache/iotdb/admin/service/impl/MetricsServiceImpl.java
@@ -0,0 +1,1746 @@
+package org.apache.iotdb.admin.service.impl;
+
+import org.apache.iotdb.admin.common.exception.BaseException;
+import org.apache.iotdb.admin.common.exception.ErrorCode;
+import org.apache.iotdb.admin.model.dto.QueryInfoDTO;
+import org.apache.iotdb.admin.model.entity.Connection;
+import org.apache.iotdb.admin.model.vo.*;
+import org.apache.iotdb.admin.service.ConnectionService;
+import org.apache.iotdb.admin.service.IotDBService;
+import org.apache.iotdb.admin.service.MetricsService;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+import org.apache.iotdb.session.pool.SessionDataSetWrapper;
+import org.apache.iotdb.session.pool.SessionPool;
+import org.apache.iotdb.tsfile.read.common.RowRecord;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Erickin
+ * @create 2022-04-26-下午 4:41
+ */
+@Service
+public class MetricsServiceImpl implements MetricsService {
+
+  @Autowired ConnectionService connectionService;
+  @Autowired IotDBService iotDBService;
+
+  private static final Logger logger = 
LoggerFactory.getLogger(IotDBServiceImpl.class);
+
+  public JVMMetricsListDataVO getCurrentThreadsCount(Connection connection) 
throws BaseException {
+    String name = "JVM当前线程数";
+    String metricType = "线程";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 1;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.daemon\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.live\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(2);
+    String s2 = values.get(1);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    s2 = s2.substring(0, s2.indexOf('.'));
+    int totalThreadCount = Integer.parseInt(s1);
+    int demoThreadCount = Integer.parseInt(s2);
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult =
+        "前台:"
+            + (totalThreadCount - demoThreadCount)
+            + "个,后台:"
+            + demoThreadCount
+            + "个,线程总数:"
+            + totalThreadCount
+            + "个";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getCurrentDaemonThreadsCount(Connection 
connection)
+      throws BaseException {
+    String name = "当前daemon线程数";
+    String metricType = "线程";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.daemon\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    int daemonThreadCount = Integer.parseInt(s1);
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = daemonThreadCount + "个";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getPeakThreadsCount(Connection connection) 
throws BaseException {
+    String name = "峰值线程数";
+    String metricType = "线程";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.peak\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    int daemonThreadCount = Integer.parseInt(s1);
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = daemonThreadCount + "个";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getVariableThreadsCount(Connection connection) 
throws BaseException {
+    String name = "处于各种状态的线程数";
+    String metricType = "线程";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.states\".\"state=new\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.states\".\"state=waiting\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.states\".\"state=runnable\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.states\".\"state=blocked\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.states\".\"state=timed-waiting\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.threads.states\".\"state=terminated\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    String s2 = values.get(2);
+    String s3 = values.get(3);
+    String s4 = values.get(4);
+    String s5 = values.get(5);
+    String s6 = values.get(6);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    s2 = s2.substring(0, s2.indexOf('.'));
+    s3 = s3.substring(0, s3.indexOf('.'));
+    s4 = s4.substring(0, s4.indexOf('.'));
+    s5 = s5.substring(0, s5.indexOf('.'));
+    s6 = s6.substring(0, s6.indexOf('.'));
+    int newThreadCount = Integer.parseInt(s1);
+    int waitingThreadCount = Integer.parseInt(s2);
+    int runnableThreadCount = Integer.parseInt(s3);
+    int blockedThreadCount = Integer.parseInt(s4);
+    int timedWaitingThreadCount = Integer.parseInt(s5);
+    int terminatedThreadCount = Integer.parseInt(s6);
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult =
+        "新建("
+            + newThreadCount
+            + ")、"
+            + "可运行("
+            + waitingThreadCount
+            + ")、"
+            + "运行("
+            + runnableThreadCount
+            + ")、"
+            + "阻塞("
+            + blockedThreadCount
+            + ")、"
+            + "休眠("
+            + timedWaitingThreadCount
+            + ")、"
+            + "死亡("
+            + terminatedThreadCount
+            + ")";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getYGCHappendCountAndCostTime(Connection 
connection)
+      throws BaseException {
+    String name = "YGC发生次数及总耗时";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    SessionPool sessionPool = getSessionPool(connection);
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String countSQL =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_count\".\"action=end of minor 
GC\".\"cause=Allocation Failure\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_count\".\"action=end of minor 
GC\".\"cause=Metadata GC Threshold\" "
+            + "order by time desc limit 1";
+    String timeSQL =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_total\".\"action=end of minor 
GC\".\"cause=Allocation Failure\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_total\".\"action=end of minor 
GC\".\"cause=Metadata GC Threshold\" "
+            + "order by time desc limit 1";
+    List<String> countValues = executeQueryOneLine(sessionPool, countSQL);
+    List<String> timeValues = executeQueryOneLine(sessionPool, timeSQL);
+    long lastestTimeStamp = Long.parseLong(countValues.get(0));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    Integer detailAvailable = 2;
+    String s1 = countValues.get(1);
+    String s2 = countValues.get(2);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    s2 = s2.substring(0, s2.indexOf('.'));
+    int count = Integer.parseInt(s1) + Integer.parseInt(s2);
+    double time =
+        (Double.parseDouble(timeValues.get(1)) + 
Double.parseDouble(timeValues.get(2))) / 1000;
+    String latestResult = count + "次 " + time + "s";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getYGCMaxCostTimeAndReason(Connection connection)
+      throws BaseException {
+    String name = "YGC最大耗时及原因";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    SessionPool sessionPool = getSessionPool(connection);
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String timeSQL =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_max\".\"action=end of minor 
GC\".\"cause=Metadata GC Threshold\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_max\".\"action=end of minor 
GC\".\"cause=Allocation Failure\" "
+            + "order by time desc limit 1";
+    List<String> timeValues = executeQueryOneLine(sessionPool, timeSQL);
+    long lastestTimeStamp = Long.parseLong(timeValues.get(0));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    Integer detailAvailable = 2;
+    String latestResult =
+        Double.parseDouble(timeValues.get(1)) / 1000
+            + "s(Metadata GC Threshold)、"
+            + Double.parseDouble(timeValues.get(2)) / 1000
+            + "s(Allocation Failure)";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getFGCHappendCountAndCostTime(Connection 
connection)
+      throws BaseException {
+    String name = "FGC发生次数及总耗时";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    SessionPool sessionPool = getSessionPool(connection);
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String countSQL =
+        "select * from "
+            +
+            //            
"root._metric.\"127.0.0.1:8086\".\"jvm.gc.pause_count\".\"action=end of
+            // major GC\".\"cause=Allocation Failure\", " +
+            "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_count\".\"action=end of major 
GC\".\"cause=Metadata GC Threshold\" "
+            +
+            //            
"root._metric.\"127.0.0.1:8086\".\"jvm.gc.pause_count\".\"action=end of
+            // major GC\".\"cause=Ergonomics\" " +
+            "order by time desc limit 1";
+    String timeSQL =
+        "select * from "
+            +
+            //            
"root._metric.\"127.0.0.1:8086\".\"jvm.gc.pause_total\".\"action=end of
+            // major GC\".\"cause=Allocation Failure\", " +
+            "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_total\".\"action=end of major 
GC\".\"cause=Metadata GC Threshold\" "
+            +
+            //            
"root._metric.\"127.0.0.1:8086\".\"jvm.gc.pause_total\".\"action=end of
+            // major GC\".\"cause=Ergonomics\" " +
+            "order by time desc limit 1";
+    List<String> countValues = executeQueryOneLine(sessionPool, countSQL);
+    List<String> timeValues = executeQueryOneLine(sessionPool, timeSQL);
+    long lastestTimeStamp = Long.parseLong(countValues.get(0));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    Integer detailAvailable = 2;
+    // TODO: IOTDB BUG 等待修复
+    String s1 = countValues.get(1).equals("null") ? "0.0" : countValues.get(1);
+    //    String s2 = countValues.get(2).equals("null") ? "0.0" : 
countValues.get(2);
+    //    String s3 = countValues.get(3).equals("null") ? "0.0" : 
countValues.get(3);
+
+    s1 = s1.substring(0, s1.indexOf('.'));
+    //    s2 = s2.substring(0, s2.indexOf('.'));
+    //    s3 = s3.substring(0, s3.indexOf('.'));
+    //    int count = Integer.parseInt(s1) + Integer.parseInt(s2) + 
Integer.parseInt(s3);
+    int count = Integer.parseInt(s1);
+    // TODO: IOTDB BUG 等待修复
+    double d1 = timeValues.get(1).equals("null") ? 0.0 : 
Double.parseDouble(timeValues.get(1));
+    //    double d2 = timeValues.get(2).equals("null")? 0.0 : 
Double.parseDouble(timeValues.get(2));
+    //    double d3 = timeValues.get(3).equals("null")? 0.0 : 
Double.parseDouble(timeValues.get(3));
+    //    double time = d1 + d2 + d3;
+    double time = (d1) / 1000;
+    String latestResult = count + "次 " + time + "s";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getFGCMaxCostTimeAndReason(Connection connection)
+      throws BaseException {
+    String name = "FGC最大耗时及原因";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    SessionPool sessionPool = getSessionPool(connection);
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String timeSQL =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.pause_max\".\"action=end of major 
GC\".\"cause=Metadata GC Threshold\" "
+            +
+            //            
"root._metric.\"127.0.0.1:8086\".\"jvm.gc.pause_max\".\"action=end of
+            // major GC\".\"cause=Allocation Failure\", " +
+            //            
"root._metric.\"127.0.0.1:8086\".\"jvm.gc.pause_max\".\"action=end of
+            // major GC\".\"cause=Ergonomics\" " +
+            "order by time desc limit 1";
+    List<String> timeValues = executeQueryOneLine(sessionPool, timeSQL);
+    long lastestTimeStamp = Long.parseLong(timeValues.get(0));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    Integer detailAvailable = 2;
+    // TODO: IOTDB BUG 等待修复
+    String s1 = timeValues.get(1).equals("null") ? "0.0" : timeValues.get(1);
+    //    String s2 = timeValues.get(2).equals("null")? "0.0" : 
timeValues.get(2);
+    //    String s3 = timeValues.get(3).equals("null")? "0.0" : 
timeValues.get(3);
+    //    String latestResult = timeValues.get(1)+"s(Metadata GC
+    // Threshold)、"+timeValues.get(2)+"s(Allocation 
Failure)、"+timeValues.get(3)+"s(Ergonomics)";
+    String latestResult = Double.parseDouble(timeValues.get(1)) / 1000 + 
"s(Metadata GC Threshold)";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getGCCPUoverhead(Connection connection) throws 
BaseException {
+    String name = "GC消耗CPU的比例";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.overhead\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    double percent = Double.parseDouble(values.get(1));
+    BigDecimal b = new BigDecimal(percent);
+    double percent1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = percent1 + "%";
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getGCPromoted(Connection connection) throws 
BaseException {
+    String name = "从GC之前到GC之后老年代内存池大小正增长的累计";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.memory.promoted\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = getNetFileSizeDescription((long) 
(Double.parseDouble(values.get(1))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getMajorMemoryMaxValueEver(Connection connection)
+      throws BaseException {
+    String name = "老年代内存的历史最大值";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.max.data.size\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = getNetFileSizeDescription((long) 
(Double.parseDouble(values.get(1))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getMajorMemorySizeAfterGC(Connection connection)
+      throws BaseException {
+    String name = "GC之后老年代内存的大小";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.live.data.size\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = getNetFileSizeDescription((long) 
(Double.parseDouble(values.get(1))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getMinorMemorySizeAddedBetweentwoGC(Connection 
connection)
+      throws BaseException {
+    String name = "在一个GC之后到下一个GC之前年轻代增加的内存";
+    String metricType = "垃圾回收";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.gc.memory.allocated\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = getNetFileSizeDescription((long) 
(Double.parseDouble(values.get(1))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getBufferUsed(Connection connection) throws 
BaseException {
+    String name = "已经使用的缓冲区大小";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.buffer.memory.used\".\"id=mapped\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.buffer.memory.used\".\"id=direct\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count =
+        getNetFileSizeDescription(
+            (long) (Double.parseDouble(values.get(1)) + 
Double.parseDouble(values.get(2))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getMaxBuffer(Connection connection) throws 
BaseException {
+    String name = "最大缓冲区大小";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.buffer.total.capacity\".\"id=mapped\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.buffer.total.capacity\".\"id=direct\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count =
+        getNetFileSizeDescription(
+            (long) (Double.parseDouble(values.get(1)) + 
Double.parseDouble(values.get(2))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getBufferCount(Connection connection) throws 
BaseException {
+    String name = "当前缓冲区数量";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.buffer.count\".\"id=mapped\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.buffer.count\".\"id=direct\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    String s2 = values.get(2);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    s2 = s2.substring(0, s2.indexOf('.'));
+    String latestResult = (Integer.parseInt(s1) + Integer.parseInt(s2)) + "个";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMCommittedMemorySize(Connection connection)
+      throws BaseException {
+    String name = "当前向JVM申请的内存大小";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.committed\".\"area=nonheap\".\"id=Compressed 
Class Space\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.committed\".\"area=nonheap\".\"id=Code Cache\", 
"
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.committed\".\"area=nonheap\".\"id=Metaspace\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.committed\".\"area=heap\".\"id=PS Old Gen\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.committed\".\"area=heap\".\"id=PS Eden Space\", 
"
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.committed\".\"area=heap\".\"id=PS Survivor 
Space\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count =
+        getNetFileSizeDescription(
+            (long)
+                (Double.parseDouble(values.get(1))
+                    + Double.parseDouble(values.get(2))
+                    + Double.parseDouble(values.get(3))
+                    + Double.parseDouble(values.get(4))
+                    + Double.parseDouble(values.get(5))
+                    + Double.parseDouble(values.get(6))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMMemoryMaxSize(Connection connection) 
throws BaseException {
+    String name = "JVM最大内存";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.max\".\"area=nonheap\".\"id=Compressed Class 
Space\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.max\".\"area=nonheap\".\"id=Code Cache\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.max\".\"area=nonheap\".\"id=Metaspace\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.max\".\"area=heap\".\"id=PS Old Gen\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.max\".\"area=heap\".\"id=PS Eden Space\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.max\".\"area=heap\".\"id=PS Survivor Space\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count =
+        getNetFileSizeDescription(
+            (long)
+                (Double.parseDouble(values.get(1))
+                    + Double.parseDouble(values.get(2))
+                    + Double.parseDouble(values.get(3))
+                    + Double.parseDouble(values.get(4))
+                    + Double.parseDouble(values.get(5))
+                    + Double.parseDouble(values.get(6))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMMemoryUsedSize(Connection connection) 
throws BaseException {
+    String name = "JVM已使用内存大小";
+    String metricType = "内存";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.used\".\"area=nonheap\".\"id=Compressed Class 
Space\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.used\".\"area=nonheap\".\"id=Code Cache\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.used\".\"area=nonheap\".\"id=Metaspace\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.used\".\"area=heap\".\"id=PS Old Gen\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.used\".\"area=heap\".\"id=PS Eden Space\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.memory.used\".\"area=heap\".\"id=PS Survivor Space\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count =
+        getNetFileSizeDescription(
+            (long)
+                (Double.parseDouble(values.get(1))
+                    + Double.parseDouble(values.get(2))
+                    + Double.parseDouble(values.get(3))
+                    + Double.parseDouble(values.get(4))
+                    + Double.parseDouble(values.get(5))
+                    + Double.parseDouble(values.get(6))));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = count;
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMUnloadedClassesTotal(Connection connection)
+      throws BaseException {
+    String name = "JVM累计卸载的Class数量";
+    String metricType = "Classes";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.classes.unloaded\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    String latestResult = Integer.parseInt(s1) + "个";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMloadedClassesTotal(Connection connection) 
throws BaseException {
+    String name = "JVM累计加载的Class数量";
+    String metricType = "Classes";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.classes.loaded\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    String latestResult = Integer.parseInt(s1) + "个";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public JVMMetricsListDataVO getJVMCompilationTime(Connection connection) 
throws BaseException {
+    String name = "JVM耗费在编译上的时间";
+    String metricType = "Classes";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"jvm.compilation.time\".\"compiler=HotSpot 64-Bit Tiered 
Compilers\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = values.get(1) + "s";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    JVMMetricsListDataVO jvmMetricsListDataVO = new JVMMetricsListDataVO();
+    jvmMetricsListDataVO.setMetricType(metricType);
+    jvmMetricsListDataVO.setDetailAvailable(detailAvailable);
+    jvmMetricsListDataVO.setLatestResult(latestResult);
+    jvmMetricsListDataVO.setLatestScratchTime(latestScratchTime);
+    jvmMetricsListDataVO.setName(name);
+    return jvmMetricsListDataVO;
+  }
+
+  public MetricsListDataVO getCPUUsed(Connection connection) throws 
BaseException {
+    String name = "CPU使用率";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_cpu_load\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = values.get(1) + "%";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getCPUCores(Connection connection) throws 
BaseException {
+    String name = "CPU核数";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_cpu_cores\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String s1 = values.get(1);
+    s1 = s1.substring(0, s1.indexOf('.'));
+    String latestResult = s1 + "核";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getCPUTime(Connection connection) throws 
BaseException {
+    String name = "CPU Time";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"process_cpu_time\".\"name=process\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String timeStr = values.get(1);
+    long count = Long.parseLong(timeStr.substring(timeStr.indexOf("E") + 1));
+    double time = Double.parseDouble(timeStr.substring(0, 
timeStr.indexOf("E")));
+    while (count > 0) {
+      time *= 10;
+      count--;
+    }
+    String latestResult = (float) (time / 1000000000) + "s";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getTotalMem(Connection connection) throws 
BaseException {
+    String name = "物理内存大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    String str = connection.getHost();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_total_physical_memory_size\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(1)));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getProcessRatio(Connection connection) throws 
BaseException {
+    String name = "IoTDB进程内存占用比例";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"process_mem_ratio\".\"name=process\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    String latestResult = values.get(1) + "%";
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getDiskTotalSize(Connection connection) throws 
BaseException {
+    String name = "磁盘总大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_disk_total_space\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(1)));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getDiskLoadSize(Connection connection) throws 
BaseException {
+    // TODO: 假数据,等待iotdb增加该指标
+    String name = "磁盘挂载";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_disk_total_space\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    //    String latestResult = 
getNetFileSizeDescription((long)Double.parseDouble(values.get(1)));
+    String latestResult = "【假数据:指标暂缺】2G";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getDiskAvailableSize(Connection connection) throws 
BaseException {
+    String name = "磁盘剩余";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_disk_free_space\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String latestResult = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(1)));
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getDiskIO(Connection connection) throws 
BaseException {
+    String name = "磁盘IO吞吐";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"sys_disk_free_space\".\"name=system\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    //    String latestResult = 
getNetFileSizeDescription((long)Double.parseDouble(values.get(1)));
+    String latestResult = "【假数据:指标暂缺】136K/s";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getWalFileCountAndSize(Connection connection) 
throws BaseException {
+    String name = "wal日志文件数量及大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=wal\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=wal\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "数量:" + count + ";" + "大小:" + size;
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getSeqTSFileCountAndSize(Connection connection) 
throws BaseException {
+    String name = "顺序TsFile文件数量及大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=seq\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=seq\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "数量:" + count + ";" + "大小:" + size;
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getUnSeqTSFileCountAndSize(Connection connection) 
throws BaseException {
+    String name = "乱序TsFile文件数量及大小";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=unseq\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=unseq\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "数量:" + count + ";" + "大小:" + size;
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getWriteDelay(Connection connection) throws 
BaseException {
+    String name = "写入延迟(最近一分钟)";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=unseq\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=unseq\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "【假数据:指标暂缺】" + "90" + "%";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getWriteSucceedCount(Connection connection) throws 
BaseException {
+    String name = "查询成功次数(最近1分钟)";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=unseq\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=unseq\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "【假数据:指标暂缺】" + "100" + "次";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getWriteFailedCount(Connection connection) throws 
BaseException {
+    String name = "查询失败次数(最近1分钟)";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=unseq\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=unseq\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "【假数据:指标暂缺】" + "20" + "次";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  public MetricsListDataVO getWriteSucceedRatio(Connection connection) throws 
BaseException {
+    String name = "查询成功率";
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Integer detailAvailable = 0;
+    int port = connection.getPort();
+    // TODO bug 修复后删除
+    if (port == 6668) {
+      port = 8086;
+    }
+    String sql =
+        "select * from "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_count\".\"name=unseq\", "
+            + "root._metric.\"127.0.0.1:"
+            + port
+            + "\".\"file_size\".\"name=unseq\" "
+            + "order by time desc limit 1";
+    SessionPool sessionPool = getSessionPool(connection);
+    List<String> values = executeQueryOneLine(sessionPool, sql);
+    long lastestTimeStamp = Long.parseLong(values.get(0));
+    String count = values.get(1);
+    count = count.substring(0, count.indexOf('.'));
+    String size = getNetFileSizeDescription((long) 
Double.parseDouble(values.get(2)));
+    String latestResult = "【假数据:指标暂缺】" + "80" + "%";
+    String latestScratchTime = simpleDateFormat.format(lastestTimeStamp);
+    MetricsListDataVO metricsListDataVO = new MetricsListDataVO();
+    metricsListDataVO.setDetailAvailable(detailAvailable);
+    metricsListDataVO.setLatestResult(latestResult);
+    metricsListDataVO.setLatestScratchTime(latestScratchTime);
+    metricsListDataVO.setName(name);
+    return metricsListDataVO;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getJVMMetricsDataList(Connection connection) 
throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    list.add(getCurrentThreadsCount(connection));
+    list.add(getCurrentDaemonThreadsCount(connection));
+    list.add(getPeakThreadsCount(connection));
+    list.add(getVariableThreadsCount(connection));
+    list.add(getYGCHappendCountAndCostTime(connection));
+    list.add(getYGCMaxCostTimeAndReason(connection));
+    list.add(getFGCHappendCountAndCostTime(connection));
+    list.add(getFGCMaxCostTimeAndReason(connection));
+    list.add(getGCCPUoverhead(connection));
+    list.add(getGCPromoted(connection));
+    list.add(getMajorMemoryMaxValueEver(connection));
+    list.add(getMajorMemorySizeAfterGC(connection));
+    list.add(getMinorMemorySizeAddedBetweentwoGC(connection));
+    list.add(getBufferUsed(connection));
+    list.add(getMaxBuffer(connection));
+    list.add(getBufferCount(connection));
+    list.add(getJVMCommittedMemorySize(connection));
+    list.add(getJVMMemoryMaxSize(connection));
+    list.add(getJVMMemoryUsedSize(connection));
+    list.add(getJVMUnloadedClassesTotal(connection));
+    list.add(getJVMloadedClassesTotal(connection));
+    list.add(getJVMCompilationTime(connection));
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getCPUMetricsDataList(Connection connection) 
throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    list.add(getCPUCores(connection));
+    list.add(getCPUUsed(connection));
+    list.add(getCPUTime(connection));
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getMemMetricsDataList(Connection connection) 
throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    list.add(getTotalMem(connection));
+    list.add(getProcessRatio(connection));
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getDiskMetricsDataList(Connection connection)
+      throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    list.add(getDiskTotalSize(connection));
+    list.add(getDiskLoadSize(connection));
+    list.add(getDiskAvailableSize(connection));
+    list.add(getDiskIO(connection));
+    list.add(getWalFileCountAndSize(connection));
+    list.add(getSeqTSFileCountAndSize(connection));
+    list.add(getUnSeqTSFileCountAndSize(connection));
+    return list;
+  }
+
+  @Override
+  public List<MetricsListDataVO> getWriteMetricsDataList(Connection connection)
+      throws BaseException {
+    List<MetricsListDataVO> list = new ArrayList<>();
+    list.add(getWriteDelay(connection));
+    list.add(getWriteSucceedCount(connection));
+    list.add(getWriteFailedCount(connection));
+    list.add(getWriteFailedCount(connection));
+    list.add(getWriteSucceedRatio(connection));
+    return list;
+  }
+
+  @Override
+  public MetircsQueryClassificationVO getMetircsQueryClassification(Integer 
serverId) {
+    // TODO:等待清华提供查询分类的接口
+    List<QueryClassificationVO> fakeData = new ArrayList<>();
+    for (int i = 0; i < 6; i++) {
+      QueryClassificationVO queryClassificationVO = new 
QueryClassificationVO();
+      queryClassificationVO.setId(i + 1);
+      queryClassificationVO.setName("查询分类" + (i + 1));
+      queryClassificationVO.setFlag(i % 2 == 0 ? 1 : 0);
+      fakeData.add(queryClassificationVO);
+    }
+    MetircsQueryClassificationVO metircsQueryClassificationVO = new 
MetircsQueryClassificationVO();
+    metircsQueryClassificationVO.setServerId(serverId);
+    metircsQueryClassificationVO.setClassificationList(fakeData);
+    return metircsQueryClassificationVO;
+  }
+
+  @Override
+  public QueryInfoVO getQueryInfo(
+      Integer serverId,
+      Integer queryClassificationId,
+      Integer pageSize,
+      Integer pageNum,
+      String filterString,
+      String startTimeStr,
+      String endTimeStr,
+      Integer executionResult)
+      throws BaseException {
+    long startTime = Long.parseLong(startTimeStr);
+    long endTime = Long.parseLong(endTimeStr);
+    Connection connection = connectionService.getById(serverId);
+    QueryInfoDTO queryInfoDTO =
+        iotDBService.getQueryInfoListByQueryClassificationId(
+            connection,
+            queryClassificationId,
+            pageSize,
+            pageNum,
+            filterString,
+            startTime,
+            endTime,
+            executionResult);
+    QueryInfoVO queryInfoVO = new QueryInfoVO();
+    queryInfoVO.setQueryClassificationId(queryClassificationId);
+    String pattern = "yyyy-MM-dd' 'HH:mm:ss.SSS";
+    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
+    Long latestRunningTime = queryInfoDTO.getLatestRunningTime();
+    queryInfoVO.setLatestRunningTime(
+        latestRunningTime == 0 ? null : 
simpleDateFormat.format(latestRunningTime));
+    BeanUtils.copyProperties(queryInfoDTO, queryInfoVO);
+    queryInfoVO.setServerId(serverId);
+    return queryInfoVO;
+  }
+
+  @Override
+  public MetricsDataCountVO getMetricsDataCount(Integer serverId) throws 
BaseException {
+    Connection connection = connectionService.getById(serverId);
+    DataCountVO dataCountVO = new DataCountVO();
+    MetricsDataCountVO metricsDataCountVO = new MetricsDataCountVO();
+    DataCountVO dataCount = new DataCountVO();
+    try {
+      dataCount = iotDBService.getDataCount(connection);
+      metricsDataCountVO.setStatus(true);
+    } catch (BaseException e) {
+      metricsDataCountVO.setStatus(false);
+    }
+    metricsDataCountVO.setServerId(serverId);
+    metricsDataCountVO.setUrl(connection.getHost());
+    metricsDataCountVO.setPort(connection.getPort());
+    BeanUtils.copyProperties(dataCount, metricsDataCountVO);
+    metricsDataCountVO.setDataCount(dataCount.getDataCount());
+    return metricsDataCountVO;
+  }
+
+  @Override
+  public MetricsDataForListVO getMetricsDataForList(Integer serverId, Integer 
metricsType)
+      throws BaseException {
+    Connection connection = connectionService.getById(serverId);
+    List<MetricsListDataVO> metricsDataList = null;
+    // TODO:具体区分和判断等待清华提供方案和策略
+    switch (metricsType) {
+      case 0:
+        metricsDataList = getJVMMetricsDataList(connection);
+        break;
+      case 1:
+        metricsDataList = getCPUMetricsDataList(connection);
+        break;
+      case 2:
+        metricsDataList = getMemMetricsDataList(connection);
+        break;
+      case 3:
+        metricsDataList = getDiskMetricsDataList(connection);
+        break;
+      case 4:
+        metricsDataList = getWriteMetricsDataList(connection);
+        break;
+    }
+    MetricsDataForListVO metricsDataForListVO = new MetricsDataForListVO();
+    metricsDataForListVO.setServerId(serverId);
+    metricsDataForListVO.setMetricsType(metricsType);
+    metricsDataForListVO.setListInfo(metricsDataList);
+    return metricsDataForListVO;
+  }
+
+  public static SessionPool getSessionPool(Connection connection) throws 
BaseException {
+    String host = connection.getHost();
+    Integer port = connection.getPort();
+    String username = connection.getUsername();
+    String password = connection.getPassword();
+    SessionPool sessionPool = null;
+    try {
+      sessionPool = new SessionPool(host, port, username, password, 3);
+    } catch (Exception e) {
+      throw new BaseException(ErrorCode.GET_SESSION_FAIL, 
ErrorCode.GET_SESSION_FAIL_MSG);
+    }
+    return sessionPool;
+  }
+
+  private List<String> executeQueryOneLine(SessionPool sessionPool, String sql)
+      throws BaseException {
+    SessionDataSetWrapper sessionDataSetWrapper = null;
+    try {
+      List<String> valueList = new ArrayList<>();
+      sessionDataSetWrapper = sessionPool.executeQueryStatement(sql);
+      if (sessionDataSetWrapper.hasNext()) {
+        RowRecord rowRecord = sessionDataSetWrapper.next();
+        valueList.add(rowRecord.getTimestamp() + "");
+        List<org.apache.iotdb.tsfile.read.common.Field> fields = 
rowRecord.getFields();
+        for (org.apache.iotdb.tsfile.read.common.Field field : fields) {
+          valueList.add(field.toString());
+        }
+      }
+      return valueList;
+    } catch (IoTDBConnectionException e) {
+      logger.error(e.getMessage());
+      throw new BaseException(ErrorCode.GET_SESSION_FAIL, 
ErrorCode.GET_SESSION_FAIL_MSG);
+    } catch (StatementExecutionException e) {
+      logger.error(e.getMessage());
+      throw new BaseException(ErrorCode.SQL_EP, ErrorCode.SQL_EP_MSG);
+    } finally {
+      closeResultSet(sessionDataSetWrapper);
+    }
+  }
+
+  private void closeSessionPool(SessionPool sessionPool) {
+    if (sessionPool != null) {
+      sessionPool.close();
+    }
+  }
+
+  private void closeResultSet(SessionDataSetWrapper sessionDataSetWrapper) {
+    if (sessionDataSetWrapper != null) {
+      sessionDataSetWrapper.close();
+    }
+  }
+
+  private static String getNetFileSizeDescription(long size) {
+    StringBuffer bytes = new StringBuffer();
+    DecimalFormat format = new DecimalFormat("###.0");
+    if (size >= 1024 * 1024 * 1024) {
+      double i = (size / (1024.0 * 1024.0 * 1024.0));
+      bytes.append(format.format(i)).append("GB");
+    } else if (size >= 1024 * 1024) {
+      double i = (size / (1024.0 * 1024.0));
+      bytes.append(format.format(i)).append("MB");
+    } else if (size >= 1024) {
+      double i = (size / (1024.0));
+      bytes.append(format.format(i)).append("KB");
+    } else if (size < 1024) {
+      if (size <= 0) {
+        bytes.append("0B");
+      } else {
+        bytes.append((int) size).append("B");
+      }
+    }
+    return bytes.toString();
+  }
+}

Reply via email to