Submit a ticketCall us

Webinar: Web Help Desk for HR, Facilities and Accounting Departments
This webinar will focus on use cases for HR, Facilities and Accounting.

Having a unified ticketing and asset management system for all the departments in your company can provide end-users with a seamless experience and make things easier for your IT team. Yet, with different business tasks and objectives, many departments don’t fully understand the capabilities of Web Help Desk and how the software can be customized for effective use in their departments.
Register Now.

Home > Success Center > Server & Application Monitor (SAM) > SAM Custom Template Guide > Linux/Unix scripting in SAM custom templates

Linux/Unix scripting in SAM custom templates

The SAM Linux/Unix Script monitor supports custom scripts on Linux-based systems. You can create multiple instances of this component monitor per template to run custom scripts.

This information details the format and usage of Linux or Unix scripts for SAM, including script arguments and output formats. This information does not provide information on coding in programming languages such as Perl or Python. Prior to using this monitor, review the Linux/Unix support in SAM to configure the Linux target server.

After configuring Nagios and reviewing the components of a script, create Linux/Unix scripts using the component monitor per template.

Linux/Unix script support in SAM

SAM supports using Linux/Unix scripting with Nagios installed and configured on target servers.

To locate a list of out-of-the-box Linux and Unix script supporting templates, navigate to the Manage Templates page. Click Settings > All Settings > SAM Settings and click Manage Templates. In the search field, enter Linux or Unix to filter the list. These templates use customized instances of the Linux/Unix Script Monitor.

Credentials

You need to include credentials that can run scripts on the monitored Linux-based computer.

Python installation

You need to 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 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 the Linux/Unix Script monitor with Apache services (as with the Apache template), you need to configure Apache access. For full configuration details for all services, see Linux system configurations for Component Monitors.

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.

Components 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 the 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

You must 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 Fields

Script Working Directory field

Enter a working directory where the script processes when executed. This is a directory located on the target system. A popular 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, customers have used Python. Depending on the language, you may need to take additional steps 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, displayed in the Orion Web Console.

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.

Last modified
12:33, 9 May 2017

Tags

Classifications

Public