From 624801322135f19d32e01ab0370c46268aff9f8f Mon Sep 17 00:00:00 2001 From: fanfuxiaoran <495538672@qq.com> Date: Wed, 12 Mar 2014 16:38:37 +0800 Subject: [PATCH] fix the model --- .../org/bench4q/monitor/MonitorServer.java | 5 ++-- .../monitor/api/PhysicalDiskController.java | 2 +- .../monitor/api/ProcessController.java | 2 +- .../bench4q/monitor/model/MonitorMain.java | 6 ++--- .../monitor/model/PhysicalDiskModel.java | 2 +- .../bench4q/monitor/model/ProcessModel.java | 24 +++++++++---------- .../bench4q/monitor/model/ProcessorModel.java | 2 +- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/bench4q/monitor/MonitorServer.java b/src/main/java/org/bench4q/monitor/MonitorServer.java index 958e855a..988249f7 100644 --- a/src/main/java/org/bench4q/monitor/MonitorServer.java +++ b/src/main/java/org/bench4q/monitor/MonitorServer.java @@ -1,6 +1,7 @@ package org.bench4q.monitor; + import java.util.Timer; import org.bench4q.monitor.service.TimerService; @@ -77,8 +78,8 @@ public class MonitorServer { MonitorServer monitorServer = new MonitorServer(5556); monitorServer.start(); - /* Timer timer = new Timer(); - timer.schedule(new TimerService(), 1000, 60000);*/ + Timer timer = new Timer(); + timer.schedule(new TimerService(), 1000, 60000); } diff --git a/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java b/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java index 28a978ca..d698d40d 100644 --- a/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java +++ b/src/main/java/org/bench4q/monitor/api/PhysicalDiskController.java @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping("/monitor") public class PhysicalDiskController { - @RequestMapping("/pshysicalDisk") + @RequestMapping("/physicalDisk") @ResponseBody PhysicalDiskModel getPhysicalDiskModel() throws SigarException, InterruptedException, ExecutionException { diff --git a/src/main/java/org/bench4q/monitor/api/ProcessController.java b/src/main/java/org/bench4q/monitor/api/ProcessController.java index 69b5b2b0..335c3f80 100644 --- a/src/main/java/org/bench4q/monitor/api/ProcessController.java +++ b/src/main/java/org/bench4q/monitor/api/ProcessController.java @@ -35,7 +35,7 @@ class ProcessController { public ProcessModelChild getProcessModelChild(@PathVariable("processName") String name) throws SigarException, InterruptedException, ExecutionException { ProcessModel processModel=new ProcessModel(); - ArrayList proList=(ArrayList) processModel.getProcesModelList(); + ArrayList proList=(ArrayList) processModel.getProcessModelList(); if(proList!=null){ for(ProcessModelChild processModelChild:proList){ if(processModelChild.getInstanceString().equals(name)) diff --git a/src/main/java/org/bench4q/monitor/model/MonitorMain.java b/src/main/java/org/bench4q/monitor/model/MonitorMain.java index fcda36f3..11be892b 100644 --- a/src/main/java/org/bench4q/monitor/model/MonitorMain.java +++ b/src/main/java/org/bench4q/monitor/model/MonitorMain.java @@ -14,8 +14,8 @@ import org.hyperic.sigar.SigarException; @XmlRootElement(name = "history") @XmlType public class MonitorMain { - @XmlElement - private String date; +/* @XmlElement + private String date;*/ @XmlElement(name = "processor_info") private ProcessorModel processorModel; @XmlElement(name = "memory_info") @@ -36,7 +36,7 @@ public class MonitorMain { public MonitorMain(Date date) throws SigarException, InterruptedException, ExecutionException { dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); - this.date = dateFormat.format(date); + /*this.date = dateFormat.format(date);*/ processorModel = new ProcessorModel(); memoryModel = new MemoryModel(); diff --git a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java b/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java index 299b0ee1..72ecbe9c 100644 --- a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java +++ b/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java @@ -19,7 +19,7 @@ import org.hyperic.sigar.FileSystem; import org.hyperic.sigar.FileSystemUsage; import org.hyperic.sigar.SigarException; -@XmlRootElement(name = "PhysicalDisk") +@XmlRootElement public class PhysicalDiskModel { private Double diskReadKBytesRate; private Double diskWriteKBytesRate; diff --git a/src/main/java/org/bench4q/monitor/model/ProcessModel.java b/src/main/java/org/bench4q/monitor/model/ProcessModel.java index 7b9f8a77..df5204ce 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessModel.java +++ b/src/main/java/org/bench4q/monitor/model/ProcessModel.java @@ -16,7 +16,7 @@ import org.hyperic.sigar.ProcState; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; -@XmlRootElement(name = "Process") +@XmlRootElement public class ProcessModel { private Sigar sigar = GetSigar.getSigar(); private List processModelList; @@ -31,25 +31,25 @@ public class ProcessModel { System.out.println("total process:" + processModel.getProcessPids().length); for (int i = 0; i < processModel.getProcessPids().length; i++) { - if (processModel.getProcesModelList().get(i) != null) { + if (processModel.getProcessModelList().get(i) != null) { System.out.println("pid:" - + processModel.getProcesModelList().get(i) + + processModel.getProcessModelList().get(i) .getInstanceString()); System.out.println("name:" - + processModel.getProcesModelList().get(i) + + processModel.getProcessModelList().get(i) .getProcessId()); System.out.println("cpu percent:" - + processModel.getProcesModelList().get(i) + + processModel.getProcessModelList().get(i) .getProcessorTimePercent()); System.out.println("getResidentKBytes:" - + processModel.getProcesModelList().get(i) + + processModel.getProcessModelList().get(i) .getResidentKBytes()); System.out.println("virtural Kbytes:" - + processModel.getProcesModelList().get(i).getVSize()); + + processModel.getProcessModelList().get(i).getVSize()); System.out .println(" Kbytes:" - + processModel.getProcesModelList().get(i) + + processModel.getProcessModelList().get(i) .getMemSize()); break; @@ -78,9 +78,9 @@ public class ProcessModel { this.size = sigar.getProcList().length; } - @XmlElementWrapper(name="processList") - @XmlElement(name = "process", type = ProcessModelChild.class) - public List getProcesModelList() { + @XmlElementWrapper() + @XmlElement( type = ProcessModelChild.class) + public List getProcessModelList() { return processModelList; } @@ -102,7 +102,7 @@ public class ProcessModel { } } - +@XmlElement public long[] getProcessPids() { return processPids; } diff --git a/src/main/java/org/bench4q/monitor/model/ProcessorModel.java b/src/main/java/org/bench4q/monitor/model/ProcessorModel.java index 59b85f4b..f01b83f8 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessorModel.java +++ b/src/main/java/org/bench4q/monitor/model/ProcessorModel.java @@ -19,7 +19,7 @@ import org.hyperic.sigar.Sigar; import org.hyperic.sigar.CpuPerc; import org.hyperic.sigar.SigarException; -@XmlRootElement(name = "Processors") +@XmlRootElement public class ProcessorModel { private List processorModelList; private Sigar sigar = GetSigar.getSigar();