Class PerfCounter

java.lang.Object
oshi.driver.common.windows.perfmon.PerfCounter

@Immutable public final class PerfCounter extends Object
Encapsulates the three string components of a PDH performance counter path, plus whether it refers to the base (SecondValue) of a multi-value counter.
  • Field Details

    • BASE_SUFFIX

      public static final String BASE_SUFFIX
      Suffix appended to counter names in enum definitions to indicate that the SecondValue (base) should be read instead of the FirstValue.
      See Also:
  • Constructor Details

    • PerfCounter

      public PerfCounter(String objectName, String instanceName, String counterName)
      Creates a PerfCounter.
      Parameters:
      objectName - the PDH object name
      instanceName - the instance name
      counterName - the counter name (may end with _Base for SecondValue)
  • Method Details

    • getObject

      public String getObject()
      Gets the PDH object name.
      Returns:
      Returns the object.
    • getInstance

      public String getInstance()
      Gets the PDH instance name.
      Returns:
      Returns the instance.
    • getCounter

      public String getCounter()
      Gets the PDH counter name.
      Returns:
      Returns the counter.
    • isBaseCounter

      public boolean isBaseCounter()
      Checks whether this is a base (SecondValue) counter.
      Returns:
      Returns whether the counter is a base counter
    • getCounterPath

      public String getCounterPath()
      Returns the path for this counter
      Returns:
      A string representing the counter path
    • stripBaseSuffix

      public static String stripBaseSuffix(String counterName)
      Strips the BASE_SUFFIX from a counter name if present.
      Parameters:
      counterName - The counter name, possibly ending with _Base
      Returns:
      The counter name without the _Base suffix, or the original name if the suffix is not present
    • isBase

      public static boolean isBase(String counterName)
      Tests whether a counter name has the BASE_SUFFIX.
      Parameters:
      counterName - The counter name to test
      Returns:
      true if the counter name ends with _Base
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object