Package org.metricshub.wmi
Class WmiHelper
java.lang.Object
org.metricshub.wmi.WmiHelper
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateNetworkResource(String hostname, String namespace) The "network resource" is either just the namespace (for localhost), or \\hostname\\namespace.Extract the exact name of the properties from a WMI result.Extract the exact name of the properties from a WMI result.static booleanisLocalNetworkResource(String networkResource) static booleanisValidWql(String wqlQuery) Check if the WQL Query respect the simple syntax in the form ofSelect * from (where)orSelect a,b,c from (where)is valid.
-
Field Details
-
DEFAULT_NAMESPACE
- See Also:
-
-
Method Details
-
isValidWql
Check if the WQL Query respect the simple syntax in the form ofSelect * from (where)orSelect a,b,c from (where)is valid.- Parameters:
wqlQuery-- Returns:
- whether specified WQL query's syntax is valid or not
-
createNetworkResource
The "network resource" is either just the namespace (for localhost), or \\hostname\\namespace.- Parameters:
hostname- Host to connect to.namespace- The Namespace.- Returns:
- A string representing the Network resource.
-
isLocalNetworkResource
- Parameters:
networkResource- Network resource string to test- Returns:
- whether specified networkResource is local or not
-
extractPropertiesFromResult
public static List<String> extractPropertiesFromResult(List<Map<String, Object>> resultRows, String wql) Extract the exact name of the properties from a WMI result. The interest is to retrieve the exact case of the property names, instead of the lowercase that we have at this stage.- Parameters:
resultRows- The result whose first row will be parsedwql- The WQL query that was used (so we make sure to return the properties in the same order)- Returns:
- a list of property names
- Throws:
IllegalStateException- if the specified WQL is invalid
-
extractPropertiesFromResult
public static List<String> extractPropertiesFromResult(List<Map<String, Object>> resultRows, WqlQuery wqlQuery) Extract the exact name of the properties from a WMI result. The interest is to retrieve the exact case of the property names, instead of the lowercase that we have at this stage. Note: The exact case cannot be retrieved if result is empty, in which case all names are reported in lower case- Parameters:
resultRows- The result whose first row will be parsedwqlQuery- The WQL query that was used (so we make sure to return the properties in the same order)- Returns:
- a list of property names
-