46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
package net.geedge.confagent.controller;
|
|
|
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import net.geedge.confagent.util.OSHIUtils;
|
|
import net.geedge.confagent.util.R;
|
|
import net.geedge.confagent.util.Tool;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.net.UnknownHostException;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@RestController
|
|
public class OSHIController extends BaseController{
|
|
|
|
@GetMapping("/oshi/info")
|
|
public R getSystemInfo(HttpServletRequest request){
|
|
|
|
Map<String, Object> systemInfo = OSHIUtils.getSystemInfo();
|
|
|
|
return R.ok(systemInfo);
|
|
}
|
|
|
|
@GetMapping("/oshi/process")
|
|
public R getProcessInfo(HttpServletRequest request) throws InterruptedException {
|
|
|
|
List<Map> result = OSHIUtils.getProcessInfo();
|
|
HashMap<Object, Object> data = Tool.MapUtil.newHashMap();
|
|
data.put("list" ,result);
|
|
|
|
return R.ok(data);
|
|
}
|
|
|
|
@GetMapping("/oshi/netstat")
|
|
public R getNetstatInfo(HttpServletRequest request) throws UnknownHostException {
|
|
List<Map> result = OSHIUtils.getNetInfo();
|
|
HashMap<Object, Object> data = Tool.MapUtil.newHashMap();
|
|
data.put("list" ,result);
|
|
|
|
return R.ok(data);
|
|
}
|
|
}
|