|
@@ -100,36 +100,40 @@ public class SysInfoWindows extends SysInfo {
|
|
|
String sysInfoStr = getSystemInfoInfoFromShell();
|
|
|
if (sysInfoStr != null) {
|
|
|
final int sysInfoSplitCount = 11;
|
|
|
- String[] sysInfo = sysInfoStr.substring(0, sysInfoStr.indexOf("\r\n"))
|
|
|
- .split(",");
|
|
|
- if (sysInfo.length == sysInfoSplitCount) {
|
|
|
- try {
|
|
|
- vmemSize = Long.parseLong(sysInfo[0]);
|
|
|
- memSize = Long.parseLong(sysInfo[1]);
|
|
|
- vmemAvailable = Long.parseLong(sysInfo[2]);
|
|
|
- memAvailable = Long.parseLong(sysInfo[3]);
|
|
|
- numProcessors = Integer.parseInt(sysInfo[4]);
|
|
|
- cpuFrequencyKhz = Long.parseLong(sysInfo[5]);
|
|
|
- cumulativeCpuTimeMs = Long.parseLong(sysInfo[6]);
|
|
|
- storageBytesRead = Long.parseLong(sysInfo[7]);
|
|
|
- storageBytesWritten = Long.parseLong(sysInfo[8]);
|
|
|
- netBytesRead = Long.parseLong(sysInfo[9]);
|
|
|
- netBytesWritten = Long.parseLong(sysInfo[10]);
|
|
|
- if (lastCumCpuTimeMs != -1) {
|
|
|
- /**
|
|
|
- * This number will be the aggregated usage across all cores in
|
|
|
- * [0.0, 100.0]. For example, it will be 400.0 if there are 8
|
|
|
- * cores and each of them is running at 50% utilization.
|
|
|
- */
|
|
|
- cpuUsage = (cumulativeCpuTimeMs - lastCumCpuTimeMs)
|
|
|
- * 100F / refreshInterval;
|
|
|
+ int index = sysInfoStr.indexOf("\r\n");
|
|
|
+ if (index >= 0) {
|
|
|
+ String[] sysInfo = sysInfoStr.substring(0, index).split(",");
|
|
|
+ if (sysInfo.length == sysInfoSplitCount) {
|
|
|
+ try {
|
|
|
+ vmemSize = Long.parseLong(sysInfo[0]);
|
|
|
+ memSize = Long.parseLong(sysInfo[1]);
|
|
|
+ vmemAvailable = Long.parseLong(sysInfo[2]);
|
|
|
+ memAvailable = Long.parseLong(sysInfo[3]);
|
|
|
+ numProcessors = Integer.parseInt(sysInfo[4]);
|
|
|
+ cpuFrequencyKhz = Long.parseLong(sysInfo[5]);
|
|
|
+ cumulativeCpuTimeMs = Long.parseLong(sysInfo[6]);
|
|
|
+ storageBytesRead = Long.parseLong(sysInfo[7]);
|
|
|
+ storageBytesWritten = Long.parseLong(sysInfo[8]);
|
|
|
+ netBytesRead = Long.parseLong(sysInfo[9]);
|
|
|
+ netBytesWritten = Long.parseLong(sysInfo[10]);
|
|
|
+ if (lastCumCpuTimeMs != -1) {
|
|
|
+ /**
|
|
|
+ * This number will be the aggregated usage across all cores in
|
|
|
+ * [0.0, 100.0]. For example, it will be 400.0 if there are 8
|
|
|
+ * cores and each of them is running at 50% utilization.
|
|
|
+ */
|
|
|
+ cpuUsage = (cumulativeCpuTimeMs - lastCumCpuTimeMs)
|
|
|
+ * 100F / refreshInterval;
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException nfe) {
|
|
|
+ LOG.warn("Error parsing sysInfo", nfe);
|
|
|
}
|
|
|
- } catch (NumberFormatException nfe) {
|
|
|
- LOG.warn("Error parsing sysInfo", nfe);
|
|
|
+ } else {
|
|
|
+ LOG.warn("Expected split length of sysInfo to be "
|
|
|
+ + sysInfoSplitCount + ". Got " + sysInfo.length);
|
|
|
}
|
|
|
} else {
|
|
|
- LOG.warn("Expected split length of sysInfo to be "
|
|
|
- + sysInfoSplitCount + ". Got " + sysInfo.length);
|
|
|
+ LOG.warn("Wrong output from sysInfo: " + sysInfoStr);
|
|
|
}
|
|
|
}
|
|
|
}
|