Some small changes

This commit is contained in:
Ziver Koc 2015-08-04 12:59:45 +00:00
parent 315932070a
commit b3506af8ad
3 changed files with 33 additions and 5 deletions

BIN
Zutil.jar

Binary file not shown.

View file

@ -22,11 +22,20 @@
package zutil.osal.app.windows; package zutil.osal.app.windows;
import zutil.osal.OSAbstractionLayer;
import zutil.parser.CSVParser;
import zutil.parser.DataNode;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by ezivkoc on 2015-07-30. * Created by ezivkoc on 2015-07-30.
*/ */
public class TypePerf { public class TypePerf {
// Only available Vista -> // Only available Vista and later...
//https://www.webperformance.com/support/suite/manual/Content/Locating_Server_Metric_Counters.htm //https://www.webperformance.com/support/suite/manual/Content/Locating_Server_Metric_Counters.htm
/* /*
@ -53,5 +62,16 @@ public class TypePerf {
*/ */
private static final String PERF_NET_PATH = "\\Network Interface(*)\\*"; private static final String PERF_NET_PATH = "\\Network Interface(*)\\*";
//typeperf "path" -SC 0 -y
private static DataNode[] execute(String path) throws IOException {
DataNode[] ret = new DataNode[2];
String[] output = OSAbstractionLayer.runCommand("typeperf \""+ path +"\" -SC 0 -y");
CSVParser parser = new CSVParser(new StringReader(output[1] + "\n" + output[2]));
ret[0] = parser.getHeaders();
ret[1] = parser.read();
return ret;
}
} }

View file

@ -53,6 +53,14 @@ public class CSVParser extends Parser{
} }
public DataNode getHeaders() { public DataNode getHeaders() {
if(parseHeader) {
try {
parseHeader = false;
headers = read();
}catch (IOException e){
e.printStackTrace();
}
}
return headers; return headers;
} }
@ -67,7 +75,7 @@ public class CSVParser extends Parser{
return new CSVParser(new StringReader(csv)).read(); return new CSVParser(new StringReader(csv)).read();
}catch (IOException e){ }catch (IOException e){
e.printStackTrace(); e.printStackTrace();
}catch (NullPointerException e){} }
return null; return null;
} }
@ -80,9 +88,9 @@ public class CSVParser extends Parser{
*/ */
@Override @Override
public DataNode read() throws IOException { public DataNode read() throws IOException {
// Make sure we have parsed headers
if(parseHeader) { if(parseHeader) {
parseHeader = false; getHeaders();
headers = read();
} }
DataNode data = new DataNode(DataNode.DataType.List); DataNode data = new DataNode(DataNode.DataType.List);