Skip to main content

Execution (run)

This command allows you to launch the agent to collect information about installed applications and, depending on the selected mode, perform analysis in local mode or network mode.

Note: If you do not specify a mode, the agent will use the default mode configured (otherwise, it will use local mode).


✅ General Usage

watchman-agent run [--mode <local|network>] [-d | --detach]

⚙️ Options

--mode <local|network>
Sets the execution mode of the agent.

local: Performs an analysis of installed applications on the machine.

network: Launches a network-wide analysis for distributed collection.

-d, --detach
Runs the agent in the background. In this mode, an independent process is started, and execution logs are saved to the file ~/watchman_agent_v2.log.

📋 Detailed Operation

  1. Foreground execution

Without the --detach option, the agent checks the mode specified on the command line.

If no mode is provided, it refers to the current configuration (default: local).

Depending on the chosen mode, the agent instantiates either LocalAgent or NetworkAgent and runs the corresponding run() method.

  1. Background execution

When the --detach option is used:

The agent builds a new command explicitly excluding the -d option to avoid recursion.

The command is executed via subprocess.Popen in a detached session.

The outputs (stdout and stderr) are redirected to the log file located at ~/watchman_agent_v2.log.

A confirmation message is displayed to inform that the process is running in the background