add SystemMonitor
This commit is contained in:
parent
686e3fd292
commit
9a71bc3d17
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<PhysicalDiskModelChild> physicalDiskModelList;
|
||||
@XmlElementWrapper
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class PhysicalDiskModelChild {
|
||||
|
||||
private String instance;
|
||||
|
|
|
@ -13,7 +13,7 @@ public class ProcessModel {
|
|||
|
||||
private List<ProcessModelChild> procesModelList;
|
||||
@XmlElementWrapper
|
||||
@XmlElement(name="Instance",type=ProcessorModelChild.class)
|
||||
@XmlElement(name="Instance",type=ProcessModelChild.class)
|
||||
public List<ProcessModelChild> getProcesModelList() {
|
||||
return procesModelList;
|
||||
}
|
||||
|
@ -24,9 +24,6 @@ public class ProcessModel {
|
|||
this.procesModelList=new ArrayList<ProcessModelChild>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<ProcessorModelChild> processorModelList;
|
||||
public ProcessorModel(){
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue