Documentation forServer & Application Monitor
Monitoring your applications and environment is a key capability of SolarWinds Observability Self-Hosted (formerly Hybrid Cloud Observability) and is available in the Essentials edition. Server & Application Monitor (SAM) is also available in a standalone module.

Create a Windows Script Monitor

You can use the predefined Windows Script Monitor to run custom scripts that use Windows Script Host to monitor Windows-based computers. Windows Script Host comes with Visual Basic script (VBScript) and JScript, but can be extended with other scripting languages.

Scripts run on the SolarWinds Platform server and use the credentials you specify. The script must both return an exit code and output a text string containing a statistic value conforming to the specifications described later in this section.

Format the Statistic value to use the same decimal separator as the SolarWinds Platform server, as determined by Windows regional settings.

Before coding and testing a script, review Create custom Windows scripts and Best practices for SAM templates.

  1. Click Settings > All Settings > SAM Settings and click Manage Templates.

  2. When the Manage Application Monitor Templates page appears, search to locate, select, and edit an existing template or click Create New Template.

  3. Click Add Component Monitor(s) and choose Manually Add Component Monitors.
  4. Search for "Windows Script", select the Windows Script Monitor, and click add.

  5. Enter Script Arguments to run for the script. Include the variables ${IP} (or ${Node.DNS}), ${USER}, and ${PASSWORD}, which are replaced with the IP address of the target node, the credential user name, and the credential password.

    Depending on the script type, the command line may require additional information and parameters such as the file path or hostname.

  6. Click Edit Script to enter and test the script.

  7. Test the script by selecting settings for the output, specified node, and specified credentials. Click Get Script Output.

    Output results display using the script code with success or failure and any additional notes.

  8. Click Get Script Output to generate the output and click Save.

    The metrics save to outputs to configure as part of the component monitor. These outputs display at polling intervals for the template.

  9. When complete, click Submit to save the template.

When tested, output generates into customizable sections. Each output section is named by the Unique ID with a Display Name you can edit.

For each output, you can optionally:

  • Convert the value using selected formulas.
  • Configure statistic thresholds to refine alerting for the component monitor. Set the warning and critical thresholds with specific values or baseline data.
  • Select a roll-up status sort option to display the best or worst status up through the template and component monitor.
  • Add notes to describe the script output.

Adapt an existing VBScript to a Windows Script Monitor in a new template

  1. Click Settings > SAM Settings > Create a New Template, and then name the template.
  2. Click Add Component Monitor, then expand the Custom Component Monitors group, and then check Windows Script Monitor.
  3. Click Submit, and then select credentials with the appropriate permissions to run the script on the SolarWinds Platform server, and that also has appropriate permissions to do whatever else the script requires.
  4. Copy the VBScript into the Script Body field.
  5. Type any script arguments into the Script Arguments field.
  6. Specify the critical and warning thresholds, then click Submit.

Macros for Script Arguments

Specify script arguments in the Script Arguments field if needed. You can use the following variables as script arguments:

  • ${IP}: This is replaced with the target node’s IP Address.
  • ${USER}: This is replaced with the user name from the credential set.
  • ${PASSWORD}: This is replaced with the password from the credential set.

Script exit codes and text output

Scripts must report their status by exiting with the appropriate exit code, which is then used to report the status of the monitor in the SolarWinds Platform Web Console, as described in Report status through exit codes. For example, to inform SAM that a VBScript reports Up status, exit the script using code similar to the following, where 0 reports Up: Wscript.quit(0)

Scripts report additional details by sending text to the script’s standard output. See Scripts with text output for details.

Example

Following is a sample VBScript that returns two values:

  • The total number of files in a folder
  • Twice the total number of files in the same folder

To use this script, copy and paste the following code into the Script Body field. In the Scripts Arguments field, type in C:\Windows, or any other folder you want to monitor.

Option Explicit
Dim lstArgs, path, fso, objDir, objFiles
Set lstArgs = WScript.Arguments
If lstArgs.Count = 1 Then
    path = Trim(lstArgs(0))
Else
    WScript.Echo "Usage: wscript.exe filelist.vbs [pathToFiles]"
    WScript.Echo "[pathToFiles] Local or UNC Path"
    WScript.Quit(1)
End If
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(path) Then
    Set objDir = fso.GetFolder(path)
    If IsEmpty(objDir) Then
        WScript.Echo "Message: Object Not Initialized"
        WScript.Quit(1)
    End If
    Set objFiles = objDir.Files
    If objFiles.Count = 0 Then
        WScript.Echo "Message: No files found in the folder."
        WScript.Quit(1)
    End If
    WScript.Echo "Message.Total: " & objFiles.Count & " files in this folder."
    WScript.Echo "Statistic.Total: " & objFiles.Count
    WScript.Echo "Message.Twice: " & objFiles.Count * 2 & " = twice the number of files in this folder."
    WScript.Echo "Statistic.Twice: " & objFiles.Count * 2
    WScript.Quit(0)
Else
    WScript.Echo "Message: Folder Not Found"
    WScript.Quit(1)
End If

Several sample scripts are installed in the following default folder on the SolarWinds Platform server: C:\Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors\WindowsScripts