Using Remote Script Executor, you can execute scripts on both Linux and Windows workstations with different script types.

  • User-defined external arguments support to the script through custom attributes.
  • Monitor Level script execution – Ability to pull more metrics in a single script execution.
  • Ability to execute different types of scripts through custom script options apart from default options.
  • Able to use Credentials attached to the device in the script using the dynamic macro support.
  • The monitoring of Windows Workstations through Linux Gateway is not supported.

Prerequisite: Gateway version 7.0.0.

Create metrics

Metrics enter the metadata to correlate the script output and must match the metrics names added to the Monitor.

  1. Select a client from the All Clients list.

  2. Go to Setup > Monitoring > Metrics.

  3. From METRICS, click + Add and enter:

    • Metric Scope: Select Partner Metric or Client Specific Metric.

    • Adaptor Type: Select Application.

    • Application Type: Select Remote Script Executor.

    • Name: Unique Name for the metric. OpsRamp recommends <vendorname>.<application name>.<component>.<metric> as naming convention for the metric. For example, apache.tomcat.webapps.count.

    • Tag Name: User-defined tags for better filtering.

    • Display Name: Enter Display Name. For example, System Drive Free Space.

    • Description: Enter the reason for the metric.

    • Data Point type: Value chosen to plot data in the graph.

    • Units: Required values for Units. You can choose Units depending on the chosen Data Point Type.

    • Unit Multiplication Factor: Value chosen to multiply a value based on the chosen unit.

    • Data Point Conversion: One of the following options:

      • Value: To populate data using values.
      • Enumerated Map: To populate alert and graph details after adding the states such as Up or Down. The screen displays an more section where you can add the state descriptions and select Alerts and Graphs to populate data.
    • Metric Processing: One of the following values for processing the Metric:

      • Notification

      • Graph

      • Graph and Notification

      • To configure values for Graph and Notification:

        • Warning if value: Warning threshold value.
        • Critical if value: Critical threshold value.
        • Subject: Subject for the metric.
        • Description: Description for the metric.
  4. Click Save.

Remote Script Executor Create Metric

Create monitor

Custom Remote Script Executor Monitor is a collection of Remote Script Executor metrics. You can create a template using the Remote Script Executor monitor.

Prerequisite: Add the required custom parameters.

  1. From All Clients, select a client.
  2. Go to Setup > Monitoring > Monitors.
  3. From Monitors, click + Add.
  4. From CREATE A MONITOR, enter the details for the following parameters and click Save.
    • Monitor Scope: Select either Partner Monitor or Client Specific Monitor.
    • Type: Select Application.
    • Application Type: Select Remote Script Executor.
    • Name: Enter a unique name for the monitor.
    • Description: Enter the reason for creating the monitor.
    • Script: Custom script in the Script text box. You can refer to Script and JSON output formats-example to view the example script.
    • Metrics: To add Metrics:
      1. From Metrics, click Add Metrics.
      2. Search the metric and click Add Metrics. The Metrics section displays the selected metric.
      3. After adding the metrics, navigate to Configuration Parameters.
    • Configuration Parameters: To add configuration Parameters:
    1. Enter Default Value for all the configuration parameters.
    2. Select the Configurable checkbox.
    3. Click +Add.
    4. Enter Configuration Parameters depending on the selected script type.
      You can view the default value for the respective Name selected.
      If you select the Custom value in Configuration Parameters, add the configuration parameter: custom.script.execution.path.
      MONITORS screen displays the new monitor.
Remote Script Executor Monitor

Macros in Remote Script Executor

Macros are implemented to address the passing of dynamic arguments to scripts. Use the following macros to make available native attributes and custom attribute defined on the resource, in the script:

Static macros

Using the Static Macros, OpsRamp overrides the values that you provide in the script.

Description of static macros
MacroDescription
${resource.ipaddress}The IP address of the device
${resource.mac}Mac address of the device
${resource.serialno}Serial Number of the device
${resource.make}Make of the device
${resource.model}Model of the device.
${resource.hostname}The hostname of the device
${resource.uniqueid}UniqueId of the device
${resource.os}Operating System of the device

Dynamic macros

Using Dynamic Macros, you can do the following actions:

  • Get custom attributes of the device – If you want to use an argument in any script, you can apply the custom attributes to the device.
    Syntax: ${customattributes.customAttributekey}. For example, you have a custom Attribute on the device with Key: serviceName and Value: oracledb. During runtime, the Value: oracledb replaces the macro: ${customattributes.serviceName} in the script.
  • Get the credentials added to the device – You can use (macros) credentials in the script to avoid keeping the original username and password in plain text. The macros replace the original credentials when you execute the script. Syntax: ${credentials.CredentialName.credentialField}. For example, you define a Credential set of Name JMXCred and added to a device. You can use the macro ${credentials.JMXCred.username} in your script. The macro replaces the original credentials in your script at runtime.

Script execution path for configuration parameters in Linux and Windows

GatewayTarget Platform
Script TypeLinux/SSHWindows
Linux GatewayBashbash -sNot Applicable
PowershellNot ApplicableNot Applicable
Pythonpython -Not Applicable
PerlPerl - -Not Applicable
Windows GatewayBashbash -s
PowershellNot Applicablepowershell.exe
Pythonpython -python.exe
PerlPerl - -perl.exe

If your runtime is not set as an environment variable, mention the absolute path of your runtime. For example, if Python is not set as an environment variable, enter the absolute path of Python such as /usr/lib/python.

Create template

A template is an instance of a monitor and is applied to devices.

  1. From All Clients, select a client.

  2. Go to Setup > Monitoring >Templates.

  3. Click + Add.

  4. From MONITOR TEMPLATE, enter the details for the following parameters and click Save:

    • Select Template Scope: Template type.

    • Collector Type: Select Gateway.

    • Monitor Type: Select Monitors for G2 Templates.

    • Applicable for: Select Device.

    • Template Name: Name of the template.

    • Description: Summary of the template.

    • Generation: Generation that the template belongs to.

    • Tags: User-defined tags for better filtering.

    • Prerequisites: Essential things that you must consider while monitoring using the template. For example, check the SQL services while monitoring the SQL Parameters using the Windows templates.

    • Status: Active or End-of-life templates.

    • Notes: Information that you want to add to the template.

    • Template Family Name: Category that applies to the application. For example, Windows Server, Storage Server, and Network Server.

    • Deployment Type: One of the following methods to apply the template to the resources:

      • Custom
      • Optional
      • Standard
  5. After providing the template details, MONITOR TEMPLATE displays the Monitors section.
    The user interface for the Monitors section varies with the option selected in the Collector Type.

    • Monitor: To add details in Monitors:
    1. From the Monitors section, click Add.

    2. Enter details for the following parameters:

      • Frequency: Refer to the frequency to execute the template.
      • Monitor Definition: Monitor type.
      • When to Alert: Select Breach of a Threshold.
    3. Select Availability and Alert checkbox to initiate monitoring. The TEMPLATES section displays the configured details.

Assign template to a device

You need to create credentials to assign a template to a device.

Create credentials

If the configuration parameter remote.server.operating system is:

  • Windows, you must consider Windows type credentials.
  • LINUX or UNIX, you must consider SSH type credentials.
  1. Select a client from the All Clients list.

  2. Go to Infrastructure > Resources.

  3. From the list of devices, select a device. Navigates to the device information page.

  4. From the center pane, click Credentials.

  5. Click +Add.

  6. From Create new credential, provide details for the following parameters and click Save:

    • Name: Name of the credential.
    • Description: Description of the new credential.
    • Type: Application type. Select Windows.
    • Username: Username for the credential set.
    • Password: Password that you set for the credential set.
    • Confirm Password: Enter the same password.
    • Port: Port used to connect to the application.
    • Connection Time Out (ms): Time taken for the resource to connect to the application. The Credentials screen displays the new credentials.

Assign template

  1. From the left pane, click Infrastructure. The Infrastructure screen of the selected client is displayed.
  2. From the Resources tab, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
  3. Click the resource name to view details.
  4. From the left pane, click Monitors. Templates tab is displayed.
  5. From Templates tab, click +Assign Templates.
  6. From Apply Templates, select the templates. The selected Templates section displays the chosen templates.
  7. Click Assign. The template gets assigned to the selected device.

After assigning the template to a resource for monitoring, click Get Latest Metric Values to view the latest metric information.

Use the following global templates to monitor your Linux resources:

  • Gateway - Linux OS Performance Remote Monitoring
  • Gateway - Linux OS Performance Remote Monitoring - V2
  • Gateway - Linux Network Remote Monitoring

View graphs

OpsRamp Gateway monitors the remote system using the assigned templates and displays the results in a graphical format.

  1. From the left pane, click Infrastructure. The Infrastructure screen of the selected client is displayed.
  2. From the Resources tab, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
  3. Click the resource name to view details.
  4. From the left pane, click Metrics. The Metrics page displays graphs generated by all monitoring templates assigned to a device.
  5. Search with the template name to filter the graphs.
Graphical Representation

Troubleshooting

  • The device is accessible to the Gateway.
  • The appropriate port is available from the remote server.
  • Must not support the monitoring of Windows Workstations through Linux Gateway.

Example: Remote script executor script

#!/bin/bash

CPU=$(top -bn1 | grep load | awk ‘{printf “%.2f\t\t\n”, $(NF-2)}’)
MEMORY=$(free -m | awk ‘NR==2{printf “%.2f\t\t”, $3*100/$2 }’)
DISK=`df -h | awk ‘$NF==”/”{ print $5}’ | sed ‘s/%//g’`

printf “{\”disk.utilization\” : %s , \”memory.utilization\” : %s , \”cpu.usage\” : %s}” “$DISK” “$MEMORY” “$CPU”

Output :

{“disk.utilization” : 23 , “memory.utilization” : 24.28 , “cpu.usage” : 0.64 }

Standard JSON Output formats: Remote script executor script

Format 1
{
“Metric1”: 98,
“Metric2”: 70,
“Metric3”: 80
}
Format 2
{
“Metric1”: 98,
“Metric2”: “STATE”,
“Metric3”: 80
}
}
Format 3
{
    "MetricName1": {
        "components": {
            "component1": 70,
            "component2": 98
        }
    },
    "MetricName2": {
        "components": {
            "component1": 77,
            "component2": 98
        }
    }
}
Format 4
alertTokens: Using alertTokens, you can add more information to the alert Subject and Description.

{
    "MetricName1": {
        "components": {
            "component1": "STATE",
            "component2": 98
        },
        "alertTokens": {
            "token1": "value",
            "token2": "value2"
        }
    },
    "MetricName2": {
        "components": {
            "component1": 77,
            "component2": 98
        },
        "alertTokens": {
            "token1": "value",
            "token2": "value2"
        }
    }
}
Format 5

{
    "MetricName1": 254,
    "MetricName2": {
        "components": {
            "comp1": 90,
            "comp2": 60
        }
    },
    "MetricName3": {
        "components": {
            "component1": "STATE",
            "component2": 98
        },
        "alertTokens": {
            "token1": "value",
            "token2": "value2"
        }
    }
}