Defining the script output (Windows)


Using the PATROL for Scripting KM for monitoring your environment is a two-stage process:

  • Define execution plan for your monitoring environment- Select or write scripts, place the scripts at the respective locations, define the script output
  • Monitor the environment- Configure the scripts (locally or remotely)

You can define the script output, and the definitions are set on the PATROL Agent when the policy is applied. The script output should be returned to the standard output and must be defined in one of the following ways:

Single value 

The script output must return a number at the first line that will be presented in the static monitor type named Script within the Value parameter. All the lines starting with the second line will be attached to the parameter value as an annotation.

Example

A script that invokes HTTP GET request and prints the HTTP RC and the page content

Example

200 
The page content 1 
The page content N/2 
The page content N

Multiple instances

The script output should return multiple lines, where each line simulates an instance with its corresponding parameters. The new instances gets displayed as new monitor types (dynamic monitor types based on the script output) with the corresponding parameters which are returned as an output upon execution of the script.

Note

Before configuring multiple instances using a script, make sure that the script output does not create instances on TrueSight Operations Management console with ‘|’ character in their name. The TSOM instances are created based on the script output, instance name that contains a  ‘|’ character in the name need to be replaced with any other special character, such as the ‘_’ character.

Script output metadata feature

Map script output instances to devices

Property name: I2D

Property value: True or false
Example: <metadata>I2D=true</metadata>

Optional use case: Discovered instances based on the script output are real devices.

Description: To map the script output instances to devices in TSPS feature named device mapping, the first line at the device output should be: <metadata>I2D=true</metadata>. To disable device mapping either remove this line from the script output or set it as: <metadata>I2D=false</metadata>

Override the monitor type name

Property name: MonitorTypeName

Property value: The name of the monitor type that will get created.
Example: <metadata>MonitorTypeName=Process</metadata>

Optional use case: Monitor type name must be a unique name, assuming that you configured two scripts:
get-process and get-service, both of them will get instantiate using the Name monitor type, hence each one of the Cmdlet creates the same monitor type named Name but with a different content, this will consider it as an invalid operation. In order to have a separate monitor type for each script configured to run, add the user defined name at the first line of each script output (example: for get-process set it as <metadata>MonitorTypeName=Process</metadata> and for get-service set it is as <metadata>MonitorTypeName=Service</metadata>).

Description: To set a user defined monitor type name based on the script output, the first line at the device output should be: <metadata>MonitorTypeName=MyMonitorTypeName</metadata>

You can set multiple metadata attributes separated by a comma. For example, to set the device mapping to true and the monitor type name to Process use it as: <metadata>I2D=true,MonitorTypeName=Process</metadata>

  • One-liner command supports formatted output by adding format-list.

For example: Get-process | Format-List  Name,Id,PM,VM 

  • When running cmdlets, the default monitor type is Name. To override the default monitor type add the metadata to the first line in script output.

For example: <metadata>MonitorTypeName=ProcessName</metadata>

  • You can add echo “metadata>MonitorTypeName=ProcessName</metadata>”;get-process. The monitor type should be a unique name across all configured scripts.
  • You can merge arguments to create an unique instance name

For example: Get-process | Format-List Name+Id,PM,VM

PowerShell cmdlet output

Windows output.png

Defining each line in the script output

With the output metadata

MonitorTypeName=instanceName1,parameter1=value,parameter2=value,parameterN=value

MonitorTypeName=instanceName2,parameter1=value,parameter2=value,parameterN=value

MonitorTypeName=instanceNameN,parameter1=value,parameter2=value,parameterN=value

where,

MonitorTypeName is the static name of the monitor type that is created to group all of the instances

instanceName is the instance name. This is a dynamic name. Each instance will be created in the MonitorTypeName container. This instance will hold all the user defined parameters.

parameter is the name of the parameter that will provide the value for each instance

Structure

+ MonitorTypeName

    + instanceName1

        parameter1

        parameter2

        parameterN

   + instanceName2

        parameter1

        parameter2

        parameterN

   + instanceNameN

        parameter1

        parameter2

        parameterN

Without parameter names

MonitorTypeName=instanceName1,value,value,value

MonitorTypeName=instanceName2,value,value,value

MonitorTypeName=instanceNameN,value,value,value

where,

MonitorTypeName is the static name of the monitor type that is created to group all of the instances 

instanceName is the instance name. This is a dynamic name. Each instance will be created in the MonitorTypeName container. This instance will hold all the user defined parameters.

parameter is none. The name of the parameters will be Value1,Value2,ValueN 

Structure

+ MonitorTypeName

   + instanceName1

       Value1

       Value2

       ValueN

   + instanceName2

       Value1

       Value2

       ValueN

   + instanceNameN

       Value1

       Value2

       ValueN 

Example1

A script that returns the interfaces of the device. For each interface the script returns three parameters, InErr, OutErr, and Speed.

Example

Interfaces=Ethernet1,InErr=3,OutErr=5,Speed=7 

Interfaces=Ethernet2,InErr=3,OutErr=5,Speed=7 

Interfaces=Ethernet3,InErr=3,OutErr=5,Speed=7 

Interfaces=Ethernet4,InErr=3,OutErr=5,Speed=7 

Structure

+ Interfaces 

+ Ethernet1 

InErr 

OutErr 

Speed 

+ Ethernet2 

InErr 

OutErr 

Speed 

+ Ethernet3 

InErr 

OutErr 

Speed 

+ Ethernet4 

InErr 

OutErr 

Speed 

Example 2

A script that returns the interfaces of the device. For each interface the script returns three parameters values, without the parameters names.

Interfaces=Ethernet1,3,5,7 

Interfaces=Ethernet2,3,5,7 

Interfaces=Ethernet3,3,5,7 

Interfaces=Ethernet4,3,5,7 

Structure 

+ Interfaces 

+ Ethernet1 

Value1 

Value2

Value3

+ Ethernet2

Value1

Value2

Value3

+ Ethernet3

Value1

Value2

Value3

+ Ethernet4

Value1

Value2

Value3

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*