fix the model

This commit is contained in:
fanfuxiaoran 2014-03-12 16:38:37 +08:00
parent 766357d31f
commit 6248013221
7 changed files with 22 additions and 21 deletions

View File

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

View File

@ -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 {

View File

@ -35,7 +35,7 @@ class ProcessController {
public ProcessModelChild getProcessModelChild(@PathVariable("processName") String name)
throws SigarException, InterruptedException, ExecutionException {
ProcessModel processModel=new ProcessModel();
ArrayList<ProcessModelChild> proList=(ArrayList<ProcessModelChild>) processModel.getProcesModelList();
ArrayList<ProcessModelChild> proList=(ArrayList<ProcessModelChild>) processModel.getProcessModelList();
if(proList!=null){
for(ProcessModelChild processModelChild:proList){
if(processModelChild.getInstanceString().equals(name))

View File

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

View File

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

View File

@ -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<ProcessModelChild> 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<ProcessModelChild> getProcesModelList() {
@XmlElementWrapper()
@XmlElement( type = ProcessModelChild.class)
public List<ProcessModelChild> getProcessModelList() {
return processModelList;
}
@ -102,7 +102,7 @@ public class ProcessModel {
}
}
@XmlElement
public long[] getProcessPids() {
return processPids;
}

View File

@ -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<ProcessorModelChild> processorModelList;
private Sigar sigar = GetSigar.getSigar();