服务监控讲解
前端
ruoyi-ui/src/views/monitor/server/index.vue
接口
ruoyi-ui/src/api/monitor/server.js
import request from '@/utils/request'
// 获取服务信息
export function getServer() {
return request({
url: '/monitor/server',
method: 'get'
})
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
后端
pom.xml
使用的一个开源包
<!-- 获取系统信息 -->
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>${oshi.version}</version>
</dependency>
1
2
3
4
5
6
2
3
4
5
6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java
**
* 服务器监控
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/server")
public class ServerController
{
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Server server = new Server();
server.copyTo(); //// 数据填充
return AjaxResult.success(server);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
上次更新: 2025/04/03, 11:07:08