diff --git a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/MonitorServer.java b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/MonitorServer.java index 158e0c3f..42e525fc 100644 --- a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/MonitorServer.java +++ b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/MonitorServer.java @@ -72,7 +72,7 @@ public class MonitorServer { public static void main(String[] args) throws InterruptedException { - MonitorServer monitorServer = new MonitorServer(5557); + MonitorServer monitorServer = new MonitorServer(5556); monitorServer.start(); } } diff --git a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/api/MainController.java b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/api/MainController.java index 33619426..7dd01149 100644 --- a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/api/MainController.java +++ b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/api/MainController.java @@ -1,6 +1,5 @@ package org.bench4q.monitor.api; -import java.util.Date; import java.util.concurrent.ExecutionException; import org.bench4q.monitor.model.MonitorMain; @@ -15,8 +14,7 @@ public class MainController { @RequestMapping("/all") @ResponseBody MonitorMain getMainModel() throws SigarException, InterruptedException, ExecutionException { - Date date = new Date(); - MonitorMain retModel = new MonitorMain(date); + MonitorMain retModel = new MonitorMain(); return retModel; } diff --git a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/model/MonitorMain.java b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/model/MonitorMain.java index a3c04f7c..3fba494a 100644 --- a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/model/MonitorMain.java +++ b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/model/MonitorMain.java @@ -9,40 +9,33 @@ import java.text.SimpleDateFormat; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; import org.hyperic.sigar.SigarException; import com.google.gson.annotations.Expose; @XmlRootElement(name = "history") -@XmlType public class MonitorMain { - @Expose @XmlElement private String date; - @Expose @XmlElement(name = "processor_info") private ProcessorModel processorModel; - @Expose @XmlElement(name = "memory_info") private MemoryModel memoryModel; - @Expose @XmlElement(name = "disk_info") private PhysicalDiskModel physicalDiskModel; @Expose @XmlElement(name = "network_info") private NetworkInterfaceModel networkInterfaceModel; - @Expose @XmlElement(name = "process_info") private ProcessModel processModel; private SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd-HH-mm-ss"); - public MonitorMain(Date date) throws SigarException, InterruptedException, + public MonitorMain() throws SigarException, InterruptedException, ExecutionException { dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); - this.date = dateFormat.format(date); + this.date = dateFormat.format(new Date()); long startTime = System.currentTimeMillis(); List threadList = new ArrayList(); threadList.add(new Thread(new ProcessModel(this))); diff --git a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/service/WriteSystemInfoToLocalDisk.java b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/service/WriteSystemInfoToLocalDisk.java index 64be7e6e..7a9decb5 100644 --- a/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/service/WriteSystemInfoToLocalDisk.java +++ b/Bench4Q-Monitor-Sigar/src/main/java/org/bench4q/monitor/service/WriteSystemInfoToLocalDisk.java @@ -30,11 +30,10 @@ public class WriteSystemInfoToLocalDisk { public void writeCurrentSystemInfoToLocalDisk() throws SigarException, InterruptedException, ExecutionException, IOException { dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); - Date date = new Date(); - MonitorMain mainModel = new MonitorMain(date); + MonitorMain mainModel = new MonitorMain(); FileWriter writer = null; try { - writer = new FileWriter(savePath + dateFormat.format(date) + writer = new FileWriter(savePath + dateFormat.format(new Date()) + ".json"); Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation().create();