Class PerfDataUtilFFM
java.lang.Object
oshi.util.platform.windows.PerfDataUtilFFM
Helper class to centralize the boilerplate portions of PDH counter setup using the FFM API.
This utility collects counter data with a single call to PdhCollectQueryData, which yields valid results for
raw counters. OSHI queries raw counter values and computes rates in Java rather than using PDH formatted rate
counters, which would require two samples separated by an interval.
-
Method Summary
Modifier and TypeMethodDescriptionqueryCounters(Class<T> propertyEnum, String perfObject) Query multiple PDH counter values in a single query, one per enum constant.static <T extends Enum<T> & oshi.driver.common.windows.perfmon.PdhCounterWildcardProperty>
oshi.util.tuples.Pair<List<String>, Map<T, List<Long>>> queryWildcardCounters(Class<T> propertyEnum, String perfObject) Query wildcard PDH counter values for all instances matching the filter defined by the first enum constant.static <T extends Enum<T> & oshi.driver.common.windows.perfmon.PdhCounterWildcardProperty>
oshi.util.tuples.Pair<List<String>, Map<T, List<Long>>> queryWildcardCounters(Class<T> propertyEnum, String perfObject, String customFilter) Query wildcard PDH counter values for all instances matching the given filter or the default from the first enum constant.
-
Method Details
-
queryCounters
public static <T extends Enum<T> & oshi.driver.common.windows.perfmon.PdhCounterProperty> Map<T,Long> queryCounters(Class<T> propertyEnum, String perfObject) Query multiple PDH counter values in a single query, one per enum constant.- Type Parameters:
T- An enum implementingPdhCounterProperty- Parameters:
propertyEnum- The enum class whose constants define the counters to queryperfObject- The PDH object name (e.g., "Process")- Returns:
- An
EnumMapof values indexed by enum constant. May contain a subset of constants if individual counters fail to add or read. Returns an empty map if the query itself fails to open or collect.
-
queryWildcardCounters
public static <T extends Enum<T> & oshi.driver.common.windows.perfmon.PdhCounterWildcardProperty> oshi.util.tuples.Pair<List<String>, Map<T, List<Long>>> queryWildcardCounters(Class<T> propertyEnum, String perfObject) Query wildcard PDH counter values for all instances matching the filter defined by the first enum constant.- Type Parameters:
T- An enum implementingPdhCounterWildcardProperty- Parameters:
propertyEnum- The enum class whose constants define the counters to query. The first constant defines the instance filter; remaining constants define counter names.perfObject- The PDH object name (e.g., "Process")- Returns:
- A pair of (instances, valueMap) where valueMap is indexed by enum constant (excluding the first). Returns empty list and empty map on failure.
-
queryWildcardCounters
public static <T extends Enum<T> & oshi.driver.common.windows.perfmon.PdhCounterWildcardProperty> oshi.util.tuples.Pair<List<String>, Map<T, List<Long>>> queryWildcardCounters(Class<T> propertyEnum, String perfObject, String customFilter) Query wildcard PDH counter values for all instances matching the given filter or the default from the first enum constant.- Type Parameters:
T- An enum implementingPdhCounterWildcardProperty- Parameters:
propertyEnum- The enum class whose constants define the counters to query. The first constant defines the default instance filter; remaining constants define counter names.perfObject- The PDH object name (e.g., "Process")customFilter- A custom instance filter to use. If null, uses the first element of the property enum.- Returns:
- A pair of (instances, valueMap) where valueMap is indexed by enum constant (excluding the first). Returns empty list and empty map on failure.
-