Class PerfCounterWildcardQuery<T extends java.lang.Enum<T>>

java.lang.Object
oshi.util.platform.windows.PerfCounterQuery<T>
oshi.util.platform.windows.PerfCounterWildcardQuery<T>

@NotThreadSafe
public class PerfCounterWildcardQuery<T extends java.lang.Enum<T>>
extends PerfCounterQuery<T>
Encapsulates information for a Performance Counter query.

An instance of this class should only be instantiated and used within the context of a single thread.

  • 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 implements PerfCounterWildcardQuery.PdhCounterWildcardProperty and 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 time
      perfWmiClass - 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 implements PerfCounterWildcardQuery.PdhCounterWildcardProperty and 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 time
      perfWmiClass - The WMI PerfData_RawData_* class corresponding to the PDH object
      queryKey - 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:
      initPdhCounters in class PerfCounterQuery<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:
      unInitPdhCounters in class PerfCounterQuery<T extends java.lang.Enum<T>>
    • queryValues

      public 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. This method is not implemented on this class.
      Overrides:
      queryValues in class PerfCounterQuery<T extends java.lang.Enum<T>>
      Returns:
      A map of the values by the counter enum.
      See Also:
      queryValuesWildcard()
    • queryValuesWildcard

      public 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.
      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