sevMonitor.js
10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
import React,{Component} from 'react';
import './style.less';
import WhiteBar from '../../components/Common/WhiteBar';
import {Row,Col,Table,Icon} from 'antd';
import { API_SYS_MONITOR } from '@src/Api';
import axios from '@src/axios/index';
export default class AccessLog extends Component {
state = {
serverInfo: {}
}
componentDidMount () {
this.getServerInfo();
}
// 获取服务器信息
getServerInfo = () => {
axios.ajax({
url: API_SYS_MONITOR.getServerInfo,
}).then((res) => {
res.diskStats = res.diskStats.map((item,index) => {
return {...item,key:index}
});
this.setState({serverInfo: res});
});
}
render () {
const columns = [
{title: '序号', dataIndex: 'key', key: 'key', render: (key) => {
return key + 1;
}},
{title: '盘符路径', dataIndex: 'diskPath', key: 'diskPath'},
{title: '文件系统', dataIndex: 'fileSystem', key: 'fileSystem'},
{title: '盘符类型', dataIndex: 'diskType', key: 'diskType'},
{title: '总大小', dataIndex: 'allSpace', key: 'allSpace'},
{title: '可用大小', dataIndex: 'availableSpace', key: 'availableSpace'},
{title: '已用大小', dataIndex: 'usedSpace', key: 'usedSpace'},
{title: '已用百分百', dataIndex: 'usedPct', key: 'usedPct'}
];
const serverInfo = this.state.serverInfo;
return (
<div className="com-sevMonitor">
<WhiteBar title="服务器监控" />
<div className="panel-wrapper">
<Row gutter={16}>
<Col span={8}>
<Panel
title="CUP"
icon="iconfont icon-cpu"
background="linear-gradient(86deg,rgba(9,141,239,1),rgba(45,159,242,1))">
<ul>
<li className="title clear">
<p className="f_left">属性</p>
<p className="f_right">值</p>
</li>
<li className="clear">
<p className="item f_left">核心数</p>
<p className="f_right">{serverInfo.cpuNum}个</p>
</li>
<li className="clear">
<p className="item f_left">最大功率</p>
<p className="f_right">{serverInfo.cpuMaxGhz}</p>
</li>
<li className="clear">
<p className="item f_left">实时功率</p>
<p className="f_right">{serverInfo.cpuNowGhz}</p>
</li>
<li className="clear">
<p className="item f_left">使用率</p>
<p className="f_right">{serverInfo.cpuPct}</p>
</li>
</ul>
</Panel>
</Col>
<Col span={8}>
<Panel
title="内存"
icon="iconfont icon-neicun"
background="linear-gradient(86deg,rgba(73,209,183,1),rgba(97,235,213,1))">
<ul>
<li className="title clear">
<p className="w_30">属性</p>
<p className="w_30">内存</p>
<p className="w_30">JVM</p>
</li>
<li className="clear">
<p className="item w_30">总内存</p>
<p className="w_30">{serverInfo.memAll}</p>
<p className="w_30">{serverInfo.jvmAll}</p>
</li>
<li className="clear">
<p className="item w_30">剩余内存</p>
<p className="w_30">{serverInfo.memRest}</p>
<p className="w_30">{serverInfo.jvmRest}</p>
</li>
<li className="clear">
<p className="item w_30">已用内存</p>
<p className="w_30">{serverInfo.memUsed}</p>
<p className="w_30">{serverInfo.jvmUsed}</p>
</li>
<li className="clear">
<p className="item w_30">使用率</p>
<p className="w_30">{serverInfo.memPct}</p>
<p className="w_30">{serverInfo.jvmPct}</p>
</li>
</ul>
</Panel>
</Col>
<Col span={8}>
<Panel
title="堆/堆栈"
icon="iconfont icon-dui"
background="linear-gradient(86deg,rgba(254,156,12,1),rgba(252,194,59,1))">
<ul>
<li className="title clear">
<p className="w_30">属性</p>
<p className="w_30">堆</p>
<p className="w_30">堆栈</p>
</li>
<li className="clear">
<p className="item w_30">初始大小</p>
<p className="w_30">{serverInfo.heapInit}</p>
<p className="w_30">{serverInfo.nonHeapInit}</p>
</li>
<li className="clear">
<p className="item w_30">最大内存</p>
<p className="w_30">{serverInfo.heapMaxMem}</p>
<p className="w_30">{serverInfo.nonHeapMaxMem}</p>
</li>
<li className="clear">
<p className="item w_30">已用内存</p>
<p className="w_30">{serverInfo.heapUsedMem}</p>
<p className="w_30">{serverInfo.nonHeapUsedMem}</p>
</li>
<li className="clear">
<p className="item w_30">可用内存</p>
<p className="w_30">{serverInfo.heapAvailableMem}</p>
<p className="w_30">{serverInfo.nonHeapAvailableMem}</p>
</li>
</ul>
</Panel>
</Col>
</Row>
<Row gutter={16} style={{marginTop: 20}}>
<Col span={12}>
<Panel
title="服务信息"
icon="iconfont icon-server"
background="linear-gradient(90deg,rgba(86,104,219,1),rgba(125,139,226,1))">
<ul>
<li className="clear">
<p className="item f_left">服务器名称</p>
<p className="f_right">{serverInfo.serverName}</p>
</li>
<li className="clear">
<p className="item f_left">服务器IP</p>
<p className="f_right">{serverInfo.serverIp}</p>
</li>
<li className="clear">
<p className="item f_left">操作系统</p>
<p className="f_right">{serverInfo.operationName}</p>
</li>
<li className="clear">
<p className="item f_left">系统架构</p>
<p className="f_right">{serverInfo.systemArch}</p>
</li>
</ul>
</Panel>
</Col>
<Col span={12}>
<Panel
title="平台参数"
icon="iconfont icon-argu"
background="linear-gradient(90deg,rgba(86,104,219,1),rgba(125,139,226,1))">
<ul>
<li className="clear">
<p className="item f_left">当前工作路径</p>
<p className="f_right">{serverInfo.currentWorkPath}</p>
</li>
<li className="clear">
<p className="item f_left">日志存放路径</p>
<p className="f_right">{serverInfo.logSavePath}</p>
</li>
<li className="clear">
<p className="item f_left">上传文件路径</p>
<p className="f_right">{serverInfo.uploadFilePath}</p>
</li>
<li className="clear">
<p className="item f_left">系统架构</p>
<p className="f_right">{serverInfo.systemArch}</p>
</li>
</ul>
</Panel>
</Col>
</Row>
<Row style={{marginTop: 20}}>
<Col span={24}>
<Panel
title="java虚拟机问题"
icon="iconfont icon-xuniji"
background="linear-gradient(90deg,rgba(86,104,219,1),rgba(125,139,226,1))">
<ul>
<li>
<p className="w_50">
<span className="item mr_50">java名称</span>
<span>{serverInfo.javaName}</span>
</p>
<p className="w_50">
<span className="item mr_50">java版本</span>
<span>{serverInfo.javaVersion}</span>
</p>
</li>
<li>
<p className="w_50">
<span className="item mr_50">启动时间</span>
<span>{serverInfo.startTime}</span>
</p>
<p className="w_50">
<span className="item mr_50">运行时长</span>
<span>{serverInfo.runTime}</span>
</p>
</li>
<li>
<p className="w_50">
<span className="item mr_50">安装路径</span>
<span>{serverInfo.javaHome}</span>
</p>
<p className="w_50">
<span className="item mr_50">启动参数</span>
<span>{serverInfo.startParam}</span>
</p>
</li>
</ul>
</Panel>
</Col>
</Row>
<Row style={{marginTop: 20,marginBottom: 30}}>
<Panel
title="磁盘状态"
icon="iconfont icon-cipan"
background="linear-gradient(90deg,rgba(86,104,219,1),rgba(125,139,226,1))">
<Table
dataSource={serverInfo.diskStats}
pagination={{hideOnSinglePage: true}}
columns={columns}>
</Table>
</Panel>
</Row>
</div>
</div>
);
}
}
// 面板组件
class Panel extends Component {
state = {
// true 展开 false 折叠
collapse: true,
// 样式控制
textStyle: {
background: '#fff',
padding: 15,
transition: 'all ease .3s',
overflow: 'hidden'
},
// iconstyle
iconStyle: {
float: 'right',
marginTop: 12,
transition: 'transform ease .3s',
}
}
// 点击事件
handleCollapse () {
if (this.state.collapse) {
// 折叠起来
this.setState({
collapse: false,
textStyle: {
background: '#fff',
padding: 0,
transition: 'all ease .3s',
height: 0,
overflow: 'hidden'
},
iconStyle: {
float: 'right',
marginTop: 12,
transition: 'transform ease .3s',
transform: 'rotate(90deg)'
}
});
} else {
// 展开
this.setState({
collapse: true,
textStyle: {
background: '#fff',
padding: 15,
transition: 'all ease .3s',
overflow: 'hidden'
},
iconStyle: {
float: 'right',
marginTop: 12,
transition: 'transform ease .3s'
}
});
}
}
render () {
const headerStyle = {
width: '100%',
height: '42px',
lineHeight: '42px',
background: this.props.background,
color: '#fff',
paddingLeft: 20,
paddingRight: 20,
cursor: 'pointer'
};
return (
<div>
<div onClick={this.handleCollapse.bind(this)} style={{...headerStyle}} className="header">
<span style={{fontSize: 30,verticalAlign:'middle',marginRight: 5}} className={this.props.icon}></span>
{this.props.title}
<Icon style={{...this.state.iconStyle}} type="caret-down" theme="filled" />
</div>
<div style={{...this.state.textStyle}} className="textWrapper">
{this.props.children}
</div>
</div>
);
}
}