Submit a ticketCall us

Get a crash course on Network Monitoring delivered right to your inbox
This free 7-day email course provides a primer to the philosophy, theory, and fundamental concepts involved in IT monitoring. Lessons will explain not only how to perform various monitoring tasks, but why and when you should use them. Sign up now.

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

Windows scripting in SAM custom templates

The SAM Windows Script monitor supports custom scripts on Windows-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 Windows Scripts for SAM, including script arguments and output formats. This information does not provide information on coding in programming languages such as those listed in the Script Engine field.

After configuring Windows and reviewing the components of a script, create Windows scripts using the component monitor per template.

Windows Script support in SAM

SAM supports using Windows scripting on target Windows-based computers.

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

Use different scripting languages

On Windows-based computers, you can use one of several scripting languages or install a non-native scripting language.

  1. Install the scripting language engine or software on the Orion server.
  2. When installed, verify the install location for the scripting language is in the system environment path variable.
  3. In the SAM template Windows script monitor, enter the scripting language in the Script Engine.

How the Windows script works

The Windows Script Monitor executes the script on the Orion server connecting to the target server to collect metrics:

  1. Executes the script using the script arguments on the Orion server.

  2. The monitor connects to the target server using entered credentials for collecting metrics.
  3. SAM parses the text output, saves data, and reports the values using the output formats from the component monitor.

Components of a Windows Script

SolarWinds recommends writing scripts in the Windows 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 Windows 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 Scripts Arguments field
  • Script code added in the Script Body field with credentials
  • The script engine to use for the supported programming language
  • 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 Arguments field

This field is in the script editing window and allows you to specify arguments to pass to the script. You may include the variables ${IP} (or ${Node.DNS}), ${USER}, and ${PASSWORD}, which are replaced respectively by the IP address of the target node, the credential user name, and the credential password.

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.

Script Engine

This field allows you to specify the scripting language to be used. The default value is vbscript. Below is a list of scripting engines that the Windows Script Host supports:

Name File Extensions Availability

VBScript

.vbs

Installed by default

JScript

.js

Installed by default

PerlScript

.pls

Freeware

ooRexxScript

.rxs

Freeware

PythonScript

.pys

Freeware

TclScript

.tcls

Freeware

ActivePHPScript

.phps

Freeware

RubyScript

.rbs

Freeware

Object Rexx engine

 

Commercial

Delphi scripting engine

 

Commercial

VBscript runs locally on the SAM server only. PowerShell uses WINRM that runs over TCP ports 5985 and 5986. All Linux, Unix, and Nagios script monitors use SSH over TCP Port 22. 

Last modified
12:33, 9 May 2017

Tags

Classifications

Public