You can run custom scripts in the target machine and collect custom data which can then be consumed as a metric.

Prerequisites

  • All the scripts that you run using the custom script, must output a single integer value. If the output is not a single integer value, an error is displayed in the user interface.
  • The custom script uses Telegraf’s exec plugin to run scripts on a target machine's operating system. In Linux operating systems, a special user called arcuser with specific privileges, is created for installing the Telegraf agent. As a result, the exec plugin runs the scripts using that arcuser user. Ensure that the arcuser can run the scripts that use the custom script (the arcuser must have permissions to run the script). For example, the arcuser created automatically by cloud proxy, does not have privileges to run scripts which are stored under the /root directory.
  • In Windows operating systems, a system user is used for installing the Telegraf agent. As a result, the exec plugin runs the scripts using that system user. Ensure that the system user has privileges and can run the custom script.
  • The script must be placed in the /opt/vmware folder.
  • The environment variable PATH must be set for PowerShell scripts to be executed on the Windows operating system if the user used the powershell -File prefix. For example, "%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\" in the environment variable PATH variable.

How to Run Custom Scripts

  • From the Manage Telegraf Agents tab, filter by Agent Status > Agent Running.
  • Expand the drop-down arrow against the target machine on which the agent is installed. You see the Custom Monitoring section.
  • Against the Custom Script option, click the vertical ellipsis and then click Add.
  • From the Manage Custom Script dialog box, you can add and configure the Windows services to be monitored.

Instance Settings

Option Description
Status Activate the custom script execution.
Display Name Add a suitable name for the script. The * is an invalid character and must not be used in the name.
Filepath Enter the path to the script file on the target machine.

Example:

For Linux machines:
 /opt/vmware/scripts/customscript.py
For Windows machines:
c:\scripts\customscript.ps1
Prefix Enter a prefix if necessary.

Example:

For Linux machines: python2.7, /bin/bash, or perl, etc

For Windows machines: powershell -File

Args List the arguments in the script.
Timeout Enter a script execution timeout on the VM.

After you save the script, it appears under Custom Script. You can edit or delete scripts by clicking the Edit or Delete options from the vertical ellipsis against the custom script you added. After the scripts have been added and saved, click the drop down arrow against Custom Script, to view the list of scripts and their status.

Note:
  • The custom script must throw all errors in the format ERROR|<Error_message> for the error propagation to work. If the script does not throw an error in the given format, VMware Aria Operations displays an error message Unable to parse the error message. Please check the endpoint in the user interface. This is by design, until cloud proxy propagates the exact error message.
  • The bash script must start with shebang (#!/bin/bash).

All Metrics Tab

When data is collected successfully, you can view the script as a metric for the target machine, in the All Metrics tab. The script metrics are created under an object called Custom Script which is a single object per target machine. All the metrics from the scripts for the target machine are placed under that Custom Script object that contains all the custom scripts you have created. You can view the output for the specific metric. The metric name under the Scripts folder is the display name that the user specifies while creating the script configuration. For example, if you set the display name as Python script, then a metric is created with the name Python script if data is collected successfully.