Class PerfDataUtil
java.lang.Object
oshi.util.platform.windows.PerfDataUtil
Helper class to centralize the boilerplate portions of PDH counter setup and allow applications to easily add, query,
and remove counters.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddCounter(WinNT.HANDLEByReference query, String path, WinNT.HANDLEByReference p) Adds a pdh counter to a querystatic booleanClose a pdh querystatic booleanOpen a pdh querystatic longqueryCounter(WinNT.HANDLEByReference counter) Get value of pdh counterstatic longGet value of pdh counter's second value (base counters)static booleanRemove a pdh counterstatic longUpdate a query and get the timestamp
-
Method Details
-
updateQueryTimestamp
Update a query and get the timestamp- Parameters:
query- The query to update all counters in- Returns:
- The update timestamp of the first counter in the query
-
openQuery
Open a pdh query- Parameters:
q- pointer to the query- Returns:
- true if successful
-
closeQuery
Close a pdh query- Parameters:
q- pointer to the query- Returns:
- true if successful
-
queryCounter
Get value of pdh counter- Parameters:
counter- The counter to get the value of- Returns:
- long value of the counter, or negative value representing an error code
-
querySecondCounter
Get value of pdh counter's second value (base counters)- Parameters:
counter- The counter to get the value of- Returns:
- long value of the counter's second value, or negative value representing an error code
-
addCounter
public static boolean addCounter(WinNT.HANDLEByReference query, String path, WinNT.HANDLEByReference p) Adds a pdh counter to a query- Parameters:
query- Pointer to the query to add the counterpath- String name of the PerfMon counter. For Vista+, must be in English. Must localize this path for pre-Vista.p- Pointer to the counter- Returns:
- true if successful
-
removeCounter
Remove a pdh counter- Parameters:
p- pointer to the counter- Returns:
- true if successful
-