This topic provides information about configuring OS command line execution (local scripts) in the Central Monitoring Administration and TrueSight console. To configure the scripts, set the following preferences on the Add Monitoring Configuration dialog.
| | | |
|---|
| | | OS command line execution |
Click
button to configure the Scripts.
| |
|---|
| Enter a display name for the script. A container will be created with the script display name. This container will hold the attributes for this script instance. Input must match ^[0-9a-zA-Z._%:-]+$ regular expression pattern. For example, the display name can be cron-monitor.sh, ping3rdParty.sh, and so on. |
| The KM supports multiple types of values for this field:
Absolute path to a script file: Enter the absolute path to the location and the file name where the script should be placed on the target monitored device. For example: /tmp/myScript.sh path means that myScript.sh will be uploaded from the PATROL Agent’s host to the folder /tmp on the targeted device. It will be executed from there. The file will be uploaded each time when the script's source on the PATROL Agent host changes.
In some scenarios there is a need to run a script with other files (for example, data) that are bundled with the script. In such cases, the KM uploads these files along with the script file. To use this feature, the policy must be defined for a single file (for example, tmp/myScriptDir/mScript.sh). Also, all the additional files and the script file must be present in the .tar or .zip file on the PATROL Agent file system. The archive must have the same name as the base script for the KM to upload the content of the .zip or .tar file to the target host. For example, if the policy is defined with /tmp/myScriptDir/myScript.sh value, the zip file name must be myScript.zip, on the PATROL Agent file system.%PATROL_HOME%/TRO/Conf/Scripts/ScriptFileTransfer/Devices/DeviceName/ Or %PATROL_HOME%/TRO/Conf/Scripts/ScriptFileTransfer/ Or %PATROL_HOME%/TRO/Conf/Scripts/Samples/) If the script does not exist on the PATROL Agent filesystem in the accepted formats (simple file, .tar, or .zip), the Script Status parameter generates an alert with an annotation containing the problem details. Note: If the Script (for example, /tmp/bmc/myScript.sh) does not exist on the remote device but is present on the monitoring system the KM copies the script to the remote device. The KM creates the specified directory structure (/tmp/bmc/) on the remote device and then copies the script.
One OS command line (also known as one-liner): The script used by the monitor, can be a simple or complex command. Multiple tools can be used to write the command. Standard shell syntax rules apply. For example: The following line can be used to monitor the file system utilization in percent on the targeted device. df -lkh | grep -v Mounted | tr -s ' ' | for line in $(cut -d ' ' -f 6,5|sed -e 's/ /,/g' -e 's/%// g' -e 's/\//_/g' );do printf "FileSystem=%s,UsagePct=%d\n" `echo $line | cut -f 2 -d ','` `echo $line | cut -f 1 -d ','`;done After defining and executing the script, the KM creates an instance of the LINUX-UNIX shell script monitor type according to the policy field. The Script Status attribute monitors the agent’s ability to monitor by using the provided policy details.
|
| Enter the arguments that will be passed during the script execution. The arguments must be separated by a space character. Example: A script file that measures the log file size must have the argument of the log file name. |
| Beyond monitoring for numeric values the KM is capable of monitoring a specific text pattern returned by the script during execution. This is useful, when you need to enable a certain value where the actual numeric value is the same. The KM scans for a value defined in this field. It returns an annotation text along with the value and the that text defined in this field. A single or a semicolon separated list of regular expressions is supported. The syntax of regular expression has to be considered valid for usage with Oracle Java (java.util.regex). |
|
|---|
| (Optional) Enter the user name. Enter credentials only when you want to execute a script that requires special permissions. Note: If this filed is left blank the PATROL Agent user account is used. Example: If the PATROL Agent user does not have the permission to run a script located in the root directory, you need to provide these credentials to ensure smooth execution of the script. |
| (Optional) Enter the password corresponding to the user name. |
| (Optional) Re-enter the password for confirmation. |