diff --git a/src/main/java/org/bench4q/monitor/api/ProcessController.java b/src/main/java/org/bench4q/monitor/api/ProcessController.java index af45a5d9..1868e75f 100644 --- a/src/main/java/org/bench4q/monitor/api/ProcessController.java +++ b/src/main/java/org/bench4q/monitor/api/ProcessController.java @@ -10,26 +10,30 @@ import org.springframework.web.bind.annotation.ResponseBody; @Controller @RequestMapping("/Monitor") -public class ProcessController extends MonitorContorlEntity { +public class ProcessController extends MonitorContorlEntity { public ProcessServiceWindows getProcessServiceWindows() { return processServiceWindows; } + @Autowired - public void setProcessServiceWindows(ProcessServiceWindows processServiceWindows) { + public void setProcessServiceWindows( + ProcessServiceWindows processServiceWindows) { this.processServiceWindows = processServiceWindows; } private ProcessServiceWindows processServiceWindows; - + @RequestMapping("/Process") @ResponseBody - public ProcessModel getProcessInfo(){ - - if(this.getOsNameString().contains("windows")){ - return this.getProcessServiceWindows().getProcessInfo(this.getIdleTime()); + public ProcessModel getProcessInfo() { + + if (this.getOsNameString().contains("windows")) { + + return this.getProcessServiceWindows().getProcessInfo( + this.getIdleTime()); } - else return null; + else return null; } - + } diff --git a/src/main/java/org/bench4q/monitor/api/SystemController.java b/src/main/java/org/bench4q/monitor/api/SystemController.java new file mode 100644 index 00000000..29dfcf1a --- /dev/null +++ b/src/main/java/org/bench4q/monitor/api/SystemController.java @@ -0,0 +1,23 @@ +package org.bench4q.monitor.api; + +import org.bench4q.monitor.entiry.MonitorContorlEntity; +import org.bench4q.monitor.model.SystemModel; +import org.bench4q.monitor.service.windows.SystemServiceWindows; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +@Controller +@RequestMapping("/Monitor") +public class SystemController extends MonitorContorlEntity{ + @ResponseBody + @RequestMapping("/System") + public SystemModel getSystemInfo(){ + if(this.getOsNameString().contains("windows")){ + SystemServiceWindows systemServiceWindows=new SystemServiceWindows(); + return systemServiceWindows.getSystemInfo(this.getIdleTime()); + } + else return null; + } + } + + diff --git a/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java b/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java index d5ec0039..0e43a961 100644 --- a/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java +++ b/src/main/java/org/bench4q/monitor/entiry/MonitorContorlEntity.java @@ -9,7 +9,7 @@ public class MonitorContorlEntity { private int idleTime; public MonitorContorlEntity(){ this.osNameString=System.getProperty("os.name").toLowerCase(); - this.idleTime=100; + this.idleTime=1000; } public String getOsNameString() { return osNameString; diff --git a/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java b/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java index 36b7565b..1b3241cf 100644 --- a/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java +++ b/src/main/java/org/bench4q/monitor/model/NetworkInterfaceModelChild.java @@ -1,5 +1,8 @@ package org.bench4q.monitor.model; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement public class NetworkInterfaceModelChild { private double bytesTotalPerSecond; private String instance; diff --git a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java b/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java index e8424db5..06fde351 100644 --- a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java +++ b/src/main/java/org/bench4q/monitor/model/PhysicalDiskModel.java @@ -1,11 +1,13 @@ package org.bench4q.monitor.model; + import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; - +import javax.xml.bind.annotation.XmlRootElement; +@XmlRootElement(name="PhisicalDisk") public class PhysicalDiskModel { private List physicalDiskModelList; @XmlElementWrapper diff --git a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java b/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java index 84640114..2491cba0 100644 --- a/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java +++ b/src/main/java/org/bench4q/monitor/model/PhysicalDiskModelChild.java @@ -1,5 +1,8 @@ package org.bench4q.monitor.model; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement public class PhysicalDiskModelChild { private String instance; diff --git a/src/main/java/org/bench4q/monitor/model/ProcessModel.java b/src/main/java/org/bench4q/monitor/model/ProcessModel.java index b3719d1c..ce4354f7 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessModel.java +++ b/src/main/java/org/bench4q/monitor/model/ProcessModel.java @@ -13,7 +13,7 @@ public class ProcessModel { private List procesModelList; @XmlElementWrapper - @XmlElement(name="Instance",type=ProcessorModelChild.class) + @XmlElement(name="Instance",type=ProcessModelChild.class) public List getProcesModelList() { return procesModelList; } @@ -24,9 +24,6 @@ public class ProcessModel { this.procesModelList=new ArrayList(); } - - - - + } diff --git a/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java b/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java index e2730fcf..7ee3a94a 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java +++ b/src/main/java/org/bench4q/monitor/model/ProcessModelChild.java @@ -1,5 +1,8 @@ package org.bench4q.monitor.model; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement public class ProcessModelChild { private String instanceString; private double privateBytes; diff --git a/src/main/java/org/bench4q/monitor/model/ProcessorModel.java b/src/main/java/org/bench4q/monitor/model/ProcessorModel.java index 4d971a41..a9bb5807 100644 --- a/src/main/java/org/bench4q/monitor/model/ProcessorModel.java +++ b/src/main/java/org/bench4q/monitor/model/ProcessorModel.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement +@XmlRootElement(name="Processor") public class ProcessorModel { private List processorModelList; public ProcessorModel(){ diff --git a/src/main/java/org/bench4q/monitor/model/SystemModel.java b/src/main/java/org/bench4q/monitor/model/SystemModel.java new file mode 100644 index 00000000..6eafc971 --- /dev/null +++ b/src/main/java/org/bench4q/monitor/model/SystemModel.java @@ -0,0 +1,37 @@ +package org.bench4q.monitor.model; + +public class SystemModel { + + private double fileDataOperationsPerSecond; + + public double getFileDataOperationsPerSecond() { + return fileDataOperationsPerSecond; + } + + public void setFileDataOperationsPerSecond(double fileDataOperationsPerSecond) { + this.fileDataOperationsPerSecond = fileDataOperationsPerSecond; + } + + public double getProcessorQueueLength() { + return processorQueueLength; + } + + public void setProcessorQueueLength(double processorQueueLength) { + this.processorQueueLength = processorQueueLength; + } + + private double totalProceesorTimePercent; + + public double getTotalProceesorTimePercent() { + return totalProceesorTimePercent; + } + + + private double processorQueueLength; + + public void setTotalProceesorTimePercent(double totalProceesorTimePercent2) { + // TODO Auto-generated method stub + this.totalProceesorTimePercent = totalProceesorTimePercent; + } + +} diff --git a/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java b/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java index d5362a21..00b5e3b1 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java +++ b/src/main/java/org/bench4q/monitor/service/windows/PhysicalDiskServiceWindows.java @@ -23,8 +23,10 @@ public class PhysicalDiskServiceWindows { PhysicalDiskModel physicalDiskModel = new PhysicalDiskModel(); String instances[] = physicalDiskMonitor.getInstances(); + System.out.println(instances.length); PhysicalDiskModelChild physicalDiskModelChild = new PhysicalDiskModelChild(); for (String elem : instances) { + physicalDiskModelChild.setInstance(elem); physicalDiskModelChild .setAverageDiskQueueLength(physicalDiskMonitor .getAverageDiskQueueLength(elem, idleTime)); diff --git a/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java b/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java index 0fedca42..564a4f44 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java +++ b/src/main/java/org/bench4q/monitor/service/windows/ProcessServiceWindows.java @@ -35,9 +35,7 @@ public class ProcessServiceWindows { processModelChild.setPrivateBytes(this.getProcessMonitor().getPrivateBytes(elem)); processModelChild.setWorkingSet(this.getProcessMonitor().getWorkingSet(elem)); processModel.getProcesModelList().add(processModelChild); - } - return processModel; } diff --git a/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java b/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java index 714c5ae3..5a8c9649 100644 --- a/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java +++ b/src/main/java/org/bench4q/monitor/service/windows/ProcessorServiceWindows.java @@ -5,8 +5,12 @@ import org.bench4q.monitor.performance.windows.ProcessorMonitor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -@Service + public class ProcessorServiceWindows { + public ProcessorServiceWindows() { + // TODO Auto-generated constructor stub + this.processorMonitor=new ProcessorMonitor(); + } private ProcessorMonitor processorMonitor; public ProcessorMonitor getProcessorMonitor() { diff --git a/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java b/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java new file mode 100644 index 00000000..d581569d --- /dev/null +++ b/src/main/java/org/bench4q/monitor/service/windows/SystemServiceWindows.java @@ -0,0 +1,36 @@ +package org.bench4q.monitor.service.windows; + +import org.bench4q.monitor.model.SystemModel; +import org.bench4q.monitor.performance.windows.ProcessorMonitor; +import org.bench4q.monitor.performance.windows.SystemMonitor; + +public class SystemServiceWindows { + + public SystemServiceWindows(){ + this.systemMonitor=new SystemMonitor(); + this.processorMonitor=new ProcessorMonitor(); + } + private SystemMonitor systemMonitor; + private ProcessorMonitor processorMonitor; + public SystemMonitor getSystemMonitor() { + return systemMonitor; + } + public void setSystemMonitor(SystemMonitor systemMonitor) { + this.systemMonitor = systemMonitor; + } + public ProcessorMonitor getProcessorMonitor() { + return processorMonitor; + } + public void setProcessorMonitor(ProcessorMonitor processorMonitor) { + this.processorMonitor = processorMonitor; + } + + public SystemModel getSystemInfo(int idleTime){ + SystemModel systemModel=new SystemModel(); + systemModel.setFileDataOperationsPerSecond(this.getSystemMonitor().getFileDataOperationsPerSecond(idleTime)); + systemModel.setProcessorQueueLength(this.getSystemMonitor().getProcessorQueueLength()); + double totalProceesorTimePercent=this.getProcessorMonitor().getProcessorTimePercent("_Total", idleTime); + systemModel.setTotalProceesorTimePercent(totalProceesorTimePercent); + return systemModel; + } +}