Top Description Inners Fields Constructors Methods
com.sun.jna.platform.win32

public abstract Class PdhUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, com.sun.jna.Memory, .Native, com.sun.jna.platform.win32.WinDef.DWORD, .WinDef.DWORDByReference

Pdh utility API.
Author
widdis[at]gmail[dot]com

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PdhUtil.PdhEnumObjectItems

Holder Object for PdhEnumObjectsItems.

public static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static PdhUtil.PdhEnumObjectItems

Returns:

Returns a List of Strings of the counters for the object.
PdhEnumObjectItems
(String
String that specifies the name of the log file used to enumerate the counter and instance names. If NULL, the function uses the computer specified in the szMachineName parameter to enumerate the names.
szDataSource
,
String
String that specifies the name of the computer that contains the counter and instance names that you want to enumerate. Include the leading slashes in the computer name, for example, \\computername. If the szDataSource parameter is NULL, you can set szMachineName to NULL to specify the local computer.
szMachineName
,
String
String that specifies the name of the object whose counter and instance names you want to enumerate.
szObjectName
,
int
Detail level of the performance items to return. All items that are of the specified detail level or less will be returned.
dwDetailLevel
)

Utility method to call Pdh's PdhEnumObjectItems that allocates the required memory for the lists parameters based on the type mapping used, calls to PdhEnumObjectItems, and returns the received lists of strings.

public static int

Returns:

The counter's index if it exists, or 0 otherwise.
PdhLookupPerfIndexByEnglishName
(String
The English name of the performance counter
szNameBuffer
)

Utility method similar to Pdh's PdhLookupPerfIndexByName that returns the counter index corresponding to the specified counter name in English.

public static String

Returns:

Returns the name of the performance object or counter.
PdhLookupPerfNameByIndex
(String
Null-terminated string that specifies the name of the computer where the specified performance object or counter is located. The computer name can be specified by the DNS name or the IP address. If NULL, the function uses the local computer.
szMachineName
,
int
Index of the performance object or counter.
dwNameIndex
)

Utility method to call Pdh's PdhLookupPerfNameByIndex that allocates the required memory for the szNameBuffer parameter based on the type mapping used, calls to PdhLookupPerfNameByIndex, and returns the received string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHAR_TO_BYTESback to summary
private static final int CHAR_TO_BYTES
ENGLISH_COUNTER_KEYback to summary
private static final String ENGLISH_COUNTER_KEY
ENGLISH_COUNTER_VALUEback to summary
private static final String ENGLISH_COUNTER_VALUE

Constructor Detail

PdhUtilback to summary
public PdhUtil()

Method Detail

PdhEnumObjectItemsback to summary
public static PdhUtil.PdhEnumObjectItems PdhEnumObjectItems(String szDataSource, String szMachineName, String szObjectName, int dwDetailLevel)

Utility method to call Pdh's PdhEnumObjectItems that allocates the required memory for the lists parameters based on the type mapping used, calls to PdhEnumObjectItems, and returns the received lists of strings.

Parameters
szDataSource:String

String that specifies the name of the log file used to enumerate the counter and instance names. If NULL, the function uses the computer specified in the szMachineName parameter to enumerate the names.

szMachineName:String

String that specifies the name of the computer that contains the counter and instance names that you want to enumerate. Include the leading slashes in the computer name, for example, \\computername. If the szDataSource parameter is NULL, you can set szMachineName to NULL to specify the local computer.

szObjectName:String

String that specifies the name of the object whose counter and instance names you want to enumerate.

dwDetailLevel:int

Detail level of the performance items to return. All items that are of the specified detail level or less will be returned.

Returns:PdhUtil.PdhEnumObjectItems

Returns a List of Strings of the counters for the object.

PdhLookupPerfIndexByEnglishNameback to summary
public static int PdhLookupPerfIndexByEnglishName(String szNameBuffer)

Utility method similar to Pdh's PdhLookupPerfIndexByName that returns the counter index corresponding to the specified counter name in English. Uses the registry on the local machine to find the index in the English locale, regardless of the current language setting on the machine.

Parameters
szNameBuffer:String

The English name of the performance counter

Returns:int

The counter's index if it exists, or 0 otherwise.

PdhLookupPerfNameByIndexback to summary
public static String PdhLookupPerfNameByIndex(String szMachineName, int dwNameIndex)

Utility method to call Pdh's PdhLookupPerfNameByIndex that allocates the required memory for the szNameBuffer parameter based on the type mapping used, calls to PdhLookupPerfNameByIndex, and returns the received string.

Parameters
szMachineName:String

Null-terminated string that specifies the name of the computer where the specified performance object or counter is located. The computer name can be specified by the DNS name or the IP address. If NULL, the function uses the local computer.

dwNameIndex:int

Index of the performance object or counter.

Returns:String

Returns the name of the performance object or counter.

com.sun.jna.platform.win32 back to summary

public Class PdhUtil.PdhEnumObjectItems

extends Object
Class Inheritance

Holder Object for PdhEnumObjectsItems. The embedded lists are modifiable lists and can be accessed through the getCounters() and getInstances() accessors.

Field Summary

Modifier and TypeField and Description
private final List<String>
private final List<String>

Constructor Summary

AccessConstructor and Description
public
PdhEnumObjectItems(List<String> counters, List<String> instances)

Method Summary

Modifier and TypeMethod and Description
private List<String>
public List<String>

Returns:

the embedded counters list, all calls to this function receive the same list and thus share modifications
getCounters
()

public List<String>

Returns:

the embedded instances list, all calls to this function receive the same list and thus share modifications
getInstances
()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

countersback to summary
private final List<String> counters
instancesback to summary
private final List<String> instances

Constructor Detail

PdhEnumObjectItemsback to summary
public PdhEnumObjectItems(List<String> counters, List<String> instances)

Method Detail

copyAndEmptyListForNullListback to summary
private List<String> copyAndEmptyListForNullList(List<String> inputList)
getCountersback to summary
public List<String> getCounters()
Returns:List<String>

the embedded counters list, all calls to this function receive the same list and thus share modifications

getInstancesback to summary
public List<String> getInstances()
Returns:List<String>

the embedded instances list, all calls to this function receive the same list and thus share modifications

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
com.sun.jna.platform.win32 back to summary

public final Class PdhUtil.PdhException

extends RuntimeException
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public
PdhException(int errorCode)

Method Summary

Modifier and TypeMethod and Description
public int

Field Detail

errorCodeback to summary
private final int errorCode

Constructor Detail

PdhExceptionback to summary
public PdhException(int errorCode)

Method Detail

getErrorCodeback to summary
public int getErrorCode()