Class WmiHelper

java.lang.Object
org.metricshub.wmi.WmiHelper

public abstract class WmiHelper extends Object
  • Field Details

  • Method Details

    • isValidWql

      public static boolean isValidWql(String wqlQuery)
      Check if the WQL Query respect the simple syntax in the form of Select * from (where) or Select a,b,c from (where) is valid.
      Parameters:
      wqlQuery -
      Returns:
      whether specified WQL query's syntax is valid or not
    • createNetworkResource

      public static String createNetworkResource(String hostname, String namespace)
      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

      public static boolean isLocalNetworkResource(String networkResource)
      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 parsed
      wql - 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 parsed
      wqlQuery - The WQL query that was used (so we make sure to return the properties in the same order)
      Returns:
      a list of property names