改进系统信息,增加位置数据、增加CPU型号名称

This commit is contained in:
柏码の讲师 2023-12-01 00:24:17 +08:00
parent 805bd34381
commit fef6ce9ecd
6 changed files with 8 additions and 2 deletions

View File

@ -10,6 +10,7 @@ public class BaseDetail {
String osName; String osName;
String osVersion; String osVersion;
int osBit; int osBit;
String cpuName;
int cpuCore; int cpuCore;
double memory; double memory;
double disk; double disk;

View File

@ -4,9 +4,9 @@ import com.example.entity.data.BaseDetail;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import oshi.SystemInfo; import oshi.SystemInfo;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HardwareAbstractionLayer; import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.NetworkIF; import oshi.hardware.NetworkIF;
import oshi.hardware.HWDiskStore;
import oshi.software.os.OperatingSystem; import oshi.software.os.OperatingSystem;
import java.io.IOException; import java.io.IOException;
@ -42,6 +42,7 @@ public class MonitorUtils {
.setOsArch(properties.getProperty("os.arch")) .setOsArch(properties.getProperty("os.arch"))
.setOsVersion(os.getVersionInfo().getVersion()) .setOsVersion(os.getVersionInfo().getVersion())
.setOsName(os.getFamily()) .setOsName(os.getFamily())
.setCpuName(hardware.getProcessor().getProcessorIdentifier().getName())
.setCpuCore(hardware.getProcessor().getLogicalProcessorCount()) .setCpuCore(hardware.getProcessor().getLogicalProcessorCount())
.setMemory(memory) .setMemory(memory)
.setDisk(diskSize) .setDisk(diskSize)

View File

@ -16,5 +16,6 @@ public class Client implements BaseData {
Integer id; Integer id;
String name; String name;
String token; String token;
String location;
Date registerTime; Date registerTime;
} }

View File

@ -13,6 +13,7 @@ public class ClientDetail {
String osName; String osName;
String osVersion; String osVersion;
int osBit; int osBit;
String cpuName;
int cpuCore; int cpuCore;
double memory; double memory;
double disk; double disk;

View File

@ -14,6 +14,8 @@ public class ClientDetailVO {
@NotNull @NotNull
int osBit; int osBit;
@NotNull @NotNull
String cpuName;
@NotNull
int cpuCore; int cpuCore;
@NotNull @NotNull
double memory; double memory;

View File

@ -55,7 +55,7 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
public synchronized boolean verifyAndRegister(String token) { public synchronized boolean verifyAndRegister(String token) {
if(this.registerToken.equals(token)) { if(this.registerToken.equals(token)) {
int id = this.randomClientId(); int id = this.randomClientId();
Client client = new Client(id, "未命名主机", token, new Date()); Client client = new Client(id, "未命名主机", token, "cn", new Date());
if(this.save(client)) { if(this.save(client)) {
registerToken = this.generateNewToken(); registerToken = this.generateNewToken();
this.addClientCache(client); this.addClientCache(client);