|
|
@@ -11,8 +11,8 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
|
|
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
|
|
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
|
|
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
|
|
-import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
|
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
|
|
+import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
|
|
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
|
|
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
|
|
@@ -25,13 +25,24 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
+import oshi.SystemInfo;
|
|
|
+import oshi.hardware.CentralProcessor;
|
|
|
+import oshi.hardware.GlobalMemory;
|
|
|
+import oshi.hardware.HardwareAbstractionLayer;
|
|
|
+import oshi.hardware.NetworkIF;
|
|
|
+import oshi.software.os.OperatingSystem;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
@Tag(name = "服务控制")
|
|
|
@@ -75,7 +86,6 @@ public class ServerController {
|
|
|
private IRedisCatchStorage redisCatchStorage;
|
|
|
|
|
|
|
|
|
-
|
|
|
@GetMapping(value = "/media_server/list")
|
|
|
@ResponseBody
|
|
|
@Operation(summary = "流媒体服务列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
|
|
@@ -140,7 +150,7 @@ public class ServerController {
|
|
|
@ResponseBody
|
|
|
public void deleteMediaServer(@RequestParam String id) {
|
|
|
MediaServer mediaServer = mediaServerService.getOne(id);
|
|
|
- if(mediaServer == null) {
|
|
|
+ if (mediaServer == null) {
|
|
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "流媒体不存在");
|
|
|
}
|
|
|
mediaServerService.delete(mediaServer);
|
|
|
@@ -170,9 +180,11 @@ public class ServerController {
|
|
|
// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
|
|
// }
|
|
|
// });
|
|
|
- };
|
|
|
+ }
|
|
|
+
|
|
|
+ ;
|
|
|
|
|
|
- @Operation(summary = "获取系统信息信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
|
|
+ @Operation(summary = "获取系统配置信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
|
|
@GetMapping(value = "/system/configInfo")
|
|
|
@ResponseBody
|
|
|
public SystemConfigInfo getConfigInfo() {
|
|
|
@@ -234,7 +246,7 @@ public class ServerController {
|
|
|
List<MediaServer> allOnline = mediaServerService.getAllOnline();
|
|
|
if (allOnline.isEmpty()) {
|
|
|
return result;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
for (MediaServer mediaServerItem : allOnline) {
|
|
|
result.add(mediaServerService.getLoad(mediaServerItem));
|
|
|
}
|
|
|
@@ -258,4 +270,80 @@ public class ServerController {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping(value = "/info")
|
|
|
+ @ResponseBody
|
|
|
+ @Operation(summary = "获取系统信息")
|
|
|
+ public Map<String, Map<String, String>> getInfo() {
|
|
|
+ Map<String, Map<String, String>> result = new LinkedHashMap<>();
|
|
|
+ Map<String, String> hardwareMap = new LinkedHashMap<>();
|
|
|
+ result.put("硬件信息", hardwareMap);
|
|
|
+
|
|
|
+ SystemInfo systemInfo = new SystemInfo();
|
|
|
+ HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
|
|
+ // 获取CPU信息
|
|
|
+ CentralProcessor.ProcessorIdentifier processorIdentifier = hardware.getProcessor().getProcessorIdentifier();
|
|
|
+ hardwareMap.put("CPU", processorIdentifier.getName());
|
|
|
+ // 获取内存
|
|
|
+ GlobalMemory memory = hardware.getMemory();
|
|
|
+ hardwareMap.put("内存", formatByte(memory.getTotal() - memory.getAvailable()) + "/" + formatByte(memory.getTotal()));
|
|
|
+ hardwareMap.put("制造商", systemInfo.getHardware().getComputerSystem().getManufacturer());
|
|
|
+ hardwareMap.put("产品名称", systemInfo.getHardware().getComputerSystem().getModel());
|
|
|
+ // 网卡
|
|
|
+ List<NetworkIF> networkIFs = hardware.getNetworkIFs();
|
|
|
+ StringBuilder ips = new StringBuilder();
|
|
|
+ for (int i = 0; i < networkIFs.size(); i++) {
|
|
|
+ NetworkIF networkIF = networkIFs.get(i);
|
|
|
+ String ipsStr = StringUtils.join(networkIF.getIPv4addr());
|
|
|
+ if (ObjectUtils.isEmpty(ipsStr)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ips.append(ipsStr);
|
|
|
+ if (i < networkIFs.size() - 1) {
|
|
|
+ ips.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ hardwareMap.put("网卡", ips.toString());
|
|
|
+
|
|
|
+ Map<String, String> operatingSystemMap = new LinkedHashMap<>();
|
|
|
+ result.put("操作系统", operatingSystemMap);
|
|
|
+ OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
|
|
|
+ operatingSystemMap.put("名称", operatingSystem.getFamily() + " " + operatingSystem.getVersionInfo().getVersion());
|
|
|
+ operatingSystemMap.put("类型", operatingSystem.getManufacturer());
|
|
|
+
|
|
|
+ Map<String, String> platformMap = new LinkedHashMap<>();
|
|
|
+ result.put("平台信息", platformMap);
|
|
|
+ VersionPo version = versionInfo.getVersion();
|
|
|
+ platformMap.put("版本", version.getVersion());
|
|
|
+ platformMap.put("构建日期", version.getBUILD_DATE());
|
|
|
+ platformMap.put("GIT分支", version.getGIT_BRANCH());
|
|
|
+ platformMap.put("GIT地址", version.getGIT_URL());
|
|
|
+ platformMap.put("GIT日期", version.getGIT_DATE());
|
|
|
+ platformMap.put("GIT版本", version.getGIT_Revision_SHORT());
|
|
|
+ platformMap.put("DOCKER环境", new File("/.dockerenv").exists()?"是":"否");
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单位转换
|
|
|
+ */
|
|
|
+ private static String formatByte(long byteNumber) {
|
|
|
+ //换算单位
|
|
|
+ double FORMAT = 1024.0;
|
|
|
+ double kbNumber = byteNumber / FORMAT;
|
|
|
+ if (kbNumber < FORMAT) {
|
|
|
+ return new DecimalFormat("#.##KB").format(kbNumber);
|
|
|
+ }
|
|
|
+ double mbNumber = kbNumber / FORMAT;
|
|
|
+ if (mbNumber < FORMAT) {
|
|
|
+ return new DecimalFormat("#.##MB").format(mbNumber);
|
|
|
+ }
|
|
|
+ double gbNumber = mbNumber / FORMAT;
|
|
|
+ if (gbNumber < FORMAT) {
|
|
|
+ return new DecimalFormat("#.##GB").format(gbNumber);
|
|
|
+ }
|
|
|
+ double tbNumber = gbNumber / FORMAT;
|
|
|
+ return new DecimalFormat("#.##TB").format(tbNumber);
|
|
|
+ }
|
|
|
}
|