delete the MonitorController ,add the MonitorControlEntity
This commit is contained in:
parent
470ed2c635
commit
aed395b52a
|
@ -110,6 +110,9 @@ public class Main {
|
|||
for (String elem : processInstances) {
|
||||
System.out.println(elem);
|
||||
}
|
||||
System.out.println("wxr"+processMonitor.getProcessorTimePercent("0", 1000));
|
||||
System.out.println("wxr"+processMonitor.getUserTimePercent("0", 1000));
|
||||
System.out.println(processMonitor.getPrivilegedTimePercent("0",1000));
|
||||
|
||||
String[] processCounter = processMonitor.getCounterList();
|
||||
for (String elem : processCounter) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.bench4q.monitor.api;
|
|||
|
||||
|
||||
|
||||
import org.bench4q.monitor.entiry.MonitorContorlEntity;
|
||||
import org.bench4q.monitor.model.LogicalDiskModel;
|
||||
import org.bench4q.monitor.service.windows.LogicalDiskServiceWindows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -12,16 +13,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/Monitor")
|
||||
public class LogicalDiskController {//以后实现linux后,要加入linux的dervice
|
||||
private MonitorController monitorController;
|
||||
public class LogicalDiskController extends MonitorContorlEntity {//以后实现linux后,要加入linux的dervice
|
||||
|
||||
private LogicalDiskServiceWindows logicalDiskServiceWindows;
|
||||
public MonitorController getMonitorController() {
|
||||
return monitorController;
|
||||
}
|
||||
@Autowired
|
||||
public void setMonitorController(MonitorController monitorController) {
|
||||
this.monitorController = monitorController;
|
||||
}
|
||||
|
||||
public LogicalDiskServiceWindows getLogicalDiskServiceWindows() {
|
||||
return logicalDiskServiceWindows;
|
||||
}
|
||||
|
@ -34,8 +29,8 @@ public class LogicalDiskController {//
|
|||
@ResponseBody
|
||||
public LogicalDiskModel getLogicalDiskInfo(){
|
||||
|
||||
if(monitorController.getOsNameString().contains("windows")){
|
||||
return logicalDiskServiceWindows.getLogicalDiskInfo(this.getMonitorController().getIdleTime());
|
||||
if(this.getOsNameString().contains("windows")){
|
||||
return logicalDiskServiceWindows.getLogicalDiskInfo(this.getIdleTime());
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.bench4q.monitor.api;
|
||||
|
||||
import org.bench4q.monitor.entiry.MonitorContorlEntity;
|
||||
import org.bench4q.monitor.model.MemoryModel;
|
||||
import org.bench4q.monitor.service.windows.MemoryServiceWindows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -9,17 +10,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/Monitor")
|
||||
public class MemoryController {
|
||||
public class MemoryController extends MonitorContorlEntity {
|
||||
|
||||
private MonitorController monitorController;
|
||||
private MemoryServiceWindows memoryServiceWindows;
|
||||
public MonitorController getMonitorController() {
|
||||
return monitorController;
|
||||
}
|
||||
@Autowired
|
||||
public void setMonitorController(MonitorController monitorController) {
|
||||
this.monitorController = monitorController;
|
||||
}
|
||||
|
||||
public MemoryServiceWindows getMemoryServiceWindows() {
|
||||
return memoryServiceWindows;
|
||||
}
|
||||
|
@ -30,8 +24,8 @@ public class MemoryController {
|
|||
@RequestMapping("/Memory")
|
||||
@ResponseBody
|
||||
public MemoryModel getMemoryInfo(){
|
||||
if(this.getMonitorController().getOsNameString().contains("windows")){
|
||||
return this.getMemoryServiceWindows().getMemoryInfo(this.getMonitorController().getIdleTime());
|
||||
if(this.getOsNameString().contains("windows")){
|
||||
return this.getMemoryServiceWindows().getMemoryInfo(this.getIdleTime());
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package org.bench4q.monitor.api;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MonitorController {
|
||||
|
||||
private String osNameString;
|
||||
private int idleTime;
|
||||
public MonitorController(){
|
||||
this.osNameString=System.getProperty("os.name").toLowerCase();
|
||||
this.idleTime=100;
|
||||
}
|
||||
public String getOsNameString() {
|
||||
return osNameString;
|
||||
}
|
||||
public void setOsNameString(String osNameString) {
|
||||
this.osNameString = osNameString;
|
||||
}
|
||||
public int getIdleTime() {
|
||||
return idleTime;
|
||||
}
|
||||
public void setIdleTime(int idleTime) {
|
||||
this.idleTime = idleTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.bench4q.monitor.api;
|
||||
|
||||
import org.bench4q.monitor.entiry.MonitorContorlEntity;
|
||||
import org.bench4q.monitor.model.ProcessorModel;
|
||||
import org.bench4q.monitor.service.windows.ProcessorServicewindows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -9,19 +10,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
@Controller
|
||||
@RequestMapping("/Monitor")
|
||||
public class ProcessorController {
|
||||
private MonitorController monitorController;
|
||||
public class ProcessorController extends MonitorContorlEntity {
|
||||
private ProcessorServicewindows processorServicewindows;
|
||||
|
||||
public MonitorController getMonitorController() {
|
||||
return monitorController;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setMonitorController(MonitorController monitorController) {
|
||||
this.monitorController = monitorController;
|
||||
}
|
||||
|
||||
public ProcessorServicewindows getProcessorServicewindows() {
|
||||
return processorServicewindows;
|
||||
}
|
||||
|
@ -36,9 +26,9 @@ public class ProcessorController {
|
|||
@ResponseBody
|
||||
public ProcessorModel getProcessorInfo() {
|
||||
|
||||
if (this.getMonitorController().getOsNameString().contains("windows")) {
|
||||
if (this.getOsNameString().contains("windows")) {
|
||||
return this.getProcessorServicewindows().getProcessorInfo(
|
||||
this.getMonitorController().getIdleTime());
|
||||
this.getIdleTime());
|
||||
} else
|
||||
return null;
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package org.bench4q.monitor.entiry;
|
||||
|
||||
|
||||
public class MonitorContorlEntity {
|
||||
|
||||
|
||||
|
||||
private String osNameString;
|
||||
private int idleTime;
|
||||
public MonitorContorlEntity(){
|
||||
this.osNameString=System.getProperty("os.name").toLowerCase();
|
||||
this.idleTime=100;
|
||||
}
|
||||
public String getOsNameString() {
|
||||
return osNameString;
|
||||
}
|
||||
public void setOsNameString(String osNameString) {
|
||||
this.osNameString = osNameString;
|
||||
}
|
||||
public int getIdleTime() {
|
||||
return idleTime;
|
||||
}
|
||||
public void setIdleTime(int idleTime) {
|
||||
this.idleTime = idleTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
import java.awt.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* @author wxr
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "LogicalDisk")
|
||||
public class LogicalDiskModel1 {
|
||||
|
||||
private String[] instances;
|
||||
private Map<String, Double> freeSpacePercent;
|
||||
private Map<String, Double> freeMegabytes;
|
||||
|
||||
// 磁盘活动百分比
|
||||
private Map<String, Double> diskTimePercent;
|
||||
private Map<String, Double> diskReadTimePercent;
|
||||
private Map<String, Double> diskWriteTimePercent;
|
||||
|
||||
// 磁盘平均活动时间
|
||||
private Map<String, Double> averageDiskTransferTimeInSecond;
|
||||
private Map<String, Double> averageDiskReadTimeInSecond;
|
||||
private Map<String, Double> averageDiskWriteTimeInSecond;
|
||||
// 磁盘平均处理的字节
|
||||
private Map<String, Double> averageDiskBytesPerTransfer;// 可计算吞吐率
|
||||
private Map<String, Double> averageDiskBytesPerRead;
|
||||
private Map<String, Double> averageDiskBytesPerWrite;
|
||||
|
||||
// 空闲百分比
|
||||
private Map<String, Double> idleTimePercent;
|
||||
// 平均队列长度
|
||||
private Map<String, Double> averageDiskQueueLength;
|
||||
// 当前队列长度
|
||||
private Map<String, Double> currentDiskQueueLength;
|
||||
|
||||
@XmlElement(name = "Instance")
|
||||
public String[] getInstances() {
|
||||
return instances;
|
||||
}
|
||||
|
||||
public void setInstances(String[] instances) {
|
||||
this.instances = instances;
|
||||
}
|
||||
|
||||
@XmlElement(name = "FreeSpacePercent")
|
||||
public Map<String, Double> getFreeSpacePercent() {
|
||||
return freeSpacePercent;
|
||||
}
|
||||
|
||||
public void setFreeSpacePercent(Map<String, Double> freeSpacePercent) {
|
||||
this.freeSpacePercent = freeSpacePercent;
|
||||
}
|
||||
|
||||
public Map<String, Double> getFreeMegabytes() {
|
||||
return freeMegabytes;
|
||||
}
|
||||
|
||||
public void setFreeMegabytes(Map<String, Double> freeMegabytes) {
|
||||
this.freeMegabytes = freeMegabytes;
|
||||
}
|
||||
|
||||
public Map<String, Double> getDiskTimePercent() {
|
||||
return diskTimePercent;
|
||||
}
|
||||
|
||||
public void setDiskTimePercent(Map<String, Double> diskTimePercent) {
|
||||
this.diskTimePercent = diskTimePercent;
|
||||
}
|
||||
|
||||
public Map<String, Double> getDiskReadTimePercent() {
|
||||
return diskReadTimePercent;
|
||||
}
|
||||
|
||||
public void setDiskReadTimePercent(Map<String, Double> diskReadTimePercent) {
|
||||
this.diskReadTimePercent = diskReadTimePercent;
|
||||
}
|
||||
|
||||
public Map<String, Double> getDiskWriteTimePercent() {
|
||||
return diskWriteTimePercent;
|
||||
}
|
||||
|
||||
public void setDiskWriteTimePercent(Map<String, Double> diskWriteTimePercent) {
|
||||
this.diskWriteTimePercent = diskWriteTimePercent;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskTransferTimeInSecond() {
|
||||
return averageDiskTransferTimeInSecond;
|
||||
}
|
||||
|
||||
public void setAverageDiskTransferTimeInSecond(
|
||||
Map<String, Double> averageDiskTransferTimeInSecond) {
|
||||
this.averageDiskTransferTimeInSecond = averageDiskTransferTimeInSecond;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskReadTimeInSecond() {
|
||||
return averageDiskReadTimeInSecond;
|
||||
}
|
||||
|
||||
public void setAverageDiskReadTimeInSecond(
|
||||
Map<String, Double> averageDiskReadTimeInSecond) {
|
||||
this.averageDiskReadTimeInSecond = averageDiskReadTimeInSecond;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskWriteTimeInSecond() {
|
||||
return averageDiskWriteTimeInSecond;
|
||||
}
|
||||
|
||||
public void setAverageDiskWriteTimeInSecond(
|
||||
Map<String, Double> averageDiskWriteTimeInSecond) {
|
||||
this.averageDiskWriteTimeInSecond = averageDiskWriteTimeInSecond;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskBytesPerTransfer() {
|
||||
return averageDiskBytesPerTransfer;
|
||||
}
|
||||
|
||||
public void setAverageDiskBytesPerTransfer(
|
||||
Map<String, Double> averageDiskBytesPerTransfer) {
|
||||
this.averageDiskBytesPerTransfer = averageDiskBytesPerTransfer;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskBytesPerRead() {
|
||||
return averageDiskBytesPerRead;
|
||||
}
|
||||
|
||||
public void setAverageDiskBytesPerRead(
|
||||
Map<String, Double> averageDiskBytesPerRead) {
|
||||
this.averageDiskBytesPerRead = averageDiskBytesPerRead;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskBytesPerWrite() {
|
||||
return averageDiskBytesPerWrite;
|
||||
}
|
||||
|
||||
public void setAverageDiskBytesPerWrite(
|
||||
Map<String, Double> averageDiskBytesPerWrite) {
|
||||
this.averageDiskBytesPerWrite = averageDiskBytesPerWrite;
|
||||
}
|
||||
|
||||
public Map<String, Double> getIdleTimePercent() {
|
||||
return idleTimePercent;
|
||||
}
|
||||
|
||||
public void setIdleTimePercent(Map<String, Double> idleTimePercent) {
|
||||
this.idleTimePercent = idleTimePercent;
|
||||
}
|
||||
|
||||
public Map<String, Double> getAverageDiskQueueLength() {
|
||||
return averageDiskQueueLength;
|
||||
}
|
||||
|
||||
public void setAverageDiskQueueLength(
|
||||
Map<String, Double> averageDiskQueueLength) {
|
||||
this.averageDiskQueueLength = averageDiskQueueLength;
|
||||
}
|
||||
|
||||
public Map<String, Double> getCurrentDiskQueueLength() {
|
||||
return currentDiskQueueLength;
|
||||
}
|
||||
|
||||
public void setCurrentDiskQueueLength(
|
||||
Map<String, Double> currentDiskQueueLength) {
|
||||
this.currentDiskQueueLength = currentDiskQueueLength;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +1,33 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
import java.util.Map;
|
||||
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.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ProcessorModel {
|
||||
private String [] instances;
|
||||
private Map<String ,Double> processorTimePercent;
|
||||
private Map<String ,Double> userTimePercent;
|
||||
private Map<String ,Double> privilegedTimePercent;
|
||||
private Map<String ,Double> dpcTimePercent;// getDpcTimePercent
|
||||
|
||||
public String[] getInstances() {
|
||||
return instances;
|
||||
}
|
||||
public void setInstances(String[] instances) {
|
||||
this.instances = instances;
|
||||
}
|
||||
public Map<String, Double> getProcessorTimePercent() {
|
||||
return processorTimePercent;
|
||||
}
|
||||
public void setProcessorTimePercent(Map<String, Double> processorTimePercent) {
|
||||
this.processorTimePercent = processorTimePercent;
|
||||
}
|
||||
public Map<String, Double> getUserTimePercent() {
|
||||
return userTimePercent;
|
||||
}
|
||||
public void setUserTimePercent(Map<String, Double> userTimePercent) {
|
||||
this.userTimePercent = userTimePercent;
|
||||
}
|
||||
public Map<String, Double> getPrivilegedTimePercent() {
|
||||
return privilegedTimePercent;
|
||||
}
|
||||
public void setPrivilegedTimePercent(Map<String, Double> privilegedTimePercent) {
|
||||
this.privilegedTimePercent = privilegedTimePercent;
|
||||
}
|
||||
public Map<String, Double> getDpcTimePercent() {
|
||||
return dpcTimePercent;
|
||||
}
|
||||
public void setDpcTimePercent(Map<String, Double> dpcTimePercent) {
|
||||
this.dpcTimePercent = dpcTimePercent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<ProcessorModelChild> processorModelList;
|
||||
public ProcessorModel(){
|
||||
processorModelList=new ArrayList<ProcessorModelChild>();
|
||||
}
|
||||
public List<ProcessorModelChild> getProcessorModelList() {
|
||||
return processorModelList;
|
||||
}
|
||||
@XmlElementWrapper(name="instance")
|
||||
@XmlElements({//表示或的关系,list中内容可以为以下两种类型
|
||||
@XmlElement(name="processorModelChild",type=ProcessorModelChild.class),
|
||||
})
|
||||
|
||||
public void setProcessorModelList(List<ProcessorModelChild> processorModelList) {
|
||||
this.processorModelList = processorModelList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
|
||||
public class ProcessorModelChild {
|
||||
private String instance;
|
||||
private Double processorTimePercent;
|
||||
private Double userTimePercent;
|
||||
private Double privilegedTimePercent;
|
||||
private Double dpcTimePercent;// getDpcTimePercent
|
||||
public String getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public void setInstance(String instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
public Double getProcessorTimePercent() {
|
||||
return processorTimePercent;
|
||||
}
|
||||
public void setProcessorTimePercent(Double processorTimePercent) {
|
||||
this.processorTimePercent = processorTimePercent;
|
||||
}
|
||||
public Double getUserTimePercent() {
|
||||
return userTimePercent;
|
||||
}
|
||||
public void setUserTimePercent(Double userTimePercent) {
|
||||
this.userTimePercent = userTimePercent;
|
||||
}
|
||||
public Double getPrivilegedTimePercent() {
|
||||
return privilegedTimePercent;
|
||||
}
|
||||
public void setPrivilegedTimePercent(Double privilegedTimePercent) {
|
||||
this.privilegedTimePercent = privilegedTimePercent;
|
||||
}
|
||||
public Double getDpcTimePercent() {
|
||||
return dpcTimePercent;
|
||||
}
|
||||
public void setDpcTimePercent(Double dpcTimePercent) {
|
||||
this.dpcTimePercent = dpcTimePercent;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package org.bench4q.monitor.service.windows;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bench4q.monitor.model.LogicalDiskModel1;
|
||||
import org.bench4q.monitor.performance.windows.LogicalDiskMonitor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LogicalDiskServiceWindows1 {
|
||||
|
||||
private LogicalDiskMonitor logicalDiskMonitor;
|
||||
|
||||
public LogicalDiskMonitor getLogicalDiskMonitor() {
|
||||
return logicalDiskMonitor;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setLogicalDiskMonitor(LogicalDiskMonitor logicalDiskMonitor) {
|
||||
this.logicalDiskMonitor = logicalDiskMonitor;
|
||||
}
|
||||
|
||||
public LogicalDiskModel1 getLogicalDiskInfo(int idleTime) {
|
||||
|
||||
|
||||
Map<String, Double> freeSpacePercent = new HashMap<String, Double>();
|
||||
Map<String, Double> freeMegabytes = new HashMap<String, Double>();
|
||||
|
||||
// 磁盘活动百分比
|
||||
Map<String, Double> diskTimePercent = new HashMap<String, Double>();
|
||||
Map<String, Double> diskReadTimePercent = new HashMap<String, Double>();
|
||||
Map<String, Double> diskWriteTimePercent = new HashMap<String, Double>();
|
||||
|
||||
// 磁盘平均活动时间
|
||||
Map<String, Double> averageDiskTransferTimeInSecond = new HashMap<String, Double>();
|
||||
Map<String, Double> averageDiskReadTimeInSecond = new HashMap<String, Double>();
|
||||
Map<String, Double> averageDiskWriteTimeInSecond = new HashMap<String, Double>();
|
||||
// 磁盘平均处理的字节
|
||||
Map<String, Double> averageDiskBytesPerTransfer = new HashMap<String, Double>();// 可计算吞吐率
|
||||
Map<String, Double> averageDiskBytesPerRead = new HashMap<String, Double>();
|
||||
Map<String, Double> averageDiskBytesPerWrite = new HashMap<String, Double>();
|
||||
|
||||
// 空闲百分比
|
||||
Map<String, Double> idleTimePercent = new HashMap<String, Double>();
|
||||
// 平均队列长度
|
||||
Map<String, Double> averageDiskQueueLength = new HashMap<String, Double>();
|
||||
// 当前队列长度
|
||||
Map<String, Double> currentDiskQueueLength = new HashMap<String, Double>();
|
||||
|
||||
|
||||
String[] instances =this.getLogicalDiskMonitor().getInstances();
|
||||
|
||||
for (String elem : instances) {
|
||||
freeSpacePercent.put(elem, this.getLogicalDiskMonitor()
|
||||
.getFreeSpacePercent(elem));
|
||||
freeMegabytes.put(elem, this.getLogicalDiskMonitor()
|
||||
.getFreeMegabytes(elem));
|
||||
// 磁盘活动百分比
|
||||
diskTimePercent.put(elem, this.getLogicalDiskMonitor()
|
||||
.getDiskTimePercent(elem, idleTime));
|
||||
diskReadTimePercent.put(elem, this.getLogicalDiskMonitor()
|
||||
.getDiskReadTimePercent(elem, idleTime));
|
||||
diskWriteTimePercent.put(elem, this.getLogicalDiskMonitor()
|
||||
.getDiskWriteTimePercent(elem, idleTime));
|
||||
|
||||
// 磁盘平均活动时间
|
||||
averageDiskTransferTimeInSecond.put(elem, this
|
||||
.getLogicalDiskMonitor()
|
||||
.getAverageDiskTransferTimeInSecond(elem, idleTime));
|
||||
averageDiskReadTimeInSecond.put(elem, this.getLogicalDiskMonitor()
|
||||
.getAverageDiskReadTimeInSecond(elem, idleTime));
|
||||
averageDiskWriteTimeInSecond.put(elem, this.getLogicalDiskMonitor()
|
||||
.getAverageDiskWriteTimeInSecond(elem, idleTime));
|
||||
// 磁盘平均处理的字节
|
||||
averageDiskBytesPerTransfer.put(elem, this.getLogicalDiskMonitor()
|
||||
.getAverageDiskBytesPerTransfer(elem, idleTime));// 可计算吞吐率
|
||||
averageDiskBytesPerRead.put(elem, this.getLogicalDiskMonitor()
|
||||
.getAverageDiskBytesPerRead(elem, idleTime));
|
||||
averageDiskBytesPerWrite.put(elem, this.getLogicalDiskMonitor()
|
||||
.getAverageDiskBytesPerWrite(elem, idleTime));
|
||||
|
||||
// 空闲百分比
|
||||
idleTimePercent.put(elem, this.getLogicalDiskMonitor()
|
||||
.getIdleTimePercent(elem, idleTime));
|
||||
// 平均队列长度
|
||||
averageDiskQueueLength.put(elem, this.getLogicalDiskMonitor()
|
||||
.getAverageDiskQueueLength(elem, idleTime));
|
||||
// 当前队列长度
|
||||
currentDiskQueueLength.put(elem, this.getLogicalDiskMonitor()
|
||||
.getCurrentDiskQueueLength(elem));
|
||||
|
||||
}
|
||||
LogicalDiskModel1 logicalDiskModel = new LogicalDiskModel1();
|
||||
logicalDiskModel.setInstances(instances);
|
||||
logicalDiskModel.setAverageDiskBytesPerRead(averageDiskBytesPerRead);
|
||||
logicalDiskModel
|
||||
.setAverageDiskBytesPerTransfer(averageDiskBytesPerTransfer);
|
||||
logicalDiskModel.setAverageDiskBytesPerWrite(averageDiskBytesPerWrite);
|
||||
logicalDiskModel.setAverageDiskQueueLength(averageDiskQueueLength);
|
||||
logicalDiskModel
|
||||
.setAverageDiskReadTimeInSecond(averageDiskReadTimeInSecond);
|
||||
logicalDiskModel
|
||||
.setAverageDiskTransferTimeInSecond(averageDiskTransferTimeInSecond);
|
||||
logicalDiskModel
|
||||
.setAverageDiskWriteTimeInSecond(averageDiskWriteTimeInSecond);
|
||||
logicalDiskModel.setCurrentDiskQueueLength(currentDiskQueueLength);
|
||||
logicalDiskModel.setDiskReadTimePercent(diskReadTimePercent);
|
||||
logicalDiskModel.setDiskTimePercent(diskTimePercent);
|
||||
logicalDiskModel.setDiskWriteTimePercent(diskWriteTimePercent);
|
||||
logicalDiskModel.setFreeMegabytes(diskWriteTimePercent);
|
||||
logicalDiskModel.setFreeSpacePercent(freeSpacePercent);
|
||||
logicalDiskModel.setIdleTimePercent(idleTimePercent);
|
||||
return logicalDiskModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +1,43 @@
|
|||
package org.bench4q.monitor.service.windows;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bench4q.monitor.model.ProcessorModel;
|
||||
import org.bench4q.monitor.model.ProcessorModelChild;
|
||||
import org.bench4q.monitor.performance.windows.ProcessorMonitor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Service
|
||||
public class ProcessorServicewindows {
|
||||
private ProcessorMonitor processorMonitor;
|
||||
|
||||
public ProcessorMonitor getProcessorMonitor() {
|
||||
return processorMonitor;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setProcessorMonitor(ProcessorMonitor processorMonitor) {
|
||||
this.processorMonitor = processorMonitor;
|
||||
}
|
||||
|
||||
public ProcessorModel getProcessorInfo(int idleTime){
|
||||
ProcessorModel processorModel=new ProcessorModel();
|
||||
String [] temp=this.getProcessorMonitor().getInstances();;
|
||||
|
||||
String instances[]=new String[temp.length-1];
|
||||
for(int i=0;i<temp.length-1;i++){
|
||||
instances[i]=temp[i];
|
||||
public ProcessorModel getProcessorInfo(int idleTime) {
|
||||
String instances[] = this.getProcessorMonitor().getInstances();
|
||||
ProcessorModel processorModel = new ProcessorModel();
|
||||
|
||||
for (String elem : instances) {
|
||||
ProcessorModelChild processorModelChild = new ProcessorModelChild();
|
||||
processorModelChild.setDpcTimePercent(this.getProcessorMonitor()
|
||||
.getDpcTimePercent(elem, idleTime));
|
||||
processorModelChild.setInstance(elem);
|
||||
processorModelChild.setPrivilegedTimePercent(this
|
||||
.getProcessorMonitor().getPrivilegedTimePercent(elem,
|
||||
idleTime));
|
||||
processorModelChild.setProcessorTimePercent(this
|
||||
.getProcessorMonitor().getProcessorTimePercent(elem,
|
||||
idleTime));
|
||||
processorModelChild.setUserTimePercent(this.getProcessorMonitor()
|
||||
.getUserTimePercent(elem, idleTime));
|
||||
processorModel.getProcessorModelList().add(processorModelChild);
|
||||
}
|
||||
Map<String ,Double> processorTimePercent=new HashMap<String, Double>();
|
||||
Map<String ,Double> userTimePercent=new HashMap<String, Double>();
|
||||
Map<String ,Double> privilegedTimePercent=new HashMap<String, Double>();
|
||||
Map<String ,Double> dpcTimePercent=new HashMap<String, Double>();// getDpcTimePercent
|
||||
|
||||
for(String elem:instances){
|
||||
processorTimePercent.put(elem, this.getProcessorMonitor().getProcessorTimePercent(elem, idleTime));
|
||||
userTimePercent.put(elem, this.getProcessorMonitor().getUserTimePercent(elem, idleTime));
|
||||
privilegedTimePercent.put(elem, this.getProcessorMonitor().getPrivilegedTimePercent(elem, idleTime));
|
||||
dpcTimePercent.put(elem, this.getProcessorMonitor().getDpcTimePercent(elem, idleTime));
|
||||
}
|
||||
|
||||
processorModel.setDpcTimePercent(dpcTimePercent);
|
||||
processorModel.setInstances(instances);
|
||||
processorModel.setPrivilegedTimePercent(privilegedTimePercent);
|
||||
processorModel.setProcessorTimePercent(processorTimePercent);
|
||||
processorModel.setUserTimePercent(userTimePercent);
|
||||
return processorModel;
|
||||
return processorModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author wxr
|
||||
*
|
||||
*/
|
||||
package org.bench4q.monitor.service.windows;
|
|
@ -60,59 +60,16 @@ public class LogicalDiskTest {
|
|||
|
||||
}
|
||||
|
||||
/*public void result(LogicalDiskModelChild1 LogicalDiskModelChild) {
|
||||
for (String elem : LogicalDiskModelChild.getInstances()) {
|
||||
System.out.println(elem);
|
||||
System.out.println("freeSpacePercent" + ": "
|
||||
+ LogicalDiskModelChild.getFreeSpacePercent().get(elem));
|
||||
System.out.println("freeMegabytes" + ": "
|
||||
+ LogicalDiskModelChild.getFreeMegabytes().get(elem));
|
||||
System.out.println("diskTimePercent" + ": "
|
||||
+ LogicalDiskModelChild.getDiskTimePercent().get(elem));
|
||||
System.out.println("diskReadTimePercent" + ": "
|
||||
+ LogicalDiskModelChild.getDiskReadTimePercent().get(elem));
|
||||
System.out.println("diskWriteTimePercent" + ": "
|
||||
+ LogicalDiskModelChild.getDiskWriteTimePercent().get(elem));
|
||||
System.out.println("averageDiskTransferTimeInSecond"
|
||||
+ ": "
|
||||
+ LogicalDiskModelChild.getAverageDiskTransferTimeInSecond()
|
||||
.get(elem));
|
||||
System.out.println("averageDiskReadTimeInSecond"
|
||||
+ ": "
|
||||
+ LogicalDiskModelChild.getAverageDiskReadTimeInSecond().get(
|
||||
elem));
|
||||
System.out.println("averageDiskWriteTimeInSecond"
|
||||
+ ": "
|
||||
+ LogicalDiskModelChild.getAverageDiskWriteTimeInSecond().get(
|
||||
elem));
|
||||
System.out.println("averageDiskBytesPerTransfer"
|
||||
+ ": "
|
||||
+ LogicalDiskModelChild.getAverageDiskBytesPerTransfer().get(
|
||||
elem));
|
||||
System.out.println("averageDiskBytesPerRead" + ": "
|
||||
+ LogicalDiskModelChild.getAverageDiskBytesPerRead().get(elem));
|
||||
System.out.println("averageDiskBytesPerWrite" + ": "
|
||||
+ LogicalDiskModelChild.getAverageDiskBytesPerWrite().get(elem));
|
||||
System.out.println("idelTimePercent"+":"+LogicalDiskModelChild.getIdleTimePercent().get(elem));
|
||||
System.out.println("averageDiskQueueLength"+":"+LogicalDiskModelChild.getAverageDiskQueueLength().get(elem));
|
||||
System.out.println("currentDiskQueueLength"+":"+LogicalDiskModelChild.getCurrentDiskQueueLength().get(elem));
|
||||
// Ć˝žůśÓÁĐł¤śČ
|
||||
|
||||
// ľąÇ°śÓÁĐł¤śČ
|
||||
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
public void result(LogicalDiskModel logicalDiskModel){
|
||||
|
||||
List<LogicalDiskModelChild> list=logicalDiskModel.getLogicalDiskList();
|
||||
Iterator<LogicalDiskModelChild> iterator=list.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
LogicalDiskModelChild logicalDiskModelChild=iterator.next();
|
||||
|
||||
|
||||
System.out.println(logicalDiskModelChild.getInstance()+":");
|
||||
System.out.println(logicalDiskModelChild.getInstance());
|
||||
System.out.println(logicalDiskModelChild.getFreeMegabytes());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@ package org.bench4q.monitor.test;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.bench4q.monitor.model.ProcessorModel;
|
||||
import org.bench4q.monitor.model.ProcessorModelChild;
|
||||
import org.bench4q.monitor.test.communication.HttpRequester;
|
||||
import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -55,12 +57,14 @@ public class ProcessorTest {
|
|||
|
||||
public void result(ProcessorModel ProcessorModel) {
|
||||
|
||||
for(String elem: ProcessorModel.getInstances()){
|
||||
System.out.println(elem+":");
|
||||
System.out.println("dpcTimePercent="+ProcessorModel.getDpcTimePercent().get(elem));
|
||||
System.out.println("privilegedTimePercent="+ProcessorModel.getPrivilegedTimePercent().get(elem));
|
||||
System.out.println("processorTimePercent="+ProcessorModel.getProcessorTimePercent().get(elem));
|
||||
System.out.println("userTimePercent="+ProcessorModel.getUserTimePercent().get(elem));
|
||||
Iterator<ProcessorModelChild> iterator=ProcessorModel.getProcessorModelList().iterator();
|
||||
while(iterator.hasNext()){
|
||||
ProcessorModelChild processorModelChild=iterator.next();
|
||||
System.out.println("instance"+processorModelChild.getInstance());
|
||||
System.out.println("dpcTimePercent"+processorModelChild.getDpcTimePercent());
|
||||
System.out.println("privilegedTimePercent"+processorModelChild.getPrivilegedTimePercent());
|
||||
System.out.println("processorTimePercent"+processorModelChild.getProcessorTimePercent());
|
||||
System.out.println("userTimePercent"+processorModelChild.getUserTimePercent());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue