Remote Module
The Remote module is an advanced automation tool that allows the Probe to execute commands directly on the operating system or environment where it is installed. This feature is ideal for automating incident responses, performing specific diagnostic collections, or triggering local scripts based on monitoring events.
Available Functions
Section titled “Available Functions”1. remote.exec(command, [arg1], [arg2], ...)
Section titled “1. remote.exec(command, [arg1], [arg2], ...)”Executes a command on the remote operating system with the specified arguments.
Parameters:
command(string): Name of the command/program to be executed…(optional, strings): Additional arguments for the command
Return:
tuple:(out, err)where:out(string or nil): Standard output of the command if successful, ornilif it failserr(string or nil): Error output of the command if it fails, ornilif successful
Behavior:
-
The command is executed as the user
monsta-probeon Windows environments andmonstasbon Linux environments.-
If the command returns exit code
0(success):outcontains the command outputerrisnil
-
If the command fails (code ≠
0):outis nilerrcontains the command’s error output (stderr)
-
If there is an execution error (command not found, etc.):
outisnilerrcontains the error message
-
Usage Example:
local resp = probe.exec("ping", { "C:\\Windows\\System32\\ping.exe" }, { "127.0.0.1" })
if resp.status == "Success" then print(resp.stdout) endSupport for Variable Arguments
Section titled “Support for Variable Arguments”Accepts any number of arguments:
-- 1 argumentprocess.exec("ls")
-- 2 argumentsprocess.exec("ls", "-la")
-- Multiple argumentsprocess.exec("find", ".", "-name", "*.log", "-type", "f", "-mtime", "+7")