add the LogicalDisk to Linux
This commit is contained in:
parent
5133ec0fa4
commit
e19a82b626
|
@ -5,6 +5,24 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
@XmlRootElement
|
||||
public class NetworkInterfaceModelChild {
|
||||
private double bytesTotalPerSecond;
|
||||
private double bytesReceivedPerSecond;
|
||||
private double bytesSentPerSecond;
|
||||
public double getBytesReceivedPerSecond() {
|
||||
return bytesReceivedPerSecond;
|
||||
}
|
||||
|
||||
public void setBytesReceivedPerSecond(double bytesReceivedPerSecond) {
|
||||
this.bytesReceivedPerSecond = bytesReceivedPerSecond;
|
||||
}
|
||||
|
||||
public double getBytesSentPerSecond() {
|
||||
return bytesSentPerSecond;
|
||||
}
|
||||
|
||||
public void setBytesSentPerSecond(double bytesSentPerSecond) {
|
||||
this.bytesSentPerSecond = bytesSentPerSecond;
|
||||
}
|
||||
|
||||
private String instance;
|
||||
public String getInstance() {
|
||||
return instance;
|
||||
|
|
|
@ -25,25 +25,27 @@ public class LogicalDiskMonitor extends LinuxFileRead {
|
|||
freeSpacePercent = new HashMap<String, Double>();
|
||||
freeMegabytes = new HashMap<String, Double>();
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD>ٷֱ<EFBFBD>
|
||||
// 锟斤拷锟教活动锟劫分憋拷
|
||||
diskTimePercent = new HashMap<String, Double>();
|
||||
diskReadTimePercent = new HashMap<String, Double>();
|
||||
diskWriteTimePercent = new HashMap<String, Double>();
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
// 锟斤拷锟斤拷平锟斤拷疃憋拷锟<EFBFBD>
|
||||
averageDiskTransferTimeInSecond = new HashMap<String, Double>();
|
||||
averageDiskReadTimeInSecond = new HashMap<String, Double>();
|
||||
averageDiskWriteTimeInSecond = new HashMap<String, Double>();
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
// 锟斤拷锟斤拷平锟斤拷锟斤拷锟斤拷纸锟<EFBFBD>
|
||||
diskBytesPerSecond = new HashMap<String, Double>();
|
||||
diskReadBytesPerSecond = new HashMap<String, Double>();
|
||||
diskWriteBytesPerSecond = new HashMap<String, Double>();
|
||||
idleTimePercent = new HashMap<String, Double>();
|
||||
// ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 平锟斤拷锟斤拷谐锟斤拷锟<EFBFBD>
|
||||
averageDiskQueueLength = new HashMap<String, Double>();
|
||||
// <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 锟斤拷前锟斤拷锟叫筹拷锟斤拷
|
||||
currentDiskQueueLength = new HashMap<String, Double>();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private List<String> instances;
|
||||
|
@ -142,25 +144,28 @@ public class LogicalDiskMonitor extends LinuxFileRead {
|
|||
private Map<String, Double> freeSpacePercent;
|
||||
private Map<String, Double> freeMegabytes;
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD>ٷֱ<EFBFBD>
|
||||
// 锟斤拷锟教活动锟劫分憋拷
|
||||
private Map<String, Double> diskTimePercent;
|
||||
private Map<String, Double> diskReadTimePercent;
|
||||
private Map<String, Double> diskWriteTimePercent;
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
||||
// 锟斤拷锟斤拷平锟斤拷疃憋拷锟<EFBFBD>
|
||||
private Map<String, Double> averageDiskTransferTimeInSecond;
|
||||
private Map<String, Double> averageDiskReadTimeInSecond;
|
||||
private Map<String, Double> averageDiskWriteTimeInSecond;
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
|
||||
// 锟斤拷锟斤拷平锟斤拷锟斤拷锟斤拷纸锟<EFBFBD>
|
||||
private Map<String, Double> diskBytesPerSecond;
|
||||
private Map<String, Double> diskReadBytesPerSecond;;
|
||||
private Map<String, Double> diskWriteBytesPerSecond;
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>аٷֱ<EFBFBD>
|
||||
|
||||
// 锟斤拷锟叫百分憋拷
|
||||
private Map<String, Double> idleTimePercent;
|
||||
// ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 平锟斤拷锟斤拷谐锟斤拷锟<EFBFBD>
|
||||
private Map<String, Double> averageDiskQueueLength;
|
||||
// <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 锟斤拷前锟斤拷锟叫筹拷锟斤拷
|
||||
|
||||
private Map<String, Double> currentDiskQueueLength;
|
||||
|
||||
public LogicalDiskModel getLogicalDiskInfo(int idleTime)
|
||||
|
@ -186,32 +191,27 @@ public class LogicalDiskMonitor extends LinuxFileRead {
|
|||
|
||||
str = token.nextToken();
|
||||
String elem = str;
|
||||
instances_temp.add(elem);// 分区名字
|
||||
str = token.nextToken();// 第1个域:读磁盘的次数,成功完成读的总次数。
|
||||
instances_temp.add(elem);// 鍒嗗尯鍚嶅瓧
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氳纾佺洏鐨勬鏁帮紝鎴愬姛瀹屾垚璇荤殑鎬绘鏁般<EFBFBD>
|
||||
readTimes.put(elem, (double)Integer.parseInt(str));
|
||||
|
||||
str = token.nextToken();// 第2个域:合并读次数, field 6 –
|
||||
// 合并写次数。为了效率可能会合并相邻的读和写。从而两次4K的读在它最终被处理到磁盘上之前可能会变成一次8K的读,才被计数(和排队),因此只有一次I/O操作。这个域使你知道这样的操作有多频繁。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬悎骞惰娆℃暟锛<EFBFBD>field 6 鈥<EFBFBD> // 鍚堝苟鍐欐鏁般<EFBFBD>涓轰簡鏁堢巼鍙兘浼氬悎骞剁浉閭荤殑璇诲拰鍐欍<EFBFBD>浠庤<EFBFBD>涓ゆ4K鐨勮鍦ㄥ畠鏈<EFBFBD>粓琚鐞嗗埌纾佺洏涓婁箣鍓嶅彲鑳戒細鍙樻垚涓<EFBFBD>8K鐨勮锛屾墠琚鏁帮紙鍜屾帓闃燂級锛屽洜姝ゅ彧鏈変竴娆/O鎿嶄綔銆傝繖涓煙浣夸綘鐭ラ亾杩欐牱鐨勬搷浣滄湁澶氶绻併<EFBFBD>
|
||||
|
||||
str = token.nextToken();// 第3个域:读扇区的次数,成功读过的扇区总次数。
|
||||
secRead.put(elem, (double)Integer.parseInt(str));
|
||||
str = token.nextToken();// 第4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数(用__make_request()到end_that_request_last()测量)。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氳鎵囧尯鐨勬鏁帮紝鎴愬姛璇昏繃鐨勬墖鍖烘<EFBFBD>娆℃暟銆<EFBFBD> secRead.put(elem, (double)Integer.parseInt(str));
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氳鑺辫垂鐨勬绉掓暟锛岃繖鏄墍鏈夎鎿嶄綔鎵<EFBFBD>姳璐圭殑姣鏁帮紙鐢╛_make_request()鍒癳nd_that_request_last()娴嬮噺锛夈<EFBFBD>
|
||||
readTmie.put(elem,(double) Integer.parseInt(str));// ms
|
||||
str = token.nextToken();// 第5个域:写完成的次数,成功写完成的总次数。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬啓瀹屾垚鐨勬鏁帮紝鎴愬姛鍐欏畬鎴愮殑鎬绘鏁般<EFBFBD>
|
||||
str=token.nextToken();
|
||||
writeTimes.put(elem, (double)Integer.parseInt(str));
|
||||
str = token.nextToken();// 第7个域:写扇区的次数,成功写扇区总次数。
|
||||
secWrite.put(elem, (double)Integer.parseInt(str));
|
||||
str = token.nextToken();// 第8个域:写花费的毫秒数,这是所有写操作所花费的毫秒数(用__make_request()到end_that_request_last()测量)。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬啓鎵囧尯鐨勬鏁帮紝鎴愬姛鍐欐墖鍖烘<EFBFBD>娆℃暟銆<EFBFBD> secWrite.put(elem, (double)Integer.parseInt(str));
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬啓鑺辫垂鐨勬绉掓暟锛岃繖鏄墍鏈夊啓鎿嶄綔鎵<EFBFBD>姳璐圭殑姣鏁帮紙鐢╛_make_request()鍒癳nd_that_request_last()娴嬮噺锛夈<EFBFBD>
|
||||
writeTime.put(elem, (double)Integer.parseInt(str));
|
||||
str = token.nextToken();// 第9个域:I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛欼/O鐨勫綋鍓嶈繘搴︼紝鍙湁杩欎釜鍩熷簲璇ユ槸0銆傚綋璇锋眰琚氦缁欓<EFBFBD>褰撶殑request_queue_t鏃跺鍔犲拰璇锋眰瀹屾垚鏃跺噺灏忋<EFBFBD>
|
||||
currentDiskQueueLength_p.put(elem,
|
||||
(double) Integer.parseInt(str));
|
||||
str = token.nextToken();// 第10个域:花在I/O操作上的毫秒数,这个域会增长只要field
|
||||
// 9不为0。
|
||||
|
||||
str = token.nextToken();// 第11个域:加权,花在I/O操作上的毫秒数,在每次I/O开始,I/O结束,I/O合并时这个域都会增加。这可以给I/O完成时间和存储那些可以累积的提供一个便利的测量标准
|
||||
|
||||
str = token.nextToken();// 绗<EFBFBD>0涓煙锛氳姳鍦↖/O鎿嶄綔涓婄殑姣鏁帮紝杩欎釜鍩熶細澧為暱鍙field
|
||||
// 9涓嶄负0銆<EFBFBD>
|
||||
str = token.nextToken();// 绗<EFBFBD>1涓煙锛氬姞鏉冿紝鑺卞湪I/O鎿嶄綔涓婄殑姣鏁帮紝鍦ㄦ瘡娆/O寮<EFBFBD>锛孖/O缁撴潫锛孖/O鍚堝苟鏃惰繖涓煙閮戒細澧炲姞銆傝繖鍙互缁橧/O瀹屾垚鏃堕棿鍜屽瓨鍌ㄩ偅浜涘彲浠ョ疮绉殑鎻愪緵涓<EFBFBD>釜渚垮埄鐨勬祴閲忔爣鍑<EFBFBD>
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -228,39 +228,36 @@ public class LogicalDiskMonitor extends LinuxFileRead {
|
|||
if (!(str.equals("0"))) {
|
||||
str = token.nextToken();
|
||||
String elem = str;
|
||||
str = token.nextToken();// 第1个域:读磁盘的次数,成功完成读的总次数。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氳纾佺洏鐨勬鏁帮紝鎴愬姛瀹屾垚璇荤殑鎬绘鏁般<EFBFBD>
|
||||
|
||||
readTimes.put(elem,
|
||||
(double)(Integer.parseInt(str) - readTimes.get(elem)));
|
||||
|
||||
str = token.nextToken();// 第2个域:合并读次数, field 6 –
|
||||
// 合并写次数。为了效率可能会合并相邻的读和写。从而两次4K的读在它最终被处理到磁盘上之前可能会变成一次8K的读,才被计数(和排队),因此只有一次I/O操作。这个域使你知道这样的操作有多频繁。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬悎骞惰娆℃暟锛<EFBFBD>field 6 鈥<EFBFBD> // 鍚堝苟鍐欐鏁般<EFBFBD>涓轰簡鏁堢巼鍙兘浼氬悎骞剁浉閭荤殑璇诲拰鍐欍<EFBFBD>浠庤<EFBFBD>涓ゆ4K鐨勮鍦ㄥ畠鏈<EFBFBD>粓琚鐞嗗埌纾佺洏涓婁箣鍓嶅彲鑳戒細鍙樻垚涓<EFBFBD>8K鐨勮锛屾墠琚鏁帮紙鍜屾帓闃燂級锛屽洜姝ゅ彧鏈変竴娆/O鎿嶄綔銆傝繖涓煙浣夸綘鐭ラ亾杩欐牱鐨勬搷浣滄湁澶氶绻併<EFBFBD>
|
||||
|
||||
str = token.nextToken();// 第3个域:读扇区的次数,成功读过的扇区总次数。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氳鎵囧尯鐨勬鏁帮紝鎴愬姛璇昏繃鐨勬墖鍖烘<EFBFBD>娆℃暟銆<EFBFBD>
|
||||
secRead.put(elem,
|
||||
Integer.parseInt(str) - secRead.get(elem));
|
||||
str = token.nextToken();// 第4个域:读花费的毫秒数,这是所有读操作所花费的毫秒数(用__make_request()到end_that_request_last()测量)。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氳鑺辫垂鐨勬绉掓暟锛岃繖鏄墍鏈夎鎿嶄綔鎵<EFBFBD>姳璐圭殑姣鏁帮紙鐢╛_make_request()鍒癳nd_that_request_last()娴嬮噺锛夈<EFBFBD>
|
||||
readTmie.put(elem,
|
||||
Integer.parseInt(str) - readTmie.get(elem));// ms
|
||||
str = token.nextToken();// 第5个域:写完成的次数,成功写完成的总次数。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬啓瀹屾垚鐨勬鏁帮紝鎴愬姛鍐欏畬鎴愮殑鎬绘鏁般<EFBFBD>
|
||||
writeTimes.put(elem,
|
||||
Integer.parseInt(str) - writeTimes.get(elem));
|
||||
str=token.nextToken();//第6个域:合并写完成次数 -----合并写次数。
|
||||
str = token.nextToken();// 第7个域:写扇区的次数,成功写扇区总次数。
|
||||
str=token.nextToken();//绗<EFBFBD>涓煙锛氬悎骞跺啓瀹屾垚娆℃暟 -----鍚堝苟鍐欐鏁般<EFBFBD>
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬啓鎵囧尯鐨勬鏁帮紝鎴愬姛鍐欐墖鍖烘<EFBFBD>娆℃暟銆<EFBFBD>
|
||||
secWrite.put(elem,
|
||||
Integer.parseInt(str) - secWrite.get(elem));
|
||||
str = token.nextToken();// 第8个域:写花费的毫秒数,这是所有写操作所花费的毫秒数(用__make_request()到end_that_request_last()测量)。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛氬啓鑺辫垂鐨勬绉掓暟锛岃繖鏄墍鏈夊啓鎿嶄綔鎵<EFBFBD>姳璐圭殑姣鏁帮紙鐢╛_make_request()鍒癳nd_that_request_last()娴嬮噺锛夈<EFBFBD>
|
||||
writeTime.put(elem,
|
||||
Integer.parseInt(str) - writeTime.get(elem));
|
||||
str = token.nextToken();// 第9个域:I/O的当前进度,只有这个域应该是0。当请求被交给适当的request_queue_t时增加和请求完成时减小。
|
||||
str = token.nextToken();// 绗<EFBFBD>涓煙锛欼/O鐨勫綋鍓嶈繘搴︼紝鍙湁杩欎釜鍩熷簲璇ユ槸0銆傚綋璇锋眰琚氦缁欓<EFBFBD>褰撶殑request_queue_t鏃跺鍔犲拰璇锋眰瀹屾垚鏃跺噺灏忋<EFBFBD>
|
||||
|
||||
currentDiskQueueLength_temp.put(elem,
|
||||
(double) Integer.parseInt(str));
|
||||
str = token.nextToken();// 第10个域:花在I/O操作上的毫秒数,这个域会增长只要field
|
||||
// 9不为0。
|
||||
|
||||
str = token.nextToken();// 第11个域:加权,花在I/O操作上的毫秒数,在每次I/O开始,I/O结束,I/O合并时这个域都会增加。这可以给I/O完成时间和存储那些可以累积的提供一个便利的测量标准
|
||||
|
||||
str = token.nextToken();// 绗<EFBFBD>0涓煙锛氳姳鍦↖/O鎿嶄綔涓婄殑姣鏁帮紝杩欎釜鍩熶細澧為暱鍙field
|
||||
// 9涓嶄负0銆<EFBFBD>
|
||||
str = token.nextToken();// 绗<EFBFBD>1涓煙锛氬姞鏉冿紝鑺卞湪I/O鎿嶄綔涓婄殑姣鏁帮紝鍦ㄦ瘡娆/O寮<EFBFBD>锛孖/O缁撴潫锛孖/O鍚堝苟鏃惰繖涓煙閮戒細澧炲姞銆傝繖鍙互缁橧/O瀹屾垚鏃堕棿鍜屽瓨鍌ㄩ偅浜涘彲浠ョ疮绉殑鎻愪緵涓<EFBFBD>釜渚垮埄鐨勬祴閲忔爣鍑<EFBFBD>
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +265,7 @@ public class LogicalDiskMonitor extends LinuxFileRead {
|
|||
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
Integer time = new Integer(idleTime);
|
||||
Process p = rt.exec("df -hl ");// df -hl 查看硬盘空间
|
||||
Process p = rt.exec("df -hl ");// df -hl 鏌ョ湅纭洏绌洪棿
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
||||
p.getInputStream()));
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package org.bench4q.monitor.service.linux;
|
||||
|
||||
public class NetworkInterfaceServiceLinux {
|
||||
|
||||
}
|
|
@ -29,6 +29,8 @@ public class NetworkInterfaceServiceWindows {
|
|||
networkInterfaceModelChild.setBytesTotalPerSecond(this
|
||||
.getNetworkInterfaceMonitor().getBytesTotalPerSecond(elem,
|
||||
idleTime));
|
||||
networkInterfaceModelChild.setBytesReceivedPerSecond(this.getNetworkInterfaceMonitor().getBytesReceivedPerSecond(elem, idleTime));
|
||||
networkInterfaceModelChild.setBytesSentPerSecond(this.getNetworkInterfaceMonitor().getBytesSentPerSecond(elem, idleTime));
|
||||
networkInterfaceModel.getNetworkList().add(networkInterfaceModelChild);
|
||||
}
|
||||
return networkInterfaceModel;
|
||||
|
|
Loading…
Reference in New Issue