Custom Script
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’sexecplugin to run scripts on a target machine's operating system. In Linux operating systems, a special user calledarcuserwith specific privileges, is created for installing the Telegraf agent. As a result, theexecplugin runs the scripts using thatarcuseruser. Ensure that thearcusercan run the scripts that use the custom script (thearcusermust have permissions to run the script). For example, thearcusercreated automatically by cloud proxy, does not have privileges to run scripts which are stored under the/rootdirectory.
- In Windows operating systems, a system user is used for installing the Telegraf agent. As a result, theexecplugin 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/vmwarefolder.
- The environment variable PATH must be set for PowerShell scripts to be executed on the Windows operating system if the user used thepowershell -Fileprefix. For example,"%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\"in the environment variable PATH variable.
How to Run Custom Scripts
- From theManage Telegraf Agentstab, filter by .
- Expand the drop-down arrow against the target machine on which the agent is installed. You see theCustom Monitoringsection.
- Against theCustom Scriptoption, click the vertical ellipsis and then clickAdd.
- From theManage Custom Scriptdialog 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: For Windows machines:
|
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. - The custom script must throw all errors in the formatERROR|<Error_message>for the error propagation to work. If the script does not throw an error in the given format,VMware Aria Operationsdisplays an error messageUnable to parse the error message. Please check the endpointin the user interface. This is by design, until cloud proxy propagates the exact error message.
- The bash script must start withshebang (#!/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.