|
@@ -12,6 +12,7 @@ import org.dbsyncer.biz.model.Sample;
|
|
import org.dbsyncer.biz.vo.AppReportMetricVo;
|
|
import org.dbsyncer.biz.vo.AppReportMetricVo;
|
|
import org.dbsyncer.biz.vo.HistoryStackVo;
|
|
import org.dbsyncer.biz.vo.HistoryStackVo;
|
|
import org.dbsyncer.biz.vo.RestResult;
|
|
import org.dbsyncer.biz.vo.RestResult;
|
|
|
|
+import org.dbsyncer.common.metric.TimeRegistry;
|
|
import org.dbsyncer.common.util.CollectionUtils;
|
|
import org.dbsyncer.common.util.CollectionUtils;
|
|
import org.dbsyncer.common.util.DateFormatUtil;
|
|
import org.dbsyncer.common.util.DateFormatUtil;
|
|
import org.dbsyncer.manager.impl.PreloadTemplate;
|
|
import org.dbsyncer.manager.impl.PreloadTemplate;
|
|
@@ -47,6 +48,7 @@ public class MonitorController extends BaseController {
|
|
private final static int COUNT = 24;
|
|
private final static int COUNT = 24;
|
|
private HistoryStackVo cpu = new HistoryStackVo();
|
|
private HistoryStackVo cpu = new HistoryStackVo();
|
|
private HistoryStackVo memory = new HistoryStackVo();
|
|
private HistoryStackVo memory = new HistoryStackVo();
|
|
|
|
+ private HistoryStackVo tps = new HistoryStackVo();
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private MonitorService monitorService;
|
|
private MonitorService monitorService;
|
|
@@ -75,6 +77,9 @@ public class MonitorController extends BaseController {
|
|
@Resource
|
|
@Resource
|
|
private HistoryStackValueFormatter memoryHistoryStackValueFormatterImpl;
|
|
private HistoryStackValueFormatter memoryHistoryStackValueFormatterImpl;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private TimeRegistry timeRegistry;
|
|
|
|
+
|
|
@RequestMapping("")
|
|
@RequestMapping("")
|
|
public String index(HttpServletRequest request, ModelMap model) {
|
|
public String index(HttpServletRequest request, ModelMap model) {
|
|
Map<String, String> params = getParams(request);
|
|
Map<String, String> params = getParams(request);
|
|
@@ -97,6 +102,7 @@ public class MonitorController extends BaseController {
|
|
public void recordHistoryStackMetric() {
|
|
public void recordHistoryStackMetric() {
|
|
recordHistoryStackMetric(MetricEnum.CPU_USAGE, cpu, cpuHistoryStackValueFormatterImpl);
|
|
recordHistoryStackMetric(MetricEnum.CPU_USAGE, cpu, cpuHistoryStackValueFormatterImpl);
|
|
recordHistoryStackMetric(MetricEnum.MEMORY_USED, memory, memoryHistoryStackValueFormatterImpl);
|
|
recordHistoryStackMetric(MetricEnum.MEMORY_USED, memory, memoryHistoryStackValueFormatterImpl);
|
|
|
|
+ addHistoryStack(tps, timeRegistry.meter(TimeRegistry.GENERAL_BUFFER_ACTUATOR_TPS).getSecondsRate());
|
|
}
|
|
}
|
|
|
|
|
|
@Scheduled(fixedRate = 10000)
|
|
@Scheduled(fixedRate = 10000)
|
|
@@ -184,6 +190,7 @@ public class MonitorController extends BaseController {
|
|
AppReportMetricVo reportMetric = monitorService.queryAppReportMetric(list);
|
|
AppReportMetricVo reportMetric = monitorService.queryAppReportMetric(list);
|
|
reportMetric.setCpu(cpu);
|
|
reportMetric.setCpu(cpu);
|
|
reportMetric.setMemory(memory);
|
|
reportMetric.setMemory(memory);
|
|
|
|
+ reportMetric.setTps(tps);
|
|
return RestResult.restSuccess(reportMetric);
|
|
return RestResult.restSuccess(reportMetric);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.error(e.getLocalizedMessage(), e.getClass());
|
|
logger.error(e.getLocalizedMessage(), e.getClass());
|
|
@@ -243,11 +250,15 @@ public class MonitorController extends BaseController {
|
|
MetricResponse metricResponse = getMetricResponse(metricEnum.getCode());
|
|
MetricResponse metricResponse = getMetricResponse(metricEnum.getCode());
|
|
List<Sample> measurements = metricResponse.getMeasurements();
|
|
List<Sample> measurements = metricResponse.getMeasurements();
|
|
if (!CollectionUtils.isEmpty(measurements)) {
|
|
if (!CollectionUtils.isEmpty(measurements)) {
|
|
- addHistoryStack(stackVo.getValue(), formatter.formatValue(measurements.get(0).getValue()));
|
|
|
|
- addHistoryStack(stackVo.getName(), DateFormatUtil.getCurrentTime());
|
|
|
|
|
|
+ addHistoryStack(stackVo, formatter.formatValue(measurements.get(0).getValue()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void addHistoryStack(HistoryStackVo stackVo, Object value) {
|
|
|
|
+ addHistoryStack(stackVo.getValue(), value);
|
|
|
|
+ addHistoryStack(stackVo.getName(), DateFormatUtil.getCurrentTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
private void addHistoryStack(List<Object> stack, Object value) {
|
|
private void addHistoryStack(List<Object> stack, Object value) {
|
|
if (stack.size() >= COUNT) {
|
|
if (stack.size() >= COUNT) {
|
|
stack.remove(0);
|
|
stack.remove(0);
|