Script Monitoring in ManageEngine OpManager

Script monitoring involves the use of custom scripts that allow network admins to monitor and retrieve data suited to their needs. The tedious task of creating a script, editing it, and executing it in the terminal or command prompt has been simplified with OpManager bringing in its custom script monitoring feature that allows you to do all the above things under a single management console.

Creating Script Monitoring Templates

Script Monitoring templates help you create custom scripts to monitor custom parameters.

Follow the steps given below to add script templates

  1. Go to Settings → Monitoring → Script templates.
  2. Click Add New and provide a name and description for the template.
  3. Configure the Monitoring Interval.
  4. Specify the Unit for the monitored parameter.
  5. Enter the Command Line to run the script, as provided in command prompt.
  6. Enter the script body. 
  7. Configure Thresholds.
  8. Click on Save and provide the OTP based on your TFA settings.

Note:
OpManager has a default set of ready-to-use scripts that are available here. Import them and associate them to your devices to start using them.

Sample Input

To create a script template for cache memory, that is used to retrieve the cache memory of a Linux system with 15 mins monitoring interval and 10 seconds as timeout while being executed from the monitoring machine,

  1. Name: Enter the name of the script. In this case, it would be "Cache memory"
  2. Description: Enter the description of the said script.
  3. Interval: Enter the monitoring interval as 15
  4. Units: Enter the units as KB
  5. Data Type: Select "Integer" as data type. The supported data types in OpManager are: Integer, Decimal, and String.
  6. Command Line: Enter the command line to run the script. Note that ${FileName} must be followed by the script file extension. You may also pass arguments. Argument list may use variable ${DeviceName} which will be replaced with the monitored machine name in run time. Other supported variables are:
    • ${pollUsing} - IP address or DNS name based on poll using setting of the device.
    • ${UserName} - WMI/CLI username,
    • ${Password} - WMI/CLI password,
    • ${SNMPRead} - SNMP read community string
    • ${IPAddress} - IP address of the device.
    • ${DisplayName} - Display name of the device.
  7. Script body: Enter the script. Kindly refer the Output message format and Output data format mentioned here before entering the script body.
  8. Timeout: Enter the timeout value as 10 seconds.
  9. Execute from: Select the "Execute from" option.

    If the option is selected as

    1. Monitored Machine
      • Scripts are executed on remote devices.
      • These scripts are supported only for Linux devices and not windows devices.
      • CLI credentials are required for the functioning of this script.
    2. Local Servers
      • Scripts are executed directly from the OpManager-installed server.
      • These scripts are supported for both Windows and Linux devices.

Add script template

Output Message Format

When a script is down or becomes active again, an alarm is raised to notify the user. An alarm message will be displayed in the notification. This alarm message is customizable and you can specify your message in the Script Body field while adding a script template.

The format for an alarm message: Message:<Custom Message>

The Output of the said syntax will be "Message: This is a custom message"

The alarm message examples for the script languages that are most commonly used and their corresponding output messages are provided below.

Alarm message examples:
VB Script
WScript.Echo "Message: This is a custom message"
Powershell Script
Write-Host "Message: This is a custom message"
Shell Script
echo "Message: This is a custom message"

Script monitoring

When you do not specify the message description in the Script Body field, OpManager, by default, will display the script name along with its status as the alarm message (<scriptMonitorName>is up or <scriptMonitorName> is down).

Exit code

Exit code is the return value of a script.

  • If the exit code is 0, it means that the script is up.
  • If the exit code is not zero, it means that the script is down.

Hence, make sure that your exit code is 0 so that the script is up and running.

Output Data Format

Specifying the format of the data used is important because the output data of the scripts are used to generate graphs and as are defined as input values for threshold limits for monitors.

The data should be specified in the given format below.

Data:
Instance1    value1
Instance2    value2
    ...    ...
InstanceN    valueN

The lines printed after the keyword Data: will be considered as the output data of the script. Every single data line will have an instance-value pair. The instances and values will be separated by a space, with instances being to the left of the space, and values being to the right of the space.

To know more about output formats in OpManager's script monitoring, click here.

Test Script

The test script option allows you to run the script check the same for its output.

Test script

Associating Script Templates

When you associate a device with a script template, the device will be monitored for that particular script's functionality. Now you can create a template for your frequently used functionalities and associate them to devices of your choice instead of creating them from scratch every now and then.

  • Go to Settings -> Monitoring -> Script templates.
  • Click on the "Associate" icon on the top right corner of the page.
  • Under the "Select script template" drop-down box, select the templates you want to associate with the devices.
  • Under the "Available devices" section , select the devices you want to associate and add them to the "Selected devices" section by clicking on the right arrow symbol in the middle.
  • Click on the "Associate" option at the bottom right.
  • Now the selected templates will be associated to the selected devices.

Exporting Scripts

You can export scripts in the form of XML formats and then import them to be used on other OpManager servers.

  • Click on the Export icon corresponding to the script that you want to export.

Importing Scripts

You can import scripts from other OpManager servers and then associate them with your devices for easier monitoring.

  • Click on the Import button under the More actions option that is available on the Script Templates page.
  • Click on the Browse button to locate the script (.xml file).
  • Finally, click Import and provide OTP based on your TFA settings.

Thank you for your feedback!

Was this content helpful?

We are sorry. Help us improve this page.

How can we improve this page?
Do you need assistance with this topic?
By clicking "Submit", you agree to processing of personal data according to the Privacy Policy.