|
@@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
import type { EChartsOption } from 'echarts';
|
|
import type { EChartsOption } from 'echarts';
|
|
|
import { useRequest } from 'umi';
|
|
import { useRequest } from 'umi';
|
|
|
import Service from './service';
|
|
import Service from './service';
|
|
|
|
|
+import moment from 'moment';
|
|
|
|
|
|
|
|
type RefType = {
|
|
type RefType = {
|
|
|
getValues: Function;
|
|
getValues: Function;
|
|
@@ -24,13 +25,47 @@ export default () => {
|
|
|
formatResult: (res) => res.result.map((item: any) => ({ label: item.name, value: item.id })),
|
|
formatResult: (res) => res.result.map((item: any) => ({ label: item.name, value: item.id })),
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const getFormValues = () => {
|
|
|
|
|
|
|
+ const getNetworkEcharts = () => {
|
|
|
const data = NETWORKRef.current!.getValues();
|
|
const data = NETWORKRef.current!.getValues();
|
|
|
- console.log(data);
|
|
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ service.queryMulti([
|
|
|
|
|
+ {
|
|
|
|
|
+ dashboard: 'systemMonitor',
|
|
|
|
|
+ object: 'network',
|
|
|
|
|
+ measurement: 'traffic',
|
|
|
|
|
+ dimension: 'agg',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ type: data.type,
|
|
|
|
|
+ interval: '1h',
|
|
|
|
|
+ from: moment(data.time[0]).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
+ to: moment(data.time[1]).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const getCPUEcharts = () => {
|
|
|
|
|
+ const data = CPURef.current!.getValues();
|
|
|
|
|
+ if (data) {
|
|
|
|
|
+ service.queryMulti([
|
|
|
|
|
+ {
|
|
|
|
|
+ dashboard: 'systemMonitor',
|
|
|
|
|
+ object: 'cpu',
|
|
|
|
|
+ measurement: 'traffic',
|
|
|
|
|
+ dimension: 'agg',
|
|
|
|
|
+ params: {
|
|
|
|
|
+ type: data.type,
|
|
|
|
|
+ interval: '1h',
|
|
|
|
|
+ from: moment(data.time[0]).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
+ to: moment(data.time[1]).format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const getEcharts = async (data: any) => {
|
|
|
|
|
- console.log(data);
|
|
|
|
|
|
|
+ const getEcharts = async () => {
|
|
|
setOptions({
|
|
setOptions({
|
|
|
xAxis: {
|
|
xAxis: {
|
|
|
type: 'category',
|
|
type: 'category',
|
|
@@ -50,7 +85,7 @@ export default () => {
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (serverId) {
|
|
if (serverId) {
|
|
|
- getFormValues();
|
|
|
|
|
|
|
+ getNetworkEcharts();
|
|
|
}
|
|
}
|
|
|
}, [serverId]);
|
|
}, [serverId]);
|
|
|
|
|
|
|
@@ -91,7 +126,7 @@ export default () => {
|
|
|
}}
|
|
}}
|
|
|
defaultTime={'week'}
|
|
defaultTime={'week'}
|
|
|
options={options}
|
|
options={options}
|
|
|
- onParamsChange={getEcharts}
|
|
|
|
|
|
|
+ onParamsChange={getNetworkEcharts}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<div style={{ display: 'flex' }}>
|
|
<div style={{ display: 'flex' }}>
|
|
@@ -102,7 +137,7 @@ export default () => {
|
|
|
height={400}
|
|
height={400}
|
|
|
defaultTime={'week'}
|
|
defaultTime={'week'}
|
|
|
options={options}
|
|
options={options}
|
|
|
- onParamsChange={getEcharts}
|
|
|
|
|
|
|
+ onParamsChange={getCPUEcharts}
|
|
|
/>
|
|
/>
|
|
|
<DashBoard
|
|
<DashBoard
|
|
|
title={'JVM内存使用率趋势'}
|
|
title={'JVM内存使用率趋势'}
|