Class PerfCounterWildcardQuery<T extends java.lang.Enum<T>>
@NotThreadSafe public class PerfCounterWildcardQuery<T extends java.lang.Enum<T>> extends PerfCounterQuery<T>
An instance of this class should only be instantiated and used within the context of a single thread.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePerfCounterWildcardQuery.PdhCounterWildcardPropertyContract for Counter Property EnumsNested classes/interfaces inherited from class oshi.util.platform.windows.PerfCounterQuery
PerfCounterQuery.CounterDataSource, PerfCounterQuery.PdhCounterProperty -
Field Summary
Fields inherited from class oshi.util.platform.windows.PerfCounterQuery
counterQuery, NOT_TOTAL_INSTANCE, NOT_TOTAL_INSTANCES, pdhQueryHandler, perfObject, perfWmiClass, propertyEnum, queryKey, source, TOTAL_INSTANCE, TOTAL_INSTANCES -
Constructor Summary
Constructors Constructor Description PerfCounterWildcardQuery(java.lang.Class<T> propertyEnum, java.lang.String perfObject, java.lang.String perfWmiClass)Construct a new object to hold performance counter data source and resultsPerfCounterWildcardQuery(java.lang.Class<T> propertyEnum, java.lang.String perfObject, java.lang.String perfWmiClass, java.lang.String queryKey)Construct a new object to hold performance counter data source and results -
Method Summary
Modifier and Type Method Description java.util.List<java.lang.String>getInstancesFromLastQuery()List the instances corresponding to the value map listsprotected booleaninitPdhCounters()Initialize PDH counters for this data source.java.util.Map<T,java.lang.Long>queryValues()Query the current data source (PDH or WMI) for the Performance Counter values corresponding to the property enum.java.util.Map<T,java.util.List<java.lang.Long>>queryValuesWildcard()Query the current data source (PDH or WMI) for the Performance Counter values corresponding to the property enum.protected voidunInitPdhCounters()Uninitialize PDH counters for this data source.Methods inherited from class oshi.util.platform.windows.PerfCounterQuery
initWmiCounters, setDataSource, unInitWmiCounters
-
Constructor Details
-
PerfCounterWildcardQuery
public PerfCounterWildcardQuery(java.lang.Class<T> propertyEnum, java.lang.String perfObject, java.lang.String perfWmiClass)Construct a new object to hold performance counter data source and results- Parameters:
propertyEnum- An enum which implementsPerfCounterWildcardQuery.PdhCounterWildcardPropertyand contains the WMI field (Enum value) and PDH Counter string (instance or counter).The first element of the enum defines the instance filter, rather than a counter name. This acts as a filter for PDH instances only and should correlate with a WMI String field defining the same name. If the instance is null then all counters will be added to the PDH query, otherwise the PDH counter will only include instances which are wildcard matches with the given instance, replacing '?' with a single character, '*' with any number of characters, and reversing the test if the first character is '^'. If the counter source is WMI, the instance filtering has no effect, and it is the responsibility of the user to add filtering to the perfWmiClass string using a WHERE clause.
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
-
PerfCounterWildcardQuery
public PerfCounterWildcardQuery(java.lang.Class<T> propertyEnum, java.lang.String perfObject, java.lang.String perfWmiClass, java.lang.String queryKey)Construct a new object to hold performance counter data source and results- Parameters:
propertyEnum- An enum which implementsPerfCounterWildcardQuery.PdhCounterWildcardPropertyand contains the WMI field (Enum value) and PDH Counter string (instance or counter).The first element of the enum defines the instance filter, rather than a counter name. This acts as a filter for PDH instances only and should correlate with a WMI String field defining the same name. If the instance is null then all counters will be added to the PDH query, otherwise the PDH counter will only include instances which are wildcard matches with the given instance, replacing '?' with a single character, '*' with any number of characters, and reversing the test if the first character is '^'. If the counter source is WMI, the instance filtering has no effect, and it is the responsibility of the user to add filtering to the perfWmiClass string using a WHERE clause.
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 objectqueryKey- An optional key for PDH counter updates; defaults to the PDH object name
-
-
Method Details
-
initPdhCounters
protected boolean initPdhCounters()Initialize PDH counters for this data source. Adds necessary counters to a PDH Query. Initialize PDH counters for this data source. Adds necessary counters to a PDH Query.- Overrides:
initPdhCountersin classPerfCounterQuery<T extends java.lang.Enum<T>>- Returns:
- True if the counters were successfully added.
-
unInitPdhCounters
protected void unInitPdhCounters()Uninitialize PDH counters for this data source. Removes necessary counters from the PDH Query, releasing their handles. Uninitialize PDH counters for this data source. Removes necessary counters from the PDH Query, releasing their handles.- Overrides:
unInitPdhCountersin classPerfCounterQuery<T extends java.lang.Enum<T>>
-
queryValues
Query the current data source (PDH or WMI) for the Performance Counter values corresponding to the property enum. This method is not implemented on this class.- Overrides:
queryValuesin classPerfCounterQuery<T extends java.lang.Enum<T>>- Returns:
- A map of the values by the counter enum.
- See Also:
queryValuesWildcard()
-
queryValuesWildcard
Query the current data source (PDH or WMI) for the Performance Counter values corresponding to the property enum.- Returns:
- A map of the values by the counter enum.
-
getInstancesFromLastQuery
public java.util.List<java.lang.String> getInstancesFromLastQuery()List the instances corresponding to the value map lists- Returns:
- A list of the in the order they are returned in the value map query
-