Documentation forServer & Application Monitor
Monitoring your applications and environment is a key capability of Hybrid Cloud Observability and is also available in a standalone module, Server & Application Monitor (SAM). Hybrid Cloud Observability and SAM are built on the self-hosted SolarWinds Platform.

Linux/Unix scripting in SAM component monitors

Script Monitors (also called "script component monitors") offer limitless options to collect metrics for target servers in SAM. Each monitor has different options to enter credentials, set working directories, run scripts, and then generate and display returned values as output.

You can use the Linux/Unix Script Monitor to run custom scripts on Linux/Unix systems by either using it in an existing application monitor template, or adding it to a custom template. When the template is ready, test it, and then assign it to target nodes to begin monitoring.

Topics in this section include:

Note the following details about Linux/Unix Script Monitors:

  • (Recommended) Review Linux/Unix Script Monitor for details about prerequisites and fields.

    Sample script monitors are available on the SolarWinds Platform server at: C:\Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors

  • You can write and test scripts in your preferred ISE to verify that the code functions properly, but SolarWinds recommends writing scripts and testing them in the SolarWinds Platform Web Console to verify access to target servers and check output. Testing in the SolarWinds Platform Web Console also generates the required database tables for metric output.

  • For scripts with Nagios formats, use the Nagios Script Monitor instead.

  • You can display templates that include Linux/Unix Script Monitors in the Component Monitor Library.

How a Linux/Unix script works

Here is an overview of how the Linux/Unix Script Monitor executes a script remotely on a target server:

  1. Connects to the target server using SSH.
  2. Executes the script using the command line value.

    The script executes on the target system, not the SolarWinds Platform server. You may need to enter additional parameters to satisfy the hostname and credentials needed to execute.

    The file saves to the Script Working Directory on the remote server.

  3. Captures metrics and returns the data to the monitor.
  4. Closes the SSH connection.
  5. SAM parses the text output, saves data, and reports the values using the output formats from the component monitor.

Elements of a Linux/Unix script

Each script should include:

  • Parameters to run the script in the Command Line field
  • Script code added in the Script Body field with credentials
  • Exit codes to report status in the script
  • Formatted output after running the script

Script Working Directory field

Enter a working directory on the target system where the script processes when executed. The default directory is /tmp.

Script Body field

Use the Script Body field to enter your script code. You can write and compile the script in a language you prefer, such as Python, then copy and paste the code into this field. Depending on the language, you may need add for the script and command line to execute.

Scripts must report their status by exiting with the appropriate exit code. The exit code is used to report the status of the monitor, as displayed in the SolarWinds Platform Web Console. For details, see Report status through exit codes in SAM script monitors.

Command Line field

Specify the shell command run after the SSH connection is established. Use the format of <scripting language path> ${SCRIPT} such as perl, python, or bash. {SCRIPT} is replaced by the actual file name of the script after it is deployed to the target node. A temporary file is created in temp directory for the script.

The Command Line field is limited to 266 characters, minus the length of the ${SCRIPT} variable after being resolved to a file name such as The typical length of the file name is around 16 characters, so the actual user Command Line input should be less than 266 – 16, or about 250 characters (not including the length of the 9 characters for the “${SCRIPT}” variable itself).

To pass a longer command line to a target node (for example, a Solaris system), create a shell script on the target node (for example, that contains the long command line, and place the call to this script in the Command Line field (for example, /opt/sw/

See also Linux/Unix Script Monitor in the SAM Application Monitor Template Reference.

Use variables in scripts

You can use the following variables in the Script Body field:

  • ${IP} - Replaced with the target node’s IP address.
  • ${USER} - Replaced with the user name from the credential.
  • ${PASSWORD} - Replaced with the password from the credential.

Use the following variable in the command line field:

  • ${SCRIPT} - Replaced with the script body.