Documentation forServer & Application Monitor

Linux/Unix scripting in SAM component monitors

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

You can use the Linux/Unix Script Monitor included in SAM to run a custom script on Linux/Unix systems. You can also add multiple instances of this script monitor to a template to run different custom scripts, and then assign that template to multiple nodes to start monitoring your systems.

This topic details the format and usage of Linux or Unix scripts for SAM, including arguments and output formats. It does not provide information on coding in programming languages such as Perl or Python.

To display templates that use customized instances of the Linux/Unix Script Monitor:

  1. Navigate to the Manage Templates page.

  2. Click Settings > All Settings > SAM Settings.

  3. Click Manage Templates.

  4. In the search field, enter Linux or Unix to filter the list.

Related topics include:

The SAM forum in THWACK also provides content about Linux/Unix scripting. Sample script monitors are available on the Orion server at: C:\Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors

Linux/Unix script support in SAM


Linux/Unix is installed and configured on target servers.


Include credentials that can run scripts on the monitored Linux-based computer.

Python installation

Verify your installation of python and python-xml. Depending on your Linux distribution, you may have need to install these libraries. You can verify your Python installed libraries with the following command:

python -c "import sys; from xml.dom.minidom import parseString; print sys.version"

See the Python site (© Python Software Foundation, available at, obtained on February 5, 2020) for documentation and install commands. The following command typically updates and installs the required Python libraries: apt-get install python

Depending on your Linux distribution, you may need to verify install and configure specific applications and services to use the Linux/Unix Script Monitor. For example, to use it with the Apache template, you need to configure Apache access. For full configuration details for all services, see Configure Linux/Unix systems for monitoring by the Orion agent.

How the Linux/Unix script works

The Linux/Unix Script Monitor executes the script remotely using the target server you provide then reports the metrics:

  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 Orion 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

SolarWinds recommends writing scripts in the Linux/Unix Script Monitor to verify correct access between the Main Polling Engine, SAM, and target server(s). You can write and test scripts in your preferred ISE, connecting and testing against the target server to verify if the code functions. You must test the script through the Linux/Unix Script Monitor to ensure entered credentials and target server access, and to generate metrics output.

The script in the monitor 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

Test the component monitor and script before assigning and using the component monitor within a template as is. Testing the script generates the required database tables for metrics output and verifies output processes.

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 then copy and paste the code into this field. For example, some customer use Python. 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 Orion Web Console. For details, see Report status through exit codes in SAM script monitors.

Command Line field

Enter your command line parameters used to run the script. 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.