Class WqlDetectionHelper

java.lang.Object
org.sentrysoftware.metricshub.engine.strategy.utils.WqlDetectionHelper

public class WqlDetectionHelper extends Object
Helper class for WBEM/WMI namespace detection using WQL queries. This class provides methods to find possible namespaces, detect suitable namespaces, and perform WQL detection tests.
  • Constructor Details

    • WqlDetectionHelper

      public WqlDetectionHelper(ClientsExecutor clientsExecutor)
      Constructs a new instance of WqlDetectionHelper with the provided ClientsExecutor.
      Parameters:
      clientsExecutor - The ClientsExecutor to be used for WQL queries.
  • Method Details

    • findPossibleNamespaces

      public WqlDetectionHelper.PossibleNamespacesResult findPossibleNamespaces(String hostname, WbemConfiguration configuration)
      Find the possible WBEM namespaces using the configured WbemConfiguration.
      Parameters:
      hostname - The hostname of the host device.
      configuration - The user's configured WbemConfiguration.
      Returns:
      A WqlDetectionHelper.PossibleNamespacesResult wrapping the success state, the message in case of errors and the possibleWmiNamespaces Set.
    • findPossibleNamespaces

      public WqlDetectionHelper.PossibleNamespacesResult findPossibleNamespaces(String hostname, IWinConfiguration configuration)
      Find the possible WMI namespaces on specified hostname with specified credentials.
      Parameters:
      hostname - The hostname of the device.
      configuration - Win configuration (credentials, timeout)
      Returns:
      A WqlDetectionHelper.PossibleNamespacesResult wrapping the success state, the message in case of errors and the possibleWmiNamespaces Set.
    • detectNamespace

      public WqlDetectionHelper.NamespaceResult detectNamespace(String hostname, IConfiguration configuration, WqlCriterion criterion, Set<String> possibleNamespaces)
      Detect the WBEM/WMI namespace applicable to the specified WBEM/WMI criterion.
      The namespace in the criterion must be "Automatic".
      Parameters:
      hostname - The host name
      configuration - WBEM/WMI configuration (credentials, timeout)
      criterion - WQL detection properties (WQL, expected result, namespace must be "Automatic")
      possibleNamespaces - The possible namespaces to execute the WQL on
      Returns:
      A WqlDetectionHelper.NamespaceResult wrapping the detected namespace and the error message if the detection fails.
    • performDetectionTest

      public CriterionTestResult performDetectionTest(String hostname, @NonNull @NonNull IConfiguration configuration, @NonNull @NonNull WqlCriterion criterion)
      Perform the specified WQL detection test, on the specified WBEM/WMI protocol configuration.
      Note: "Automatic" namespace is not supported in this method.
      Parameters:
      hostname - Host name
      configuration - WBEM/WMI configuration (credentials, timeout)
      criterion - WQL detection properties (WQL, namespace, expected result)
      Returns:
      CriterionTestResult which indicates if the check has succeeded or not.
    • isAcceptableException

      public static boolean isAcceptableException(Throwable t)
      Assess whether an exception (or any of its causes) is simply an error saying that the requested namespace of class doesn't exist, which is considered okay.
      Parameters:
      t - Exception to verify
      Returns:
      whether specified exception is acceptable while performing namespace detection