From 29c96e2343160d57e30f31152cc82b013f284857 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 31 Mar 2010 16:27:23 -0700 Subject: [PATCH] (SIGAR-207) append instance index in Pdh.getInstances() --- .../java/src/org/hyperic/sigar/win32/Pdh.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bindings/java/src/org/hyperic/sigar/win32/Pdh.java b/bindings/java/src/org/hyperic/sigar/win32/Pdh.java index 29de414a..aecb1fb7 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/Pdh.java +++ b/bindings/java/src/org/hyperic/sigar/win32/Pdh.java @@ -322,8 +322,28 @@ public class Pdh extends Win32 { } } + private static final class InstanceIndex { + long index = 0; + } + public static String[] getInstances(String path) throws Win32Exception { - return pdhGetInstances(getCounterName(path)); + String[] instances = pdhGetInstances(getCounterName(path)); + + /* PdhEnumObjectItems() does not include the instance index */ + HashMap names = new HashMap(instances.length); + for (int i=0; i