Class WmiRequestExecutor

java.lang.Object
org.sentrysoftware.metricshub.extension.wmi.WmiRequestExecutor
All Implemented Interfaces:
IWinRequestExecutor

public class WmiRequestExecutor extends Object implements IWinRequestExecutor
The WmiRequestExecutor class provides utility methods for executing various WMI requests locally or on remote hosts.
  • Constructor Details

    • WmiRequestExecutor

      public WmiRequestExecutor()
  • Method Details

    • executeWmi

      public List<List<String>> executeWmi(String hostname, @NonNull @NonNull IWinConfiguration wmiConfig, @NonNull @NonNull String wbemQuery, @NonNull @NonNull String namespace) throws ClientException
      Execute a WMI query
      Specified by:
      executeWmi in interface IWinRequestExecutor
      Parameters:
      hostname - The hostname of the device where the WMI service is running (null for localhost)
      wmiConfig - WMI Protocol configuration (credentials, timeout)
      wbemQuery - The WQL to execute
      namespace - The WBEM namespace where all the classes reside
      Returns:
      A list of rows, where each row is represented as a list of strings.
      Throws:
      ClientException - when anything goes wrong (details in cause)
    • executeWmiRemoteCommand

      public String executeWmiRemoteCommand(String command, String hostname, String username, char[] password, int timeout, List<String> localFiles) throws ClientException
      Execute a command on a remote Windows system through Client and return an object with the output of the command.
      Parameters:
      command - The command to execute. (Mandatory)
      hostname - The host to connect to. (Mandatory)
      username - The username.
      password - The password.
      timeout - Timeout in seconds
      localFiles - The local files list
      Returns:
      The output of the executed command.
      Throws:
      ClientException - For any problem encountered.
    • isAcceptableException

      public 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.
      Specified by:
      isAcceptableException in interface IWinRequestExecutor
      Parameters:
      t - Throwable to verify
      Returns:
      whether specified exception is acceptable while performing namespace detection
    • executeWinRemoteCommand

      public String executeWinRemoteCommand(String hostname, IWinConfiguration winConfiguration, String command, List<String> embeddedFiles) throws ClientException
      Specified by:
      executeWinRemoteCommand in interface IWinRequestExecutor
      Throws:
      ClientException