fix the model
This commit is contained in:
parent
766357d31f
commit
6248013221
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue