改进系统信息,增加位置数据、增加CPU型号名称
This commit is contained in:
parent
805bd34381
commit
fef6ce9ecd
@ -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;
|
||||||
|
@ -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)
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user