java.lang.Object
oshi.util.platform.windows.PerfCounterQuery
Enables queries of Performance Counters using wild cards to filter instances
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Contract for Counter Property Enums -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
localizeIfNeeded
(String perfObject, boolean force) Localize a PerfCounter string.queryValues
(Class<T> propertyEnum, String perfObject, String perfWmiClass) Query the a Performance Counter using PDH, with WMI backup on failure, for values corresponding to the property enum.queryValuesFromPDH
(Class<T> propertyEnum, String perfObject) Query the a Performance Counter using PDH for values corresponding to the property enum.queryValuesFromWMI
(Class<T> propertyEnum, String wmiClass) Query the a Performance Counter using WMI for values corresponding to the property enum.
-
Field Details
-
TOTAL_INSTANCE
- See Also:
-
TOTAL_OR_IDLE_INSTANCES
- See Also:
-
TOTAL_INSTANCES
- See Also:
-
NOT_TOTAL_INSTANCE
- See Also:
-
NOT_TOTAL_INSTANCES
- See Also:
-
-
Method Details
-
queryValues
public static <T extends Enum<T>> Map<T,Long> queryValues(Class<T> propertyEnum, String perfObject, String perfWmiClass) Query the a Performance Counter using PDH, with WMI backup on failure, for values corresponding to the property enum.- Type Parameters:
T
- The enum type ofpropertyEnum
- Parameters:
propertyEnum
- An enum which implementsPerfCounterQuery.PdhCounterProperty
and contains the WMI field (Enum value) and PDH Counter string (instance and counter)perfObject
- The PDH object for this counter; all counters on this object will be refreshed at the same timeperfWmiClass
- The WMI PerfData_RawData_* class corresponding to the PDH object- Returns:
- An
EnumMap
of the values indexed bypropertyEnum
on success, or an empty map if both PDH and WMI queries failed.
-
queryValuesFromPDH
public static <T extends Enum<T>> Map<T,Long> queryValuesFromPDH(Class<T> propertyEnum, String perfObject) Query the a Performance Counter using PDH for values corresponding to the property enum.- Type Parameters:
T
- The enum type ofpropertyEnum
- Parameters:
propertyEnum
- An enum which implementsPerfCounterQuery.PdhCounterProperty
and contains the WMI field (Enum value) and PDH Counter string (instance and counter)perfObject
- The PDH object for this counter; all counters on this object will be refreshed at the same time- Returns:
- An
EnumMap
of the values indexed bypropertyEnum
on success, or an empty map if the PDH query failed.
-
queryValuesFromWMI
public static <T extends Enum<T>> Map<T,Long> queryValuesFromWMI(Class<T> propertyEnum, String wmiClass) Query the a Performance Counter using WMI for values corresponding to the property enum.- Type Parameters:
T
- The enum type ofpropertyEnum
- Parameters:
propertyEnum
- An enum which implementsPerfCounterQuery.PdhCounterProperty
and contains the WMI field (Enum value) and PDH Counter string (instance and counter)wmiClass
- The WMI PerfData_RawData_* class corresponding to the PDH object- Returns:
- An
EnumMap
of the values indexed bypropertyEnum
if successful, an empty map if the WMI query failed.
-
localizeIfNeeded
Localize a PerfCounter string. English counter names should normally be inHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\Counter
, but language manipulations may delete the009
index. In this case we can assume English must be the language and continue. We may still fail to match the name if the assumption is wrong but it's better than nothing.- Parameters:
perfObject
- A String to localizeforce
- If true, always localize- Returns:
- The localized string if localization successful, or the original string otherwise.
-