fix the monitor main

This commit is contained in:
fanfuxiaoran 2014-07-03 11:09:48 +08:00
parent f304ff5a63
commit 698d70ebb8
4 changed files with 6 additions and 16 deletions

View File

@ -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();
}
}

View File

@ -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;
}

View File

@ -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<Thread> threadList = new ArrayList<Thread>();
threadList.add(new Thread(new ProcessModel(this)));

View File

@ -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();