add process

This commit is contained in:
fanfuxiaoran 2013-08-22 22:19:37 +08:00
parent e19a82b626
commit 7efb54cbb2
3 changed files with 39 additions and 38 deletions

View File

@ -6,7 +6,27 @@ import javax.xml.bind.annotation.XmlRootElement;
public class ProcessModelChild {
private String instanceString;
private double privateBytes;
private double workingSet;
private double processorTimePercent;
private double processId;
private double virtualBytes;
public double getProcessorTimePercent() {
return processorTimePercent;
}
public void setProcessorTimePercent(double processorTimePercent) {
this.processorTimePercent = processorTimePercent;
}
public double getProcessId() {
return processId;
}
public void setProcessId(double processId) {
this.processId = processId;
}
public double getVirtualBytes() {
return virtualBytes;
}
public void setVirtualBytes(double virtualBytes) {
this.virtualBytes = virtualBytes;
}
public String getInstanceString() {
return instanceString;
}
@ -19,10 +39,5 @@ public class ProcessModelChild {
public void setPrivateBytes(double privateBytes) {
this.privateBytes = privateBytes;
}
public double getWorkingSet() {
return workingSet;
}
public void setWorkingSet(double workingSet) {
this.workingSet = workingSet;
}
}

View File

@ -73,7 +73,7 @@ public class MemoryMonitor extends LinuxFileRead {
}
public MemoryModel getMemoryInfo(int idleTime) throws IOException{
MemoryModel memoryModel=new MemoryModel();
MemoryModel memoryModel=new MemoryModel();
Runtime rt = Runtime.getRuntime();
String time=new Integer(idleTime).toString();
Process p = rt.exec("vmstat "+time+" 2");

View File

@ -3,53 +3,39 @@ package org.bench4q.monitor.service.windows;
import org.bench4q.monitor.model.ProcessModel;
import org.bench4q.monitor.model.ProcessModelChild;
import org.bench4q.monitor.performance.windows.ProcessMonitor;
import org.springframework.beans.factory.annotation.Autowired;
public class ProcessServiceWindows {
public ProcessServiceWindows(){
this.processMonitor=new ProcessMonitor();
public ProcessServiceWindows() {
this.processMonitor = new ProcessMonitor();
}
private ProcessMonitor processMonitor;
public ProcessMonitor getProcessMonitor() {
return processMonitor;
}
public void setProcessMonitor(ProcessMonitor processMonitor) {
this.processMonitor = processMonitor;
}
public ProcessModel getProcessInfo(int idleTime) {
public ProcessModel getProcessInfo(int idleTime){
ProcessModel processModel=new ProcessModel();
String instances[]=processMonitor.getInstances();
for(String elem:instances){
ProcessModelChild processModelChild=new ProcessModelChild();
ProcessModel processModel = new ProcessModel();
String instances[] = processMonitor.getInstances();
for (String elem : instances) {
ProcessModelChild processModelChild = new ProcessModelChild();
processModelChild.setInstanceString(elem);
processModelChild.setPrivateBytes(this.getProcessMonitor().getPrivateBytes(elem));
processModelChild.setWorkingSet(this.getProcessMonitor().getWorkingSet(elem));
processModelChild.setPrivateBytes(this.getProcessMonitor()
.getPrivateBytes(elem));
processModelChild.setProcessId(this.getProcessMonitor().getProcessId(elem));
processModelChild.setProcessorTimePercent(this.getProcessMonitor().getProcessorTimePercent(elem, idleTime));
processModelChild.setVirtualBytes(this.getProcessMonitor().getVirtualBytes(elem));
processModel.getProcesModelList().add(processModelChild);
}
return processModel;
}
}