[ agent ] [ status ] - accomplish agent status - 6
This commit is contained in:
@@ -90,12 +90,12 @@ public class AgentStatusCollector {
|
|||||||
* the server info are not collected completely
|
* the server info are not collected completely
|
||||||
* this will be executed to update or complete the octopus agent server info
|
* this will be executed to update or complete the octopus agent server info
|
||||||
*/
|
*/
|
||||||
@Scheduled(initialDelay = 180000)
|
// @Scheduled(initialDelay = 180000)
|
||||||
public void updateAgentServerInfo(){
|
// public void updateAgentServerInfo(){
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
// agent boot up 120s then start to report its status
|
// agent boot up 120s then start to report its status
|
||||||
// at the fix rate of 15s
|
// at the fix rate of 15s
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import oshi.software.os.OperatingSystem;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -36,7 +35,7 @@ public class AgentSystemInfo {
|
|||||||
.manufacturer(os.getManufacturer())
|
.manufacturer(os.getManufacturer())
|
||||||
.bootTime(TimeUtils.localDateTimeString(
|
.bootTime(TimeUtils.localDateTimeString(
|
||||||
LocalDateTime.ofInstant(
|
LocalDateTime.ofInstant(
|
||||||
Instant.ofEpochMilli(os.getSystemBootTime()),
|
Instant.ofEpochSecond(os.getSystemBootTime()),
|
||||||
ZoneId.of("UTC+8")
|
ZoneId.of("UTC+8")
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class CpuInfo {
|
|||||||
/**
|
/**
|
||||||
* CPU型号信息
|
* CPU型号信息
|
||||||
*/
|
*/
|
||||||
private String cpuModel;
|
private CentralProcessor.ProcessorIdentifier cpuModel;
|
||||||
|
|
||||||
private double[] cpuLoadAverage;
|
private double[] cpuLoadAverage;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public class CpuInfo {
|
|||||||
/**
|
/**
|
||||||
* CPU型号信息
|
* CPU型号信息
|
||||||
*/
|
*/
|
||||||
private CpuTicks ticks;
|
//private CpuTicks ticks;
|
||||||
|
|
||||||
|
|
||||||
public CpuInfo(CentralProcessor processor, long waitingTime){
|
public CpuInfo(CentralProcessor processor, long waitingTime){
|
||||||
@@ -80,12 +80,12 @@ public class CpuInfo {
|
|||||||
private void init(CentralProcessor processor, long waitingTime) {
|
private void init(CentralProcessor processor, long waitingTime) {
|
||||||
|
|
||||||
final CpuTicks ticks = new CpuTicks(processor, waitingTime);
|
final CpuTicks ticks = new CpuTicks(processor, waitingTime);
|
||||||
this.ticks = ticks;
|
//this.ticks = ticks;
|
||||||
|
|
||||||
this.cpuTotal = processor.getLogicalProcessorCount();
|
this.cpuTotal = processor.getLogicalProcessorCount();
|
||||||
this.coreTotal = processor.getPhysicalProcessorCount();
|
this.coreTotal = processor.getPhysicalProcessorCount();
|
||||||
|
|
||||||
this.cpuModel = processor.toString();
|
this.cpuModel = processor.getProcessorIdentifier();
|
||||||
|
|
||||||
final long totalCpu = ticks.totalCpu();
|
final long totalCpu = ticks.totalCpu();
|
||||||
this.cpuUsageTotol = totalCpu;
|
this.cpuUsageTotol = totalCpu;
|
||||||
@@ -101,7 +101,7 @@ public class CpuInfo {
|
|||||||
this.systemLoadAverage = processor.getSystemLoadAverage(3);
|
this.systemLoadAverage = processor.getSystemLoadAverage(3);
|
||||||
|
|
||||||
// cpu load average
|
// cpu load average
|
||||||
this.cpuLoadAverage = processor.getProcessorCpuLoad(waitingTime);
|
this.cpuLoadAverage = formatCpuLoadAverage(processor.getProcessorCpuLoad(waitingTime));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,4 +120,19 @@ public class CpuInfo {
|
|||||||
return Double.parseDouble(LOAD_FORMAT.format(tick <= 0 ? 0 : (100d * tick / totalCpu)));
|
return Double.parseDouble(LOAD_FORMAT.format(tick <= 0 ? 0 : (100d * tick / totalCpu)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static double formatDouble(double doubleNum) {
|
||||||
|
|
||||||
|
return Double.parseDouble(LOAD_FORMAT.format(doubleNum));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double[] formatCpuLoadAverage(double[] cpuLoadAverage){
|
||||||
|
double[] result = new double[cpuLoadAverage.length];
|
||||||
|
|
||||||
|
for (int i = 0; i < cpuLoadAverage.length; i++) {
|
||||||
|
result[i] = formatDouble(cpuLoadAverage[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -43,7 +42,7 @@ public class TimeUtils {
|
|||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
||||||
private static final Map<String, Long> times = new HashMap<>(16);
|
private static final Map<String, Long> times = new LinkedHashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
times.put("year", TimeUnit.DAYS.toMillis(365));
|
times.put("year", TimeUnit.DAYS.toMillis(365));
|
||||||
|
|||||||
Reference in New Issue
Block a user