Change the struct of LogicalDiskModel.From Map to List
This commit is contained in:
parent
c7fd4970d1
commit
470ed2c635
|
@ -63,6 +63,7 @@ public class Main {
|
|||
for (String elem : logicalDiskInstances) {
|
||||
System.out.println(elem);
|
||||
}
|
||||
System.out.println(logicalDiskMonitor.getFreeMegabytes("C:"));
|
||||
String[] logicalDiskCounter = logicalDiskMonitor.getCounterList();
|
||||
for (String elem : logicalDiskCounter) {
|
||||
System.out.println(elem);
|
||||
|
|
|
@ -9,7 +9,7 @@ public class MonitorController {
|
|||
private int idleTime;
|
||||
public MonitorController(){
|
||||
this.osNameString=System.getProperty("os.name").toLowerCase();
|
||||
this.idleTime=10;
|
||||
this.idleTime=100;
|
||||
}
|
||||
public String getOsNameString() {
|
||||
return osNameString;
|
||||
|
|
|
@ -1,170 +1,35 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* @author wxr
|
||||
*
|
||||
*/
|
||||
|
||||
@XmlRootElement(name = "LogicalDisk")
|
||||
public class LogicalDiskModel {
|
||||
|
||||
private String[] instances;
|
||||
private Map<String, Double> freeSpacePercent;
|
||||
private Map<String, Double> freeMegabytes;
|
||||
@XmlElementWrapper(name="instance")
|
||||
@XmlElements({//表示或的关系,list中内容可以为以下两种类型
|
||||
@XmlElement(name="LogicalDiskModelChild",type=LogicalDiskModelChild.class),
|
||||
})
|
||||
|
||||
// 磁盘活动百分比
|
||||
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 List<LogicalDiskModelChild> logicalDiskList;
|
||||
public LogicalDiskModel(){
|
||||
this.logicalDiskList=new ArrayList<LogicalDiskModelChild>();
|
||||
}
|
||||
|
||||
// 空闲百分比
|
||||
private Map<String, Double> idleTimePercent;
|
||||
// 平均队列长度
|
||||
private Map<String, Double> averageDiskQueueLength;
|
||||
// 当前队列长度
|
||||
private Map<String, Double> currentDiskQueueLength;
|
||||
|
||||
@XmlElement(name = "Instance")
|
||||
public String[] getInstances() {
|
||||
return instances;
|
||||
public List<LogicalDiskModelChild> getLogicalDiskList() {
|
||||
return logicalDiskList;
|
||||
}
|
||||
|
||||
public void setInstances(String[] instances) {
|
||||
this.instances = instances;
|
||||
public void setLogicalDiskList ( ArrayList<LogicalDiskModelChild> logicalDiskList) {
|
||||
this.logicalDiskList = logicalDiskList;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class LogicalDiskModelChild{
|
||||
private String instance;
|
||||
private double freeSpacePercent;
|
||||
private double freeMegabytes;
|
||||
|
||||
// 磁盘活动百分比
|
||||
private double diskTimePercent;
|
||||
private double diskReadTimePercent;
|
||||
private double diskWriteTimePercent;
|
||||
|
||||
// 磁盘平均活动时间
|
||||
private double averageDiskTransferTimeInSecond;
|
||||
private double averageDiskReadTimeInSecond;
|
||||
private double averageDiskWriteTimeInSecond;
|
||||
// 磁盘平均处理的字节
|
||||
private double averageDiskBytesPerTransfer;// 可计算吞吐率
|
||||
private double averageDiskBytesPerRead;
|
||||
private double averageDiskBytesPerWrite;
|
||||
|
||||
// 空闲百分比
|
||||
private double idleTimePercent;
|
||||
// 平均队列长度
|
||||
private double averageDiskQueueLength;
|
||||
// 当前队列长度
|
||||
private double currentDiskQueueLength;
|
||||
public String getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public void setInstance(String instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
public double getFreeSpacePercent() {
|
||||
return freeSpacePercent;
|
||||
}
|
||||
public void setFreeSpacePercent(double freeSpacePercent) {
|
||||
this.freeSpacePercent = freeSpacePercent;
|
||||
}
|
||||
public double getFreeMegabytes() {
|
||||
return freeMegabytes;
|
||||
}
|
||||
public void setFreeMegabytes(double freeMegabytes) {
|
||||
this.freeMegabytes = freeMegabytes;
|
||||
}
|
||||
public double getDiskTimePercent() {
|
||||
return diskTimePercent;
|
||||
}
|
||||
public void setDiskTimePercent(double diskTimePercent) {
|
||||
this.diskTimePercent = diskTimePercent;
|
||||
}
|
||||
public double getDiskReadTimePercent() {
|
||||
return diskReadTimePercent;
|
||||
}
|
||||
public void setDiskReadTimePercent(double diskReadTimePercent) {
|
||||
this.diskReadTimePercent = diskReadTimePercent;
|
||||
}
|
||||
public double getDiskWriteTimePercent() {
|
||||
return diskWriteTimePercent;
|
||||
}
|
||||
public void setDiskWriteTimePercent(double diskWriteTimePercent) {
|
||||
this.diskWriteTimePercent = diskWriteTimePercent;
|
||||
}
|
||||
public double getAverageDiskTransferTimeInSecond() {
|
||||
return averageDiskTransferTimeInSecond;
|
||||
}
|
||||
public void setAverageDiskTransferTimeInSecond(
|
||||
double averageDiskTransferTimeInSecond) {
|
||||
this.averageDiskTransferTimeInSecond = averageDiskTransferTimeInSecond;
|
||||
}
|
||||
public double getAverageDiskReadTimeInSecond() {
|
||||
return averageDiskReadTimeInSecond;
|
||||
}
|
||||
public void setAverageDiskReadTimeInSecond(double averageDiskReadTimeInSecond) {
|
||||
this.averageDiskReadTimeInSecond = averageDiskReadTimeInSecond;
|
||||
}
|
||||
public double getAverageDiskWriteTimeInSecond() {
|
||||
return averageDiskWriteTimeInSecond;
|
||||
}
|
||||
public void setAverageDiskWriteTimeInSecond(double averageDiskWriteTimeInSecond) {
|
||||
this.averageDiskWriteTimeInSecond = averageDiskWriteTimeInSecond;
|
||||
}
|
||||
public double getAverageDiskBytesPerTransfer() {
|
||||
return averageDiskBytesPerTransfer;
|
||||
}
|
||||
public void setAverageDiskBytesPerTransfer(double averageDiskBytesPerTransfer) {
|
||||
this.averageDiskBytesPerTransfer = averageDiskBytesPerTransfer;
|
||||
}
|
||||
public double getAverageDiskBytesPerRead() {
|
||||
return averageDiskBytesPerRead;
|
||||
}
|
||||
public void setAverageDiskBytesPerRead(double averageDiskBytesPerRead) {
|
||||
this.averageDiskBytesPerRead = averageDiskBytesPerRead;
|
||||
}
|
||||
public double getAverageDiskBytesPerWrite() {
|
||||
return averageDiskBytesPerWrite;
|
||||
}
|
||||
public void setAverageDiskBytesPerWrite(double averageDiskBytesPerWrite) {
|
||||
this.averageDiskBytesPerWrite = averageDiskBytesPerWrite;
|
||||
}
|
||||
public double getIdleTimePercent() {
|
||||
return idleTimePercent;
|
||||
}
|
||||
public void setIdleTimePercent(double idleTimePercent) {
|
||||
this.idleTimePercent = idleTimePercent;
|
||||
}
|
||||
public double getAverageDiskQueueLength() {
|
||||
return averageDiskQueueLength;
|
||||
}
|
||||
public void setAverageDiskQueueLength(double averageDiskQueueLength) {
|
||||
this.averageDiskQueueLength = averageDiskQueueLength;
|
||||
}
|
||||
public double getCurrentDiskQueueLength() {
|
||||
return currentDiskQueueLength;
|
||||
}
|
||||
public void setCurrentDiskQueueLength(double currentDiskQueueLength) {
|
||||
this.currentDiskQueueLength = currentDiskQueueLength;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,104 +1,56 @@
|
|||
package org.bench4q.monitor.service.windows;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bench4q.monitor.model.LogicalDiskModel;
|
||||
import org.bench4q.monitor.model.LogicalDiskModelChild;
|
||||
import org.bench4q.monitor.performance.windows.LogicalDiskMonitor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LogicalDiskServiceWindows {
|
||||
|
||||
private LogicalDiskMonitor logicalDiskMonitor;
|
||||
private LogicalDiskMonitor logicalDiskMonitor;
|
||||
|
||||
public LogicalDiskMonitor getLogicalDiskMonitor() {
|
||||
return logicalDiskMonitor;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setLogicalDiskMonitor(LogicalDiskMonitor logicalDiskMonitor) {
|
||||
this.logicalDiskMonitor = logicalDiskMonitor;
|
||||
}
|
||||
|
||||
public LogicalDiskModel getLogicalDiskInfo(int idleTime){
|
||||
public LogicalDiskModel getLogicalDiskInfo(int idleTime) {
|
||||
|
||||
String []instances=this.getLogicalDiskMonitor().getInstances();
|
||||
LogicalDiskModel logicalDiskModel=new LogicalDiskModel();
|
||||
|
||||
String []temp;
|
||||
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>();
|
||||
|
||||
temp=this.getLogicalDiskMonitor().getInstances();
|
||||
String[] instances=new String[temp.length-1];
|
||||
for(int i=0;i<temp.length-1;i++)
|
||||
instances[i]=temp[i];
|
||||
for(String elem:instances){
|
||||
|
||||
freeSpacePercent.put(elem, this.getLogicalDiskMonitor().getFreeSpacePercent(elem));
|
||||
freeMegabytes.put(elem, this.getLogicalDiskMonitor().getFreeMegabytes(elem));
|
||||
LogicalDiskModelChild logicalDiskModelChild=new LogicalDiskModelChild();
|
||||
logicalDiskModelChild.setInstance(elem);
|
||||
logicalDiskModelChild.setAverageDiskBytesPerRead(this.getLogicalDiskMonitor().getAverageDiskBytesPerRead(elem, idleTime));
|
||||
logicalDiskModelChild.setAverageDiskBytesPerTransfer(this.getLogicalDiskMonitor().getAverageDiskBytesPerTransfer(elem, idleTime));
|
||||
logicalDiskModelChild.setAverageDiskBytesPerWrite(this.getLogicalDiskMonitor().getAverageDiskBytesPerWrite(elem, idleTime));
|
||||
logicalDiskModelChild.setAverageDiskQueueLength(this.getLogicalDiskMonitor().getAverageDiskQueueLength(elem, idleTime));
|
||||
logicalDiskModelChild.setAverageDiskReadTimeInSecond(this.getLogicalDiskMonitor().getAverageDiskReadQueueLength(elem, idleTime));
|
||||
|
||||
// 磁盘活动百分比
|
||||
diskTimePercent.put(elem, this.getLogicalDiskMonitor().getDiskTimePercent(elem, idleTime));
|
||||
diskReadTimePercent.put(elem, this.getLogicalDiskMonitor().getDiskReadTimePercent(elem, idleTime));
|
||||
diskWriteTimePercent.put(elem, this.getLogicalDiskMonitor().getDiskWriteTimePercent(elem, idleTime));
|
||||
logicalDiskModelChild.setAverageDiskTransferTimeInSecond(this.getLogicalDiskMonitor().getAverageDiskTransferTimeInSecond(elem, idleTime));
|
||||
logicalDiskModelChild.setCurrentDiskQueueLength(this.getLogicalDiskMonitor().getCurrentDiskQueueLength(elem));
|
||||
logicalDiskModelChild.setAverageDiskWriteTimeInSecond(this.getLogicalDiskMonitor().getAverageDiskWriteTimeInSecond(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));
|
||||
logicalDiskModelChild.setDiskReadTimePercent(this.getLogicalDiskMonitor().getDiskReadTimePercent(elem, idleTime));
|
||||
logicalDiskModelChild.setDiskTimePercent(this.getLogicalDiskMonitor().getDiskTimePercent(elem, idleTime));
|
||||
logicalDiskModelChild.setDiskWriteTimePercent(this.getLogicalDiskMonitor().getDiskWriteTimePercent(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));
|
||||
logicalDiskModelChild.setFreeMegabytes(this.getLogicalDiskMonitor().getFreeMegabytes(elem));
|
||||
logicalDiskModelChild.setFreeSpacePercent(this.getLogicalDiskMonitor().getFreeSpacePercent(elem));
|
||||
logicalDiskModelChild.setIdleTimePercent(this.getLogicalDiskMonitor().getIdleTimePercent(elem, idleTime));
|
||||
|
||||
logicalDiskModel.getLogicalDiskList().add(logicalDiskModelChild);
|
||||
}
|
||||
LogicalDiskModel logicalDiskModel=new LogicalDiskModel();
|
||||
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;
|
||||
|
||||
return logicalDiskModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
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,12 +1,17 @@
|
|||
package org.bench4q.monitor.test;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.bench4q.monitor.model.LogicalDiskModelChild;
|
||||
import org.bench4q.monitor.model.LogicalDiskModel;
|
||||
import org.bench4q.monitor.test.communication.HttpRequester;
|
||||
import org.bench4q.monitor.test.communication.HttpRequester.HttpResponse;
|
||||
|
@ -55,51 +60,62 @@ public class LogicalDiskTest {
|
|||
|
||||
}
|
||||
|
||||
public void result(LogicalDiskModel logicalDiskModel) {
|
||||
|
||||
for (String elem : logicalDiskModel.getInstances()) {
|
||||
/*public void result(LogicalDiskModelChild1 LogicalDiskModelChild) {
|
||||
for (String elem : LogicalDiskModelChild.getInstances()) {
|
||||
System.out.println(elem);
|
||||
System.out.println("freeSpacePercent" + ": "
|
||||
+ logicalDiskModel.getFreeSpacePercent().get(elem));
|
||||
+ LogicalDiskModelChild.getFreeSpacePercent().get(elem));
|
||||
System.out.println("freeMegabytes" + ": "
|
||||
+ logicalDiskModel.getFreeMegabytes().get(elem));
|
||||
+ LogicalDiskModelChild.getFreeMegabytes().get(elem));
|
||||
System.out.println("diskTimePercent" + ": "
|
||||
+ logicalDiskModel.getDiskTimePercent().get(elem));
|
||||
+ LogicalDiskModelChild.getDiskTimePercent().get(elem));
|
||||
System.out.println("diskReadTimePercent" + ": "
|
||||
+ logicalDiskModel.getDiskReadTimePercent().get(elem));
|
||||
+ LogicalDiskModelChild.getDiskReadTimePercent().get(elem));
|
||||
System.out.println("diskWriteTimePercent" + ": "
|
||||
+ logicalDiskModel.getDiskWriteTimePercent().get(elem));
|
||||
+ LogicalDiskModelChild.getDiskWriteTimePercent().get(elem));
|
||||
System.out.println("averageDiskTransferTimeInSecond"
|
||||
+ ": "
|
||||
+ logicalDiskModel.getAverageDiskTransferTimeInSecond()
|
||||
+ LogicalDiskModelChild.getAverageDiskTransferTimeInSecond()
|
||||
.get(elem));
|
||||
System.out.println("averageDiskReadTimeInSecond"
|
||||
+ ": "
|
||||
+ logicalDiskModel.getAverageDiskReadTimeInSecond().get(
|
||||
+ LogicalDiskModelChild.getAverageDiskReadTimeInSecond().get(
|
||||
elem));
|
||||
System.out.println("averageDiskWriteTimeInSecond"
|
||||
+ ": "
|
||||
+ logicalDiskModel.getAverageDiskWriteTimeInSecond().get(
|
||||
+ LogicalDiskModelChild.getAverageDiskWriteTimeInSecond().get(
|
||||
elem));
|
||||
System.out.println("averageDiskBytesPerTransfer"
|
||||
+ ": "
|
||||
+ logicalDiskModel.getAverageDiskBytesPerTransfer().get(
|
||||
+ LogicalDiskModelChild.getAverageDiskBytesPerTransfer().get(
|
||||
elem));
|
||||
System.out.println("averageDiskBytesPerRead" + ": "
|
||||
+ logicalDiskModel.getAverageDiskBytesPerRead().get(elem));
|
||||
+ LogicalDiskModelChild.getAverageDiskBytesPerRead().get(elem));
|
||||
System.out.println("averageDiskBytesPerWrite" + ": "
|
||||
+ logicalDiskModel.getAverageDiskBytesPerWrite().get(elem));
|
||||
System.out.println("idelTimePercent"+":"+logicalDiskModel.getIdleTimePercent().get(elem));
|
||||
System.out.println("averageDiskQueueLength"+":"+logicalDiskModel.getAverageDiskQueueLength().get(elem));
|
||||
System.out.println("currentDiskQueueLength"+":"+logicalDiskModel.getCurrentDiskQueueLength().get(elem));
|
||||
+ 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.getFreeMegabytes());
|
||||
}
|
||||
|
||||
}
|
||||
public LogicalDiskModel extractLogicalDiskModel(String content)
|
||||
throws JAXBException {
|
||||
|
||||
|
|
Loading…
Reference in New Issue