diff --git a/src/zutil/osal/OSAbstractionLayer.java b/src/zutil/osal/OSAbstractionLayer.java old mode 100644 new mode 100755 index eaed722..3ec2a16 --- a/src/zutil/osal/OSAbstractionLayer.java +++ b/src/zutil/osal/OSAbstractionLayer.java @@ -24,9 +24,12 @@ package zutil.osal; +import zutil.osal.linux.OsalLinuxImpl; +import zutil.osal.macos.OsalMacOSImpl; +import zutil.osal.windows.OsalWindowsImpl; + import java.io.BufferedReader; import java.io.File; -import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; diff --git a/src/zutil/osal/HalLinuxImpl.java b/src/zutil/osal/linux/HalLinuxImpl.java old mode 100644 new mode 100755 similarity index 90% rename from src/zutil/osal/HalLinuxImpl.java rename to src/zutil/osal/linux/HalLinuxImpl.java index 21a025e..84a972f --- a/src/zutil/osal/HalLinuxImpl.java +++ b/src/zutil/osal/linux/HalLinuxImpl.java @@ -1,33 +1,35 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.osal; - -/** - * Created by Ziver on 2015-04-07. - */ -public class HalLinuxImpl implements HardwareAbstractionLayer{ - - protected HalLinuxImpl(){} -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.linux; + +import zutil.osal.HardwareAbstractionLayer; + +/** + * Created by Ziver on 2015-04-07. + */ +public class HalLinuxImpl implements HardwareAbstractionLayer { + + protected HalLinuxImpl(){} +} diff --git a/src/zutil/osal/OsalLinuxImpl.java b/src/zutil/osal/linux/OsalLinuxImpl.java old mode 100644 new mode 100755 similarity index 95% rename from src/zutil/osal/OsalLinuxImpl.java rename to src/zutil/osal/linux/OsalLinuxImpl.java index ac45a95..e2bc655 --- a/src/zutil/osal/OsalLinuxImpl.java +++ b/src/zutil/osal/linux/OsalLinuxImpl.java @@ -1,82 +1,85 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.osal; - -import java.io.File; - -/** - * Linux platform specific implementation - */ -public class OsalLinuxImpl extends OSAbstractionLayer { - private static HalLinuxImpl hal; - - @Override - public OSType getOSType() { - return OSType.Linux; - } - - - @Override - public String getOSVersion() { - throw new UnsupportedOperationException(); - } - - @Override - public String getKernelVersion() { - try{ - return super.getFirstLineFromExec("uname -r"); - } catch(Exception e){ - e.printStackTrace(); - } - return null; - } - - @Override - public String getUsername() { - try{ - return super.getFirstLineFromExec("whoami"); - } catch(Exception e){ - e.printStackTrace(); - } - return null; - } - - @Override - public File getUserConfigPath() { - return new File("/home/"+getUsername()); - } - - @Override - public File getGlobalConfigPath() { - return new File("/etc"); - } - - @Override - public HardwareAbstractionLayer getHAL() { - if(hal == null) - hal = new HalLinuxImpl(); - return hal; - } -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.linux; + +import zutil.osal.HardwareAbstractionLayer; +import zutil.osal.OSAbstractionLayer; + +import java.io.File; + +/** + * Linux platform specific implementation + */ +public class OsalLinuxImpl extends OSAbstractionLayer { + private static HalLinuxImpl hal; + + @Override + public OSType getOSType() { + return OSType.Linux; + } + + + @Override + public String getOSVersion() { + throw new UnsupportedOperationException(); + } + + @Override + public String getKernelVersion() { + try{ + return super.getFirstLineFromExec("uname -r"); + } catch(Exception e){ + e.printStackTrace(); + } + return null; + } + + @Override + public String getUsername() { + try{ + return super.getFirstLineFromExec("whoami"); + } catch(Exception e){ + e.printStackTrace(); + } + return null; + } + + @Override + public File getUserConfigPath() { + return new File("/home/"+getUsername()); + } + + @Override + public File getGlobalConfigPath() { + return new File("/etc"); + } + + @Override + public HardwareAbstractionLayer getHAL() { + if(hal == null) + hal = new HalLinuxImpl(); + return hal; + } +} diff --git a/src/zutil/osal/app/linux/AptGet.java b/src/zutil/osal/linux/app/AptGet.java old mode 100644 new mode 100755 similarity index 96% rename from src/zutil/osal/app/linux/AptGet.java rename to src/zutil/osal/linux/app/AptGet.java index e3580eb..ce4c3eb --- a/src/zutil/osal/app/linux/AptGet.java +++ b/src/zutil/osal/linux/app/AptGet.java @@ -1,173 +1,173 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.osal.app.linux; - -import zutil.Timer; -import zutil.log.LogUtil; -import zutil.osal.OSAbstractionLayer; - -import java.util.HashMap; -import java.util.logging.Logger; - -/** - * Created by Ziver on 2014-11-09. - */ -public class AptGet { - public static final Logger log = LogUtil.getLogger(); - - private static Timer updateTimer = new Timer(1000*60*5); // 5min timer - private static Timer packageTimer = new Timer(1000*60*5); // 5min timer - private static HashMap packages = new HashMap<>(); - - public static void install(String pkg) { - update(); - OSAbstractionLayer.exec("apt-get -y install " + pkg); - packageTimer.reset(); - } - - public static void upgrade(){ - update(); - OSAbstractionLayer.exec("apt-get -y " + - // Dont display configuration conflicts - "-o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" " + - "upgrade"); - packageTimer.reset(); - } - - public static void update(){ - // Only run every 5 min - if(updateTimer.hasTimedOut()){ - OSAbstractionLayer.exec("apt-get update"); - updateTimer.start(); - } - } - - public static void purge(String pkg) { - OSAbstractionLayer.exec("apt-get --purge remove " + pkg); - packageTimer.reset(); - } - - - public static Package getPackage(String pkg){ - updatePackages(); - return packages.get(pkg); - } - public static synchronized void updatePackages(){ - // Only run every 5 min - if(packageTimer.hasTimedOut()){ - String[] output = OSAbstractionLayer.exec("dpkg --list"); - for(int i=5; i packages = new HashMap<>(); + + public static void install(String pkg) { + update(); + OSAbstractionLayer.exec("apt-get -y install " + pkg); + packageTimer.reset(); + } + + public static void upgrade(){ + update(); + OSAbstractionLayer.exec("apt-get -y " + + // Dont display configuration conflicts + "-o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" " + + "upgrade"); + packageTimer.reset(); + } + + public static void update(){ + // Only run every 5 min + if(updateTimer.hasTimedOut()){ + OSAbstractionLayer.exec("apt-get update"); + updateTimer.start(); + } + } + + public static void purge(String pkg) { + OSAbstractionLayer.exec("apt-get --purge remove " + pkg); + packageTimer.reset(); + } + + + public static Package getPackage(String pkg){ + updatePackages(); + return packages.get(pkg); + } + public static synchronized void updatePackages(){ + // Only run every 5 min + if(packageTimer.hasTimedOut()){ + String[] output = OSAbstractionLayer.exec("dpkg --list"); + for(int i=5; i hdds = new HashMap(); - private static long updateTimestamp; - - - private synchronized static void update(){ - if(System.currentTimeMillis() - updateTimestamp < TTL) - return; - updateTimestamp = System.currentTimeMillis(); - try { - BufferedReader in = new BufferedReader(new FileReader(PROC_PATH)); - String line = null; - while((line=in.readLine()) != null){ - String[] str = line.trim().split("\\s+", 4); - if(str.length >= 4) { - String devName = str[2]; - if(!hdds.containsKey(devName)){ - HddStats hdd = new HddStats(devName); - hdds.put(hdd.getDevName(), hdd); - } - hdds.get(devName).update(str[3]); - } - } - in.close(); - } catch (IOException e) { - log.log(Level.SEVERE, null, e); - } - } - - public static HddStats getStats(String devName){ - update(); - return hdds.get(devName); - } - - - public static class HddStats { - private String devName; - //read I/Os requests number of read I/Os processed - private long readIO = -1; - //read merges requests number of read I/Os merged with in-queue I/O - private long readMerges = -1; - //read sectors sectors number of sectors read - private long readSectors = -1; - //read ticks milliseconds total wait time for read requests - private long readTicks = -1; - //write I/Os requests number of write I/Os processed - private long writeIO = -1; - //write merges requests number of write I/Os merged with in-queue I/O - private long writeMerges = -1; - //write sectors sectors number of sectors written - private long writeSectors = -1; - //write ticks milliseconds total wait time for write requests - private long writeTicks = -1; - //in_flight requests number of I/Os currently in flight - private long inFlight = -1; - //io_ticks milliseconds total time this block device has been active - private long ioTicks = -1; - //time_in_queue milliseconds total wait time for all requests - private long timeInQueue = -1; - - private ThroughputCalculator readThroughput; - private ThroughputCalculator writeThroughput; - - - protected HddStats(String devName) { - this.devName = devName; - readThroughput = new ThroughputCalculator(); - writeThroughput = new ThroughputCalculator(); - } - protected void update(String line){ - String[] stats = line.split("\\s+"); - if(stats.length >= 11){ - readIO = Long.parseLong(stats[0]); - readMerges = Long.parseLong(stats[1]); - readSectors = Long.parseLong(stats[2]); - readTicks = Long.parseLong(stats[3]); - writeIO = Long.parseLong(stats[4]); - writeMerges = Long.parseLong(stats[5]); - writeSectors = Long.parseLong(stats[6]); - writeTicks = Long.parseLong(stats[7]); - inFlight = Long.parseLong(stats[8]); - ioTicks = Long.parseLong(stats[9]); - timeInQueue = Long.parseLong(stats[10]); - - readThroughput.setTotalHandledData(readSectors * 512); - writeThroughput.setTotalHandledData(writeSectors * 512); - } - } - - - public String getDevName() { - return devName; - } - /** - * This values increment when an I/O request completes. - */ - public long getReadIO() { - return readIO; - } - /** - * This value increment when an I/O request is merged with an - * already-queued I/O request. - */ - public long getReadMerges() { - return readMerges; - } - /** - * This value count the number of sectors read from to this - * block device. The "sectors" in question are the standard UNIX 512-byte - * sectors, not any device- or filesystem-specific block size. The - * counter is incremented when the I/O completes. - */ - public long getReadSectors() { - return readSectors; - } - /** - * This value count the number of milliseconds that I/O requests have - * waited on this block device. If there are multiple I/O requests waiting, - * this value will increase at a rate greater than 1000/second; for - * example, if 60 read requests wait for an average of 30 ms, the read_ticks - * field will increase by 60*30 = 1800. - */ - public long getReadTicks() { - return readTicks; - } - /** - * This values increment when an I/O request completes. - */ - public long getWriteIO() { - return writeIO; - } - /** - * This value increment when an I/O request is merged with an - * already-queued I/O request. - */ - public long getWriteMerges() { - return writeMerges; - } - /** - * This value count the number of sectors written to this - * block device. The "sectors" in question are the standard UNIX 512-byte - * sectors, not any device- or filesystem-specific block size. The - * counter is incremented when the I/O completes. - */ - public long getWriteSectors() { - return writeSectors; - } - /** - * This value count the number of milliseconds that I/O requests have - * waited on this block device. If there are multiple I/O requests waiting, - * this value will increase at a rate greater than 1000/second; for - * example, if 60 write requests wait for an average of 30 ms, the write_ticks - * field will increase by 60*30 = 1800. - */ - public long getWriteTicks() { - return writeTicks; - } - /** - * This value counts the number of I/O requests that have been issued to - * the device driver but have not yet completed. It does not include I/O - * requests that are in the queue but not yet issued to the device driver. - */ - public long getInFlight() { - return inFlight; - } - /** - * This value counts the number of milliseconds during which the device has - * had I/O requests queued. - */ - public long getIoTicks() { - return ioTicks; - } - /** - * This value counts the number of milliseconds that I/O requests have waited - * on this block device. If there are multiple I/O requests waiting, this - * value will increase as the product of the number of milliseconds times the - * number of requests waiting (see "read ticks" above for an example). - */ - public long getTimeInQueue() { - return timeInQueue; - } - - /** - * @return the average byte/second read throughput from the disk - */ - public double getReadThroughput(){ - return readThroughput.getByteThroughput(); - } - /** - * @return the average byte/second write throughput to the disk - */ - public double getWriteThroughput(){ - return writeThroughput.getByteThroughput(); - } - } - - - public static void main(String[] args){ - while(true){ - HddStats hdd = ProcDiskstats.getStats("sda"); - System.out.println("sda= " + - "read: " + StringUtil.formatByteSizeToString((long)hdd.getReadThroughput()) + "/s "+ - "write: " + StringUtil.formatByteSizeToString((long)hdd.getWriteThroughput()) + "/s"); - try{Thread.sleep(1000);}catch (Exception e){} - } - } -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.linux.app; + +import zutil.StringUtil; +import zutil.Timer; +import zutil.log.LogUtil; +import zutil.net.ThroughputCalculator; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Documentation from https://www.kernel.org/doc/Documentation/block/stat.txt + * + * Created by Ziver on 2015-05-19. + */ +public class ProcDiskstats { + private static final Logger log = LogUtil.getLogger(); + private static final String PROC_PATH = "/proc/diskstats"; + private static final int TTL = 500; // update stats every 0.5 second + + private static HashMap hdds = new HashMap(); + private static Timer updateTimer = new Timer(TTL); + + + private synchronized static void update(){ + if(!updateTimer.hasTimedOut()) + return; + + try { + BufferedReader in = new BufferedReader(new FileReader(PROC_PATH)); + parse(in); + in.close(); + } catch (IOException e) { + log.log(Level.SEVERE, null, e); + } + } + protected static void parse(BufferedReader in) throws IOException { + updateTimer.start(); + String line = null; + while((line=in.readLine()) != null){ + String[] str = line.trim().split("\\s+", 4); + if(str.length >= 4) { + String devName = str[2]; + if(!hdds.containsKey(devName)){ + HddStats hdd = new HddStats(devName); + hdds.put(hdd.getDevName(), hdd); + } + hdds.get(devName).update(str[3]); + } + } + } + + + + public static HddStats getStats(String devName){ + update(); + return hdds.get(devName); + } + + + public static class HddStats { + private String devName; + //read I/Os requests number of read I/Os processed + private long readIO = -1; + //read merges requests number of read I/Os merged with in-queue I/O + private long readMerges = -1; + //read sectors sectors number of sectors read + private long readSectors = -1; + //read ticks milliseconds total wait time for read requests + private long readTicks = -1; + //write I/Os requests number of write I/Os processed + private long writeIO = -1; + //write merges requests number of write I/Os merged with in-queue I/O + private long writeMerges = -1; + //write sectors sectors number of sectors written + private long writeSectors = -1; + //write ticks milliseconds total wait time for write requests + private long writeTicks = -1; + //in_flight requests number of I/Os currently in flight + private long inFlight = -1; + //io_ticks milliseconds total time this block device has been active + private long ioTicks = -1; + //time_in_queue milliseconds total wait time for all requests + private long timeInQueue = -1; + + private ThroughputCalculator readThroughput; + private ThroughputCalculator writeThroughput; + + + protected HddStats(String devName) { + this.devName = devName; + readThroughput = new ThroughputCalculator(); + writeThroughput = new ThroughputCalculator(); + } + protected void update(String line){ + String[] stats = line.split("\\s+"); + if(stats.length >= 11){ + readIO = Long.parseLong(stats[0]); + readMerges = Long.parseLong(stats[1]); + readSectors = Long.parseLong(stats[2]); + readTicks = Long.parseLong(stats[3]); + writeIO = Long.parseLong(stats[4]); + writeMerges = Long.parseLong(stats[5]); + writeSectors = Long.parseLong(stats[6]); + writeTicks = Long.parseLong(stats[7]); + inFlight = Long.parseLong(stats[8]); + ioTicks = Long.parseLong(stats[9]); + timeInQueue = Long.parseLong(stats[10]); + + readThroughput.setTotalHandledData(readSectors * 512); + writeThroughput.setTotalHandledData(writeSectors * 512); + } + } + + + public String getDevName() { + return devName; + } + /** + * This values increment when an I/O request completes. + */ + public long getReadIO() { + return readIO; + } + /** + * This value increment when an I/O request is merged with an + * already-queued I/O request. + */ + public long getReadMerges() { + return readMerges; + } + /** + * This value count the number of sectors read from to this + * block device. The "sectors" in question are the standard UNIX 512-byte + * sectors, not any device- or filesystem-specific block size. The + * counter is incremented when the I/O completes. + */ + public long getReadSectors() { + return readSectors; + } + /** + * This value count the number of milliseconds that I/O requests have + * waited on this block device. If there are multiple I/O requests waiting, + * this value will increase at a rate greater than 1000/second; for + * example, if 60 read requests wait for an average of 30 ms, the read_ticks + * field will increase by 60*30 = 1800. + */ + public long getReadTicks() { + return readTicks; + } + /** + * This values increment when an I/O request completes. + */ + public long getWriteIO() { + return writeIO; + } + /** + * This value increment when an I/O request is merged with an + * already-queued I/O request. + */ + public long getWriteMerges() { + return writeMerges; + } + /** + * This value count the number of sectors written to this + * block device. The "sectors" in question are the standard UNIX 512-byte + * sectors, not any device- or filesystem-specific block size. The + * counter is incremented when the I/O completes. + */ + public long getWriteSectors() { + return writeSectors; + } + /** + * This value count the number of milliseconds that I/O requests have + * waited on this block device. If there are multiple I/O requests waiting, + * this value will increase at a rate greater than 1000/second; for + * example, if 60 write requests wait for an average of 30 ms, the write_ticks + * field will increase by 60*30 = 1800. + */ + public long getWriteTicks() { + return writeTicks; + } + /** + * This value counts the number of I/O requests that have been issued to + * the device driver but have not yet completed. It does not include I/O + * requests that are in the queue but not yet issued to the device driver. + */ + public long getInFlight() { + return inFlight; + } + /** + * This value counts the number of milliseconds during which the device has + * had I/O requests queued. + */ + public long getIoTicks() { + return ioTicks; + } + /** + * This value counts the number of milliseconds that I/O requests have waited + * on this block device. If there are multiple I/O requests waiting, this + * value will increase as the product of the number of milliseconds times the + * number of requests waiting (see "read ticks" above for an example). + */ + public long getTimeInQueue() { + return timeInQueue; + } + + /** + * @return the average byte/second read throughput from the disk + */ + public double getReadThroughput(){ + return readThroughput.getByteThroughput(); + } + /** + * @return the average byte/second write throughput to the disk + */ + public double getWriteThroughput(){ + return writeThroughput.getByteThroughput(); + } + } + + + public static void main(String[] args){ + while(true){ + HddStats hdd = ProcDiskstats.getStats("sda"); + System.out.println("sda= " + + "read: " + StringUtil.formatByteSizeToString((long)hdd.getReadThroughput()) + "/s "+ + "write: " + StringUtil.formatByteSizeToString((long)hdd.getWriteThroughput()) + "/s"); + try{Thread.sleep(1000);}catch (Exception e){} + } + } +} diff --git a/src/zutil/osal/linux/app/ProcNetArp.java b/src/zutil/osal/linux/app/ProcNetArp.java new file mode 100755 index 0000000..2d1de03 --- /dev/null +++ b/src/zutil/osal/linux/app/ProcNetArp.java @@ -0,0 +1,135 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.linux.app; + +import zutil.Timer; +import zutil.converter.Converter; +import zutil.log.LogUtil; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.UnknownHostException; +import java.util.Collection; +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Makes the Linux ARP cache available as Java api + *

+ * Created by Ziver on 2015-05-19. + */ +public class ProcNetArp { + private static final Logger logger = LogUtil.getLogger(); + private static final String PROC_PATH = "/proc/net/arp"; + private static final int TTL = 500; // update stats every 0.5 second + + private static HashMap arpTable = new HashMap<>(); + private static Timer updateTimer = new Timer(TTL); + + + private synchronized static void update() { + if (!updateTimer.hasTimedOut()) + return; + + try { + BufferedReader in = new BufferedReader(new FileReader(PROC_PATH)); + parse(in); + in.close(); + } catch (IOException e) { + logger.log(Level.SEVERE, null, e); + } + } + protected static void parse(BufferedReader in) throws IOException { + updateTimer.start(); + String line = null; + in.readLine(); // Skipp headers + while ((line = in.readLine()) != null) { + String[] str = line.split("\\s+"); + + if (str.length >= 6) { + InetAddress ip = InetAddress.getByName(str[0]); + if (!arpTable.containsKey(ip)) + arpTable.put(ip, new ArpEntry()); + ArpEntry entry = arpTable.get(ip); + entry.ip = ip; + entry.hwAddress = Converter.hexToByte(str[3].replaceAll(":", "")); + entry.netIf = str[5]; + } else + logger.warning(PROC_PATH + " contains unrecognized format"); + } + } + + + public static Collection getAllArpEntries() { + update(); + return arpTable.values(); + } + + public static ArpEntry getArpEntry(InetAddress ip) { + update(); + return arpTable.get(ip); + } + + + public static class ArpEntry { + private InetAddress ip; + private byte[] hwAddress; + private String netIf; + + + public InetAddress getIp() { + return ip; + } + + public byte[] getHwAddress() { + return hwAddress; + } + + public String getHwAddressString() { + StringBuilder str = new StringBuilder(); + for (int i = 0; i < hwAddress.length; i++) { + if (i != 0) + str.append(':'); + str.append(Converter.toHexString(hwAddress[i])); + } + return str.toString(); + } + + public String getNetworkInterface() { + return netIf; + } + } + + + public static void main(String[] args) { + for (ArpEntry entry : getAllArpEntries()) { + System.out.println(entry.getIp().getHostAddress() + " => " + entry.getHwAddressString()); + } + } +} diff --git a/src/zutil/osal/app/linux/ProcStat.java b/src/zutil/osal/linux/app/ProcStat.java similarity index 85% rename from src/zutil/osal/app/linux/ProcStat.java rename to src/zutil/osal/linux/app/ProcStat.java index 7dda6bc..c3bd3c9 100755 --- a/src/zutil/osal/app/linux/ProcStat.java +++ b/src/zutil/osal/linux/app/ProcStat.java @@ -1,208 +1,214 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.osal.app.linux; - -import zutil.Timer; -import zutil.log.LogUtil; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Documentation from https://www.kernel.org/doc/Documentation/block/stat.txt - * - * Created by ezivkoc on 2015-05-19. - */ -public class ProcStat { - private static final Logger log = LogUtil.getLogger(); - private static final String PROC_PATH = "/proc/stat"; - private static final int TTL = 500; // update stats every 0.5 second - - private static CpuStats cpuTotal = new CpuStats(); - private static ArrayList cpus = new ArrayList(); - private static long uptime; - private static long processes; - private static Timer updateTimer = new Timer(TTL); - - - private synchronized static void update(){ - if(updateTimer.hasTimedOut()) - return; - updateTimer.start(); - try { - BufferedReader in = new BufferedReader(new FileReader(PROC_PATH)); - String line = null; - while((line=in.readLine()) != null){ - String[] str = line.split("\\s+"); - if(str[0].equals("cpu")) { - cpuTotal.update(str); - } - else if(str[0].startsWith("cpu")){ - int cpuId = Integer.parseInt(str[0].substring(3)); - if(cpus.size() <= cpuId) - cpus.add(new CpuStats()); - cpus.get(cpuId).update(str); - } - else if(str[0].startsWith("btime")){ - uptime = Long.parseLong(str[1]); - } - else if(str[0].startsWith("processes")){ - processes = Long.parseLong(str[1]); - } - } - in.close(); - } catch (IOException e) { - log.log(Level.SEVERE, null, e); - } - } - - public static CpuStats getTotalCpuStats(){ - update(); - return cpuTotal; - } - public static Iterator getCpuStats(){ - update(); - return cpus.iterator(); - } - /** - * @return the time at which the system booted, in seconds since the Unix epoch. - */ - public static long getUptime(){ - update(); - return uptime; - } - /** - * @return the number of processes and threads created, which includes (but is not limited to) those created by calls to the fork() and clone() system calls. - */ - public static long getProcesses(){ - update(); - return processes; - } - - - - public static class CpuStats { - // normal processes executing in user mode - private long user; - // processes executing in kernel mode - private long system; - // twiddling thumbs - private long idle; - // waiting for I/O to complete - private long iowait; - private long steal; - // virtual processes - private long guest; - private long total; - - // Percentage - private float load_total; - private float load_user; - private float load_system; - private float load_iowait; - private float load_virtual; - - protected CpuStats(){} - protected void update(String[] stats){ - long newUser=0, newNice=0, newSystem=0, newIdle=0, newIowait=0, newIrq=0, newSoftirq=0, newSteal=0, newGuest=0, newGuestNice=0; - if(stats.length >= 1+8){ - newUser = Long.parseLong(stats[1]); - newNice = Long.parseLong(stats[2]); - newSystem = Long.parseLong(stats[3]); - newIdle = Long.parseLong(stats[4]); - newIowait = Long.parseLong(stats[5]); - newIrq = Long.parseLong(stats[6]); - newSoftirq = Long.parseLong(stats[7]); - if(stats.length >= 1+8+3){ - newSteal = Long.parseLong(stats[8]); - newGuest = Long.parseLong(stats[9]); - newGuestNice = Long.parseLong(stats[10]); - } - - // Summarize - newUser = newUser + newNice - newGuest - newGuestNice; - newSystem = newSystem + newIrq + newSoftirq; - newGuest = newGuest + newGuestNice; - - // Calculate the diffs - long userDiff = newUser - user; - long idleDiff = (newIdle + newIowait) - (idle + iowait); - long systemDiff = newSystem - system; - long stealDiff = newSteal - steal; - long virtualDiff = newGuest - guest; - long newTotal = userDiff + systemDiff + idleDiff + stealDiff + virtualDiff; - // Calculate load - load_total = (float)(newTotal-idleDiff)/newTotal; - load_user = (float)userDiff/newTotal; - load_system = (float)systemDiff/newTotal; - load_iowait = (float)(newIowait - iowait)/newTotal; - load_virtual = (float)virtualDiff/newTotal; - - // update old values - user = newUser; - system = newSystem; - idle = newIdle; - iowait = newIowait; - steal = newSteal; - guest = newGuest; - total = newTotal; - } - } - - public float getTotalLoad() { - return load_total; - } - public float getUserLoad() { - return load_user; - } - public float getSystemLoad() { - return load_system; - } - public float getIOWaitLoad() { - return load_iowait; - } - public float getVirtualLoad() { - return load_virtual; - } - - } - - public static void main(String[] args){ - while(true){ - Iterator it = ProcStat.getCpuStats(); - for(int i=0; it.hasNext(); ++i){ - CpuStats cpu = it.next(); - System.out.print("CPU"+i+": " + cpu.getTotalLoad()+ " "); - } - System.out.println("Total Load: " + ProcStat.getTotalCpuStats().getTotalLoad()); - try{Thread.sleep(1000);}catch (Exception e){} - } - } -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.linux.app; + +import zutil.Timer; +import zutil.log.LogUtil; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Documentation from https://www.kernel.org/doc/Documentation/block/stat.txt + * + * Created by Ziver on 2015-05-19. + */ +public class ProcStat { + private static final Logger log = LogUtil.getLogger(); + private static final String PROC_PATH = "/proc/stat"; + private static final int TTL = 500; // update stats every 0.5 second + + private static CpuStats cpuTotal = new CpuStats(); + private static ArrayList cpus = new ArrayList(); + private static long uptime; + private static long processes; + private static Timer updateTimer = new Timer(TTL); + + + private synchronized static void update(){ + if(!updateTimer.hasTimedOut()) + return; + + try { + BufferedReader in = new BufferedReader(new FileReader(PROC_PATH)); + parse(in); + in.close(); + } catch (IOException e) { + log.log(Level.SEVERE, null, e); + } + } + protected static void parse(BufferedReader in) throws IOException { + updateTimer.start(); + String line = null; + while((line=in.readLine()) != null){ + String[] str = line.split("\\s+"); + if(str[0].equals("cpu")) { + cpuTotal.update(str); + } + else if(str[0].startsWith("cpu")){ + int cpuId = Integer.parseInt(str[0].substring(3)); + if(cpus.size() <= cpuId) + cpus.add(new CpuStats()); + cpus.get(cpuId).update(str); + } + else if(str[0].startsWith("btime")){ + uptime = Long.parseLong(str[1]); + } + else if(str[0].startsWith("processes")){ + processes = Long.parseLong(str[1]); + } + } + } + + + + public static CpuStats getTotalCpuStats(){ + update(); + return cpuTotal; + } + public static Iterator getCpuStats(){ + update(); + return cpus.iterator(); + } + /** + * @return the time at which the system booted, in seconds since the Unix epoch. + */ + public static long getUptime(){ + update(); + return uptime; + } + /** + * @return the number of processes and threads created, which includes (but is not limited to) those created by calls to the fork() and clone() system calls. + */ + public static long getProcesses(){ + update(); + return processes; + } + + + + public static class CpuStats { + // normal processes executing in user mode + private long user; + // processes executing in kernel mode + private long system; + // twiddling thumbs + private long idle; + // waiting for I/O to complete + private long iowait; + private long steal; + // virtual processes + private long guest; + private long total; + + // Percentage + private float load_total; + private float load_user; + private float load_system; + private float load_iowait; + private float load_virtual; + + protected CpuStats(){} + protected void update(String[] stats){ + long newUser=0, newNice=0, newSystem=0, newIdle=0, newIowait=0, newIrq=0, newSoftirq=0, newSteal=0, newGuest=0, newGuestNice=0; + if(stats.length >= 1+8){ + newUser = Long.parseLong(stats[1]); + newNice = Long.parseLong(stats[2]); + newSystem = Long.parseLong(stats[3]); + newIdle = Long.parseLong(stats[4]); + newIowait = Long.parseLong(stats[5]); + newIrq = Long.parseLong(stats[6]); + newSoftirq = Long.parseLong(stats[7]); + if(stats.length >= 1+8+3){ + newSteal = Long.parseLong(stats[8]); + newGuest = Long.parseLong(stats[9]); + newGuestNice = Long.parseLong(stats[10]); + } + + // Summarize + newUser = newUser + newNice - newGuest - newGuestNice; + newSystem = newSystem + newIrq + newSoftirq; + newGuest = newGuest + newGuestNice; + + // Calculate the diffs + long userDiff = newUser - user; + long idleDiff = (newIdle + newIowait) - (idle + iowait); + long systemDiff = newSystem - system; + long stealDiff = newSteal - steal; + long virtualDiff = newGuest - guest; + long newTotal = userDiff + systemDiff + idleDiff + stealDiff + virtualDiff; + // Calculate load + load_total = (float)(newTotal-idleDiff)/newTotal; + load_user = (float)userDiff/newTotal; + load_system = (float)systemDiff/newTotal; + load_iowait = (float)(newIowait - iowait)/newTotal; + load_virtual = (float)virtualDiff/newTotal; + + // update old values + user = newUser; + system = newSystem; + idle = newIdle; + iowait = newIowait; + steal = newSteal; + guest = newGuest; + total = newTotal; + } + } + + public float getTotalLoad() { + return load_total; + } + public float getUserLoad() { + return load_user; + } + public float getSystemLoad() { + return load_system; + } + public float getIOWaitLoad() { + return load_iowait; + } + public float getVirtualLoad() { + return load_virtual; + } + + } + + public static void main(String[] args){ + while(true){ + Iterator it = ProcStat.getCpuStats(); + for(int i=0; it.hasNext(); ++i){ + CpuStats cpu = it.next(); + System.out.print("CPU"+i+": " + cpu.getTotalLoad()+ " "); + } + System.out.println("Total Load: " + ProcStat.getTotalCpuStats().getTotalLoad()); + try{Thread.sleep(1000);}catch (Exception e){} + } + } +} diff --git a/src/zutil/osal/app/linux/Ps.java b/src/zutil/osal/linux/app/Ps.java old mode 100644 new mode 100755 similarity index 95% rename from src/zutil/osal/app/linux/Ps.java rename to src/zutil/osal/linux/app/Ps.java index ec1862b..e87d8a8 --- a/src/zutil/osal/app/linux/Ps.java +++ b/src/zutil/osal/linux/app/Ps.java @@ -1,39 +1,39 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.osal.app.linux; - -import zutil.osal.OSAbstractionLayer; - -/** - * Created by Ziver on 2014-12-23. - */ -public class Ps { - private static OSAbstractionLayer os = OSAbstractionLayer.getInstance(); - - public static boolean isRunning(int pid){ - String[] output = os.exec("ps -p "+pid); - return output.length > 1; - } -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.linux.app; + +import zutil.osal.OSAbstractionLayer; + +/** + * Created by Ziver on 2014-12-23. + */ +public class Ps { + private static OSAbstractionLayer os = OSAbstractionLayer.getInstance(); + + public static boolean isRunning(int pid){ + String[] output = os.exec("ps -p "+pid); + return output.length > 1; + } +} diff --git a/src/zutil/osal/OsalMacOSImpl.java b/src/zutil/osal/macos/OsalMacOSImpl.java old mode 100644 new mode 100755 similarity index 95% rename from src/zutil/osal/OsalMacOSImpl.java rename to src/zutil/osal/macos/OsalMacOSImpl.java index 3e88371..fcf975a --- a/src/zutil/osal/OsalMacOSImpl.java +++ b/src/zutil/osal/macos/OsalMacOSImpl.java @@ -22,9 +22,11 @@ * THE SOFTWARE. */ -package zutil.osal; +package zutil.osal.macos; import com.mysql.jdbc.NotImplemented; +import zutil.osal.HardwareAbstractionLayer; +import zutil.osal.OSAbstractionLayer; import java.io.File; diff --git a/src/zutil/osal/OsalWindowsImpl.java b/src/zutil/osal/windows/OsalWindowsImpl.java old mode 100644 new mode 100755 similarity index 95% rename from src/zutil/osal/OsalWindowsImpl.java rename to src/zutil/osal/windows/OsalWindowsImpl.java index a4e8de0..da72d50 --- a/src/zutil/osal/OsalWindowsImpl.java +++ b/src/zutil/osal/windows/OsalWindowsImpl.java @@ -1,73 +1,76 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.osal; - -import java.io.File; - -/** - * Windows platform specific implementation - */ -public class OsalWindowsImpl extends OSAbstractionLayer { - - @Override - public OSType getOSType() { - return OSType.Windows; - } - - @Override - public String getOSVersion() { - throw new UnsupportedOperationException(); - } - - @Override - public String getKernelVersion() { - try { - return getFirstLineFromExec("ver"); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - public String getUsername() { - throw new UnsupportedOperationException(); - } - - @Override - public File getUserConfigPath() { - throw new UnsupportedOperationException(); - } - - @Override - public File getGlobalConfigPath() { - throw new UnsupportedOperationException(); - } - - @Override - public HardwareAbstractionLayer getHAL() { - throw new UnsupportedOperationException(); - } -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.windows; + +import zutil.osal.HardwareAbstractionLayer; +import zutil.osal.OSAbstractionLayer; + +import java.io.File; + +/** + * Windows platform specific implementation + */ +public class OsalWindowsImpl extends OSAbstractionLayer { + + @Override + public OSType getOSType() { + return OSType.Windows; + } + + @Override + public String getOSVersion() { + throw new UnsupportedOperationException(); + } + + @Override + public String getKernelVersion() { + try { + return getFirstLineFromExec("ver"); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + public String getUsername() { + throw new UnsupportedOperationException(); + } + + @Override + public File getUserConfigPath() { + throw new UnsupportedOperationException(); + } + + @Override + public File getGlobalConfigPath() { + throw new UnsupportedOperationException(); + } + + @Override + public HardwareAbstractionLayer getHAL() { + throw new UnsupportedOperationException(); + } +} diff --git a/src/zutil/osal/app/windows/TypePerf.java b/src/zutil/osal/windows/app/TypePerf.java similarity index 99% rename from src/zutil/osal/app/windows/TypePerf.java rename to src/zutil/osal/windows/app/TypePerf.java index 619a268..3d2a894 100755 --- a/src/zutil/osal/app/windows/TypePerf.java +++ b/src/zutil/osal/windows/app/TypePerf.java @@ -1,77 +1,77 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -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; - -/** - * Created by ezivkoc on 2015-07-30. - */ -public class TypePerf { - // Only available Vista and later... - //https://www.webperformance.com/support/suite/manual/Content/Locating_Server_Metric_Counters.htm - - /* - "(PDH-CSV 4.0)","\\SE00035694\processor(0)\% Processor Time","\\SE00035694\processor(0)\% User Time","\\SE00035694\processor(0)\% Privileged Time","\\SE00035694\processor(0)\Interrupts/sec","\\SE00035694\processor(0)\% DPC Time","\\SE00035694\processor(0)\% Interrupt Time","\\SE00035694\processor(0)\DPCs Queued/sec","\\SE00035694\processor(0)\DPC Rate","\\SE00035694\processor(0)\% Idle Time","\\SE00035694\processor(0)\% C1 Time","\\SE00035694\processor(0)\% C2 Time","\\SE00035694\processor(0)\% C3 Time","\\SE00035694\processor(0)\C1 Transitions/sec","\\SE00035694\processor(0)\C2 Transitions/sec","\\SE00035694\processor(0)\C3 Transitions/sec","\\SE00035694\processor(1)\% Processor Time","\\SE00035694\processor(1)\% User Time","\\SE00035694\processor(1)\% Privileged Time","\\SE00035694\processor(1)\Interrupts/sec","\\SE00035694\processor(1)\% DPC Time","\\SE00035694\processor(1)\% Interrupt Time","\\SE00035694\processor(1)\DPCs Queued/sec","\\SE00035694\processor(1)\DPC Rate","\\SE00035694\processor(1)\% Idle Time","\\SE00035694\processor(1)\% C1 Time","\\SE00035694\processor(1)\% C2 Time","\\SE00035694\processor(1)\% C3 Time","\\SE00035694\processor(1)\C1 Transitions/sec","\\SE00035694\processor(1)\C2 Transitions/sec","\\SE00035694\processor(1)\C3 Transitions/sec","\\SE00035694\processor(2)\% Processor Time","\\SE00035694\processor(2)\% User Time","\\SE00035694\processor(2)\% Privileged Time","\\SE00035694\processor(2)\Interrupts/sec","\\SE00035694\processor(2)\% DPC Time","\\SE00035694\processor(2)\% Interrupt Time","\\SE00035694\processor(2)\DPCs Queued/sec","\\SE00035694\processor(2)\DPC Rate","\\SE00035694\processor(2)\% Idle Time","\\SE00035694\processor(2)\% C1 Time","\\SE00035694\processor(2)\% C2 Time","\\SE00035694\processor(2)\% C3 Time","\\SE00035694\processor(2)\C1 Transitions/sec","\\SE00035694\processor(2)\C2 Transitions/sec","\\SE00035694\processor(2)\C3 Transitions/sec","\\SE00035694\processor(3)\% Processor Time","\\SE00035694\processor(3)\% User Time","\\SE00035694\processor(3)\% Privileged Time","\\SE00035694\processor(3)\Interrupts/sec","\\SE00035694\processor(3)\% DPC Time","\\SE00035694\processor(3)\% Interrupt Time","\\SE00035694\processor(3)\DPCs Queued/sec","\\SE00035694\processor(3)\DPC Rate","\\SE00035694\processor(3)\% Idle Time","\\SE00035694\processor(3)\% C1 Time","\\SE00035694\processor(3)\% C2 Time","\\SE00035694\processor(3)\% C3 Time","\\SE00035694\processor(3)\C1 Transitions/sec","\\SE00035694\processor(3)\C2 Transitions/sec","\\SE00035694\processor(3)\C3 Transitions/sec","\\SE00035694\processor(_Total)\% Processor Time","\\SE00035694\processor(_Total)\% User Time","\\SE00035694\processor(_Total)\% Privileged Time","\\SE00035694\processor(_Total)\Interrupts/sec","\\SE00035694\processor(_Total)\% DPC Time","\\SE00035694\processor(_Total)\% Interrupt Time","\\SE00035694\processor(_Total)\DPCs Queued/sec","\\SE00035694\processor(_Total)\DPC Rate","\\SE00035694\processor(_Total)\% Idle Time","\\SE00035694\processor(_Total)\% C1 Time","\\SE00035694\processor(_Total)\% C2 Time","\\SE00035694\processor(_Total)\% C3 Time","\\SE00035694\processor(_Total)\C1 Transitions/sec","\\SE00035694\processor(_Total)\C2 Transitions/sec","\\SE00035694\processor(_Total)\C3 Transitions/sec" - "07/30/2015 11:53:49.003","4.331731","4.629110","0.000000","1251.466768","0.000000","0.000000","58.368806","0.000000","95.668269","4.370950","3.882572","71.775440","219.624998","61.336711","1197.055170","4.331731","0.000000","1.543037","342.298420","1.543037","0.000000","147.405967","0.000000","98.754342","0.000000","0.000000","95.856588","0.000000","0.000000","341.309119","5.874768","6.172146","0.000000","1282.135124","0.000000","0.000000","23.743243","0.000000","94.125232","0.000000","0.000000","86.960208","0.000000","0.000000","1496.813613","4.331731","0.000000","0.000000","253.261259","0.000000","0.000000","19.786036","1.000000","100.297379","0.000000","0.000000","94.635420","0.000000","0.000000","265.132881","4.717488","2.700317","0.385757","3129.161571","0.385757","0.000000","249.304052","1.000000","97.211306","1.092740","0.970643","87.306914","219.624998","61.336711","3300.310781" - */ - private static final String PERF_CPU_PATH = "\\Processor(*)\\*"; - - /* - "(PDH-CSV 4.0)","\\SE00035694\Memory\Page Faults/sec","\\SE00035694\Memory\Available Bytes","\\SE00035694\Memory\Committed Bytes","\\SE00035694\Memory\Commit Limit","\\SE00035694\Memory\Write Copies/sec","\\SE00035694\Memory\Transition Faults/sec","\\SE00035694\Memory\Cache Faults/sec","\\SE00035694\Memory\Demand Zero Faults/sec","\\SE00035694\Memory\Pages/sec","\\SE00035694\Memory\Pages Input/sec","\\SE00035694\Memory\Page Reads/sec","\\SE00035694\Memory\Pages Output/sec","\\SE00035694\Memory\Pool Paged Bytes","\\SE00035694\Memory\Pool Nonpaged Bytes","\\SE00035694\Memory\Page Writes/sec","\\SE00035694\Memory\Pool Paged Allocs","\\SE00035694\Memory\Pool Nonpaged Allocs","\\SE00035694\Memory\Free System Page Table Entries","\\SE00035694\Memory\Cache Bytes","\\SE00035694\Memory\Cache Bytes Peak","\\SE00035694\Memory\Pool Paged Resident Bytes","\\SE00035694\Memory\System Code Total Bytes","\\SE00035694\Memory\System Code Resident Bytes","\\SE00035694\Memory\System Driver Total Bytes","\\SE00035694\Memory\System Driver Resident Bytes","\\SE00035694\Memory\System Cache Resident Bytes","\\SE00035694\Memory\% Committed Bytes In Use","\\SE00035694\Memory\Available KBytes","\\SE00035694\Memory\Available MBytes","\\SE00035694\Memory\Transition Pages RePurposed/sec","\\SE00035694\Memory\Free & Zero Page List Bytes","\\SE00035694\Memory\Modified Page List Bytes","\\SE00035694\Memory\Standby Cache Reserve Bytes","\\SE00035694\Memory\Standby Cache Normal Priority Bytes","\\SE00035694\Memory\Standby Cache Core Bytes" - "07/30/2015 11:54:52.288","1158.202545","1403789312.000000","7621783552.000000","18949070848.000000","0.000000","13.942249","1.991750","1142.268546","0.000000","0.000000","0.000000","0.000000","408887296.000000","184975360.000000","0.000000","430072.000000","242142.000000","33556038.000000","600846336.000000","650051584.000000","408686592.000000","4395008.000000","2433024.000000","19406848.000000","10178560.000000","600846336.000000","40.222466","1370888.000000","1338.000000","0.000000","25022464.000000","46465024.000000","24576.000000","1378742272.000000","0.000000" - */ - private static final String PERF_MEM_PATH = "\\Memory\\*"; - - /* - "(PDH-CSV 4.0)","\\SE00035694\PhysicalDisk(0 C: D: E:)\Current Disk Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Disk Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Disk Read Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Read Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Disk Write Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Write Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk sec/Transfer","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk sec/Read","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk sec/Write","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Transfers/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Reads/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Writes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Bytes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Read Bytes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Write Bytes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Bytes/Transfer","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Bytes/Read","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Bytes/Write","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Idle Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Split IO/Sec","\\SE00035694\PhysicalDisk(_Total)\Current Disk Queue Length","\\SE00035694\PhysicalDisk(_Total)\% Disk Time","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Queue Length","\\SE00035694\PhysicalDisk(_Total)\% Disk Read Time","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Read Queue Length","\\SE00035694\PhysicalDisk(_Total)\% Disk Write Time","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Write Queue Length","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk sec/Transfer","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk sec/Read","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk sec/Write","\\SE00035694\PhysicalDisk(_Total)\Disk Transfers/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Reads/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Writes/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Bytes/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Read Bytes/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Write Bytes/sec","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Bytes/Transfer","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Bytes/Read","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Bytes/Write","\\SE00035694\PhysicalDisk(_Total)\% Idle Time","\\SE00035694\PhysicalDisk(_Total)\Split IO/Sec" - "07/30/2015 11:55:26.544","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100.148515","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100.148515","0.000000" - */ - private static final String PERF_DISK_PATH = "\\PhysicalDisk(*)\\*"; - - /* - "(PDH-CSV 4.0)","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Bytes Total/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Sent/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Current Bandwidth","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Bytes Received/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Discarded","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Errors","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Unknown","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Bytes Sent/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Outbound Discarded","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Outbound Errors","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Output Queue Length","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Offloaded Connections","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Bytes Total/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Sent/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Current Bandwidth","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Bytes Received/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Discarded","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Errors","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Unknown","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Bytes Sent/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Outbound Discarded","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Outbound Errors","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Output Queue Length","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Offloaded Connections","\\SE00035694\Network Interface(6TO4 Adapter)\Bytes Total/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Sent/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Current Bandwidth","\\SE00035694\Network Interface(6TO4 Adapter)\Bytes Received/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Discarded","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Errors","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Unknown","\\SE00035694\Network Interface(6TO4 Adapter)\Bytes Sent/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Outbound Discarded","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Outbound Errors","\\SE00035694\Network Interface(6TO4 Adapter)\Output Queue Length","\\SE00035694\Network Interface(6TO4 Adapter)\Offloaded Connections","\\SE00035694\Network Interface(Local Area Connection* 12)\Bytes Total/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Sent/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Current Bandwidth","\\SE00035694\Network Interface(Local Area Connection* 12)\Bytes Received/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Discarded","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Errors","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Unknown","\\SE00035694\Network Interface(Local Area Connection* 12)\Bytes Sent/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Outbound Discarded","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Outbound Errors","\\SE00035694\Network Interface(Local Area Connection* 12)\Output Queue Length","\\SE00035694\Network Interface(Local Area Connection* 12)\Offloaded Connections","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Bytes Total/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Sent/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Current Bandwidth","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Bytes Received/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Discarded","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Errors","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Unknown","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Output Queue Length","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Offloaded Connections","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Bytes Total/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Sent/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Current Bandwidth","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Bytes Received/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Discarded","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Errors","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Unknown","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Output Queue Length","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Offloaded Connections","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Bytes Total/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Sent/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Current Bandwidth","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Bytes Received/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Discarded","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Errors","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Unknown","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Output Queue Length","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Offloaded Connections","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Bytes Total/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Sent/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Current Bandwidth","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Bytes Received/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Discarded","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Errors","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Unknown","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Output Queue Length","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Offloaded Connections" - "07/30/2015 11:56:40.899","6479.124376","13.269125","9.477947","3.791179","100000000.000000","6183.412438","5.686768","3.791179","0.000000","0.000000","0.000000","295.711938","3.791179","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","300000000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","30000000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000" - */ - private static final String PERF_NET_PATH = "\\Network Interface(*)\\*"; - - - - private static DataNode[] execute(String path) throws IOException { - DataNode[] ret = new DataNode[2]; - - String[] output = OSAbstractionLayer.exec("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; - } -} +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Ziver Koc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package zutil.osal.windows.app; + +import zutil.osal.OSAbstractionLayer; +import zutil.parser.CSVParser; +import zutil.parser.DataNode; + +import java.io.IOException; +import java.io.StringReader; + +/** + * Created by ezivkoc on 2015-07-30. + */ +public class TypePerf { + // Only available Vista and later... + //https://www.webperformance.com/support/suite/manual/Content/Locating_Server_Metric_Counters.htm + + /* + "(PDH-CSV 4.0)","\\SE00035694\processor(0)\% Processor Time","\\SE00035694\processor(0)\% User Time","\\SE00035694\processor(0)\% Privileged Time","\\SE00035694\processor(0)\Interrupts/sec","\\SE00035694\processor(0)\% DPC Time","\\SE00035694\processor(0)\% Interrupt Time","\\SE00035694\processor(0)\DPCs Queued/sec","\\SE00035694\processor(0)\DPC Rate","\\SE00035694\processor(0)\% Idle Time","\\SE00035694\processor(0)\% C1 Time","\\SE00035694\processor(0)\% C2 Time","\\SE00035694\processor(0)\% C3 Time","\\SE00035694\processor(0)\C1 Transitions/sec","\\SE00035694\processor(0)\C2 Transitions/sec","\\SE00035694\processor(0)\C3 Transitions/sec","\\SE00035694\processor(1)\% Processor Time","\\SE00035694\processor(1)\% User Time","\\SE00035694\processor(1)\% Privileged Time","\\SE00035694\processor(1)\Interrupts/sec","\\SE00035694\processor(1)\% DPC Time","\\SE00035694\processor(1)\% Interrupt Time","\\SE00035694\processor(1)\DPCs Queued/sec","\\SE00035694\processor(1)\DPC Rate","\\SE00035694\processor(1)\% Idle Time","\\SE00035694\processor(1)\% C1 Time","\\SE00035694\processor(1)\% C2 Time","\\SE00035694\processor(1)\% C3 Time","\\SE00035694\processor(1)\C1 Transitions/sec","\\SE00035694\processor(1)\C2 Transitions/sec","\\SE00035694\processor(1)\C3 Transitions/sec","\\SE00035694\processor(2)\% Processor Time","\\SE00035694\processor(2)\% User Time","\\SE00035694\processor(2)\% Privileged Time","\\SE00035694\processor(2)\Interrupts/sec","\\SE00035694\processor(2)\% DPC Time","\\SE00035694\processor(2)\% Interrupt Time","\\SE00035694\processor(2)\DPCs Queued/sec","\\SE00035694\processor(2)\DPC Rate","\\SE00035694\processor(2)\% Idle Time","\\SE00035694\processor(2)\% C1 Time","\\SE00035694\processor(2)\% C2 Time","\\SE00035694\processor(2)\% C3 Time","\\SE00035694\processor(2)\C1 Transitions/sec","\\SE00035694\processor(2)\C2 Transitions/sec","\\SE00035694\processor(2)\C3 Transitions/sec","\\SE00035694\processor(3)\% Processor Time","\\SE00035694\processor(3)\% User Time","\\SE00035694\processor(3)\% Privileged Time","\\SE00035694\processor(3)\Interrupts/sec","\\SE00035694\processor(3)\% DPC Time","\\SE00035694\processor(3)\% Interrupt Time","\\SE00035694\processor(3)\DPCs Queued/sec","\\SE00035694\processor(3)\DPC Rate","\\SE00035694\processor(3)\% Idle Time","\\SE00035694\processor(3)\% C1 Time","\\SE00035694\processor(3)\% C2 Time","\\SE00035694\processor(3)\% C3 Time","\\SE00035694\processor(3)\C1 Transitions/sec","\\SE00035694\processor(3)\C2 Transitions/sec","\\SE00035694\processor(3)\C3 Transitions/sec","\\SE00035694\processor(_Total)\% Processor Time","\\SE00035694\processor(_Total)\% User Time","\\SE00035694\processor(_Total)\% Privileged Time","\\SE00035694\processor(_Total)\Interrupts/sec","\\SE00035694\processor(_Total)\% DPC Time","\\SE00035694\processor(_Total)\% Interrupt Time","\\SE00035694\processor(_Total)\DPCs Queued/sec","\\SE00035694\processor(_Total)\DPC Rate","\\SE00035694\processor(_Total)\% Idle Time","\\SE00035694\processor(_Total)\% C1 Time","\\SE00035694\processor(_Total)\% C2 Time","\\SE00035694\processor(_Total)\% C3 Time","\\SE00035694\processor(_Total)\C1 Transitions/sec","\\SE00035694\processor(_Total)\C2 Transitions/sec","\\SE00035694\processor(_Total)\C3 Transitions/sec" + "07/30/2015 11:53:49.003","4.331731","4.629110","0.000000","1251.466768","0.000000","0.000000","58.368806","0.000000","95.668269","4.370950","3.882572","71.775440","219.624998","61.336711","1197.055170","4.331731","0.000000","1.543037","342.298420","1.543037","0.000000","147.405967","0.000000","98.754342","0.000000","0.000000","95.856588","0.000000","0.000000","341.309119","5.874768","6.172146","0.000000","1282.135124","0.000000","0.000000","23.743243","0.000000","94.125232","0.000000","0.000000","86.960208","0.000000","0.000000","1496.813613","4.331731","0.000000","0.000000","253.261259","0.000000","0.000000","19.786036","1.000000","100.297379","0.000000","0.000000","94.635420","0.000000","0.000000","265.132881","4.717488","2.700317","0.385757","3129.161571","0.385757","0.000000","249.304052","1.000000","97.211306","1.092740","0.970643","87.306914","219.624998","61.336711","3300.310781" + */ + private static final String PERF_CPU_PATH = "\\Processor(*)\\*"; + + /* + "(PDH-CSV 4.0)","\\SE00035694\Memory\Page Faults/sec","\\SE00035694\Memory\Available Bytes","\\SE00035694\Memory\Committed Bytes","\\SE00035694\Memory\Commit Limit","\\SE00035694\Memory\Write Copies/sec","\\SE00035694\Memory\Transition Faults/sec","\\SE00035694\Memory\Cache Faults/sec","\\SE00035694\Memory\Demand Zero Faults/sec","\\SE00035694\Memory\Pages/sec","\\SE00035694\Memory\Pages Input/sec","\\SE00035694\Memory\Page Reads/sec","\\SE00035694\Memory\Pages Output/sec","\\SE00035694\Memory\Pool Paged Bytes","\\SE00035694\Memory\Pool Nonpaged Bytes","\\SE00035694\Memory\Page Writes/sec","\\SE00035694\Memory\Pool Paged Allocs","\\SE00035694\Memory\Pool Nonpaged Allocs","\\SE00035694\Memory\Free System Page Table Entries","\\SE00035694\Memory\Cache Bytes","\\SE00035694\Memory\Cache Bytes Peak","\\SE00035694\Memory\Pool Paged Resident Bytes","\\SE00035694\Memory\System Code Total Bytes","\\SE00035694\Memory\System Code Resident Bytes","\\SE00035694\Memory\System Driver Total Bytes","\\SE00035694\Memory\System Driver Resident Bytes","\\SE00035694\Memory\System Cache Resident Bytes","\\SE00035694\Memory\% Committed Bytes In Use","\\SE00035694\Memory\Available KBytes","\\SE00035694\Memory\Available MBytes","\\SE00035694\Memory\Transition Pages RePurposed/sec","\\SE00035694\Memory\Free & Zero Page List Bytes","\\SE00035694\Memory\Modified Page List Bytes","\\SE00035694\Memory\Standby Cache Reserve Bytes","\\SE00035694\Memory\Standby Cache Normal Priority Bytes","\\SE00035694\Memory\Standby Cache Core Bytes" + "07/30/2015 11:54:52.288","1158.202545","1403789312.000000","7621783552.000000","18949070848.000000","0.000000","13.942249","1.991750","1142.268546","0.000000","0.000000","0.000000","0.000000","408887296.000000","184975360.000000","0.000000","430072.000000","242142.000000","33556038.000000","600846336.000000","650051584.000000","408686592.000000","4395008.000000","2433024.000000","19406848.000000","10178560.000000","600846336.000000","40.222466","1370888.000000","1338.000000","0.000000","25022464.000000","46465024.000000","24576.000000","1378742272.000000","0.000000" + */ + private static final String PERF_MEM_PATH = "\\Memory\\*"; + + /* + "(PDH-CSV 4.0)","\\SE00035694\PhysicalDisk(0 C: D: E:)\Current Disk Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Disk Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Disk Read Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Read Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Disk Write Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Write Queue Length","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk sec/Transfer","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk sec/Read","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk sec/Write","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Transfers/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Reads/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Writes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Bytes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Read Bytes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Disk Write Bytes/sec","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Bytes/Transfer","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Bytes/Read","\\SE00035694\PhysicalDisk(0 C: D: E:)\Avg. Disk Bytes/Write","\\SE00035694\PhysicalDisk(0 C: D: E:)\% Idle Time","\\SE00035694\PhysicalDisk(0 C: D: E:)\Split IO/Sec","\\SE00035694\PhysicalDisk(_Total)\Current Disk Queue Length","\\SE00035694\PhysicalDisk(_Total)\% Disk Time","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Queue Length","\\SE00035694\PhysicalDisk(_Total)\% Disk Read Time","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Read Queue Length","\\SE00035694\PhysicalDisk(_Total)\% Disk Write Time","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Write Queue Length","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk sec/Transfer","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk sec/Read","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk sec/Write","\\SE00035694\PhysicalDisk(_Total)\Disk Transfers/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Reads/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Writes/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Bytes/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Read Bytes/sec","\\SE00035694\PhysicalDisk(_Total)\Disk Write Bytes/sec","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Bytes/Transfer","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Bytes/Read","\\SE00035694\PhysicalDisk(_Total)\Avg. Disk Bytes/Write","\\SE00035694\PhysicalDisk(_Total)\% Idle Time","\\SE00035694\PhysicalDisk(_Total)\Split IO/Sec" + "07/30/2015 11:55:26.544","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100.148515","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100.148515","0.000000" + */ + private static final String PERF_DISK_PATH = "\\PhysicalDisk(*)\\*"; + + /* + "(PDH-CSV 4.0)","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Bytes Total/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Sent/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Current Bandwidth","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Bytes Received/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Discarded","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Errors","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Received Unknown","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Bytes Sent/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Outbound Discarded","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Packets Outbound Errors","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Output Queue Length","\\SE00035694\Network Interface(Intel[R] Ethernet Connection I218-LM)\Offloaded Connections","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Bytes Total/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Sent/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Current Bandwidth","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Bytes Received/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Discarded","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Errors","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Received Unknown","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Bytes Sent/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Outbound Discarded","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Packets Outbound Errors","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Output Queue Length","\\SE00035694\Network Interface(Intel[R] Dual Band Wireless-N 7260)\Offloaded Connections","\\SE00035694\Network Interface(6TO4 Adapter)\Bytes Total/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Sent/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Current Bandwidth","\\SE00035694\Network Interface(6TO4 Adapter)\Bytes Received/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Discarded","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Errors","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Received Unknown","\\SE00035694\Network Interface(6TO4 Adapter)\Bytes Sent/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Outbound Discarded","\\SE00035694\Network Interface(6TO4 Adapter)\Packets Outbound Errors","\\SE00035694\Network Interface(6TO4 Adapter)\Output Queue Length","\\SE00035694\Network Interface(6TO4 Adapter)\Offloaded Connections","\\SE00035694\Network Interface(Local Area Connection* 12)\Bytes Total/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Sent/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Current Bandwidth","\\SE00035694\Network Interface(Local Area Connection* 12)\Bytes Received/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Discarded","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Errors","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Received Unknown","\\SE00035694\Network Interface(Local Area Connection* 12)\Bytes Sent/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Outbound Discarded","\\SE00035694\Network Interface(Local Area Connection* 12)\Packets Outbound Errors","\\SE00035694\Network Interface(Local Area Connection* 12)\Output Queue Length","\\SE00035694\Network Interface(Local Area Connection* 12)\Offloaded Connections","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Bytes Total/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Sent/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Current Bandwidth","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Bytes Received/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Discarded","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Errors","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Received Unknown","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Output Queue Length","\\SE00035694\Network Interface(isatap.ki.sw.ericsson.se)\Offloaded Connections","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Bytes Total/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Sent/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Current Bandwidth","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Bytes Received/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Discarded","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Errors","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Received Unknown","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Output Queue Length","\\SE00035694\Network Interface(isatap.{B9D01222-E737-4A0B-8321-7FE782CD4197})\Offloaded Connections","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Bytes Total/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Sent/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Current Bandwidth","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Bytes Received/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Discarded","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Errors","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Received Unknown","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Output Queue Length","\\SE00035694\Network Interface(isatap.{BA17492A-F69D-42F3-890A-3E9B8D2DA7C9})\Offloaded Connections","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Bytes Total/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Sent/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Current Bandwidth","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Bytes Received/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Discarded","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Errors","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Received Unknown","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Bytes Sent/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Sent Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Sent Non-Unicast/sec","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Outbound Discarded","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Packets Outbound Errors","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Output Queue Length","\\SE00035694\Network Interface(isatap.{A42279F6-5D04-468C-A354-23EC38A4D962})\Offloaded Connections" + "07/30/2015 11:56:40.899","6479.124376","13.269125","9.477947","3.791179","100000000.000000","6183.412438","5.686768","3.791179","0.000000","0.000000","0.000000","295.711938","3.791179","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","300000000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","30000000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","100000.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000","0.000000" + */ + private static final String PERF_NET_PATH = "\\Network Interface(*)\\*"; + + + + private static DataNode[] execute(String path) throws IOException { + DataNode[] ret = new DataNode[2]; + + String[] output = OSAbstractionLayer.exec("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; + } +} diff --git a/test/zutil/osal/linux/app/ProcNetArpTest.java b/test/zutil/osal/linux/app/ProcNetArpTest.java new file mode 100755 index 0000000..eca23f9 --- /dev/null +++ b/test/zutil/osal/linux/app/ProcNetArpTest.java @@ -0,0 +1,58 @@ +package zutil.osal.linux.app; + +import org.junit.Test; +import zutil.io.StringInputStream; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.net.InetAddress; + +import static org.junit.Assert.*; + +/** + * Created by ezivkoc on 2016-09-30. + */ +public class ProcNetArpTest { + @Test + public void parse() throws Exception { + StringInputStream buff = new StringInputStream( + "IP address HW type Flags HW address Mask Device\n" + + "192.168.1.140 0x1 0x0 fc:f8:ae:3f:66:64 * eth0\n" + + "169.254.67.249 0x1 0x0 78:ab:bb:c4:05:b3 * eth0\n" + + "192.168.1.127 0x1 0x2 00:05:cd:39:aa:07 * eth0\n" + + "192.168.1.1 0x1 0x2 c0:56:27:c2:5e:82 * eth0\n" + + "192.168.1.190 0x1 0x0 fc:f8:ae:3f:66:64 * eth0\n" + + "192.168.1.253 0x1 0x0 00:00:00:00:00:00 * eth0\n" + + "192.168.1.105 0x1 0x2 24:0a:64:49:c9:7b * eth0\n" + + "192.168.1.110 0x1 0x0 00:00:00:00:00:00 * eth0\n" + + "192.168.1.2 0x1 0x0 00:00:00:00:00:00 * eth0\n" + + "192.168.1.137 0x1 0x2 78:ab:bb:c4:05:b3 * eth0\n" + + "192.168.1.128 0x1 0x2 6c:ad:f8:be:ef:ba * eth0\n" + + "192.168.1.30 0x1 0x0 00:00:00:00:00:00 * eth0\n" + + "192.168.1.12 0x1 0x0 00:00:00:00:00:00 * eth0\n" + + "192.168.1.178 0x1 0x2 6c:ad:f8:be:ef:ba * eth0\n"); + ProcNetArp.parse(new BufferedReader(new InputStreamReader(buff))); + + ProcNetArp.ArpEntry entry = ProcNetArp.getArpEntry(InetAddress.getByName("192.168.1.140")); + assertEquals("192.168.1.140", entry.getIp().getHostAddress()); + assertEquals("fc:f8:ae:3f:66:64", entry.getHwAddressString()); + assertEquals("eth0", entry.getNetworkInterface()); + + entry = ProcNetArp.getArpEntry(InetAddress.getByName("192.168.1.1")); + assertEquals("192.168.1.1", entry.getIp().getHostAddress()); + assertEquals("c0:56:27:c2:5e:82", entry.getHwAddressString()); + assertEquals("eth0", entry.getNetworkInterface()); + + entry = ProcNetArp.getArpEntry(InetAddress.getByName("192.168.1.178")); + assertEquals("192.168.1.178", entry.getIp().getHostAddress()); + assertEquals("6c:ad:f8:be:ef:ba", entry.getHwAddressString()); + assertEquals("eth0", entry.getNetworkInterface()); + } + + @Test + public void parseTwoTimes() throws Exception { + parse(); + parse(); + } +} \ No newline at end of file