Class WmiRequestExecutor
java.lang.Object
org.sentrysoftware.metricshub.extension.wmi.WmiRequestExecutor
- All Implemented Interfaces:
IWinRequestExecutor
The WmiRequestExecutor class provides utility methods for executing
various WMI requests locally or on remote hosts.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecuteWinRemoteCommand(String hostname, IWinConfiguration winConfiguration, String command, List<String> embeddedFiles) executeWmi(String hostname, @NonNull IWinConfiguration wmiConfig, @NonNull String wbemQuery, @NonNull String namespace) Execute a WMI queryexecuteWmiRemoteCommand(String command, String hostname, String username, char[] password, int timeout, List<String> localFiles) Execute a command on a remote Windows system through Client and return an object with the output of the command.booleanAssess 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.
-
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:
executeWmiin interfaceIWinRequestExecutor- Parameters:
hostname- The hostname of the device where the WMI service is running (nullfor localhost)wmiConfig- WMI Protocol configuration (credentials, timeout)wbemQuery- The WQL to executenamespace- 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 secondslocalFiles- The local files list- Returns:
- The output of the executed command.
- Throws:
ClientException- For any problem encountered.
-
isAcceptableException
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:
isAcceptableExceptionin interfaceIWinRequestExecutor- 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:
executeWinRemoteCommandin interfaceIWinRequestExecutor- Throws:
ClientException
-