Command Line Analysis

Home  Previous  Next

Objective

The aim of this tool is to execute a command line and parse the output of this command, and in addition, verify the status of the execution by searching for a string, to run an infinite background command or to stop a command execution if the timeout elapses.

Although Monitoring Studio offers a variety of tools with extensive capabilities, you may have an in-house script or command that you need to run and analyze at regular intervals in order to monitor your application.

You can configure Monitoring Studio to execute any command line and parse the output of this command. In addition, the command line execution feature allows you to:

Stop the command execution once a given timeout is reached
Verify the status of the execution by searching for a string
Run a background command that never ends

Thus, the command line execution feature gives you the options you need to properly execute, analyze and monitor the script or command line.

ImportantThe program or script being executed should not need any user interaction and should not create any window. Monitoring Studio will analyze its output, i.e. what has been written to the stdout and stderr streams.
NoteThe command line analysis features provides a "do-it-yourself" kind of tool allowing you to execute any shell script or VBScript and search for Strings and Numeric values in the returned output.

 

Create or edit a command line analysis

To create a new Command Line analysis, right-click the application/container icon in the PATROL Console and select KM Commands > New > Command Line analysis...

WIZ_CommandLine_1Welcome

New Command Line Execution Wizard — Welcome Page

To edit an existing Command Line analysis, right-click the Command Line icon in the PATROL Console and select KM Commands > Edit.

Classic command execution

Step 1: Entering the command line to execute

WIZ_CommandLine_2CommandLine

New Application/Container Icon Wizard — Command Line Page

Command line to execute: Enter the OS command line or the path to the script that Monitoring Studio will execute.

Execute this command line as Username/Password: Enter a username and password if the command line needs to be run with a user account different from the default PATROL Agent account.

NoteYou can use the %{TIME:…} and %{LASTTIME:…} macros in the command line that will be executed. They will be replaced respectively by the current time and by the last execution time. See Format symbols for more details on the macros.

 

Examples

The following command line runs the diagnose.sh shell script and parses its output:

/opt/myApp/bin/diag/diagnose.sh
The following command executes a VBS script:
CSCRIPT.EXE //NoLogo C:\MyApplication\bin\diag\diagnose.vbs

The following command dumps the errpt log on IBM AIX and does only take into account the new lines that have been logged since the last polling:

errpt –a –s %{LASTTIME:%m%d%H%M%S}

Step 2: Execution period, and execution timeout

As the option This command needs to be launched only once and runs continuously is not selected in step 1, the following dialog box is displayed.

WIZ_CommandLine_3Period

New Application/Container Icon Wizard — Command Execution Period Page

Stop the command if it takes longer than … seconds: The time after which the command will be stopped.

NoteIf the timeout is reached, the value of the ExecutionStatus parameter will be set to 1, indicating that the command failed to execute properly. No further analysis will be performed (String and Numeric Value searches).

Command to execute if the timeout above is reached: A command similar to a recovery/cleaning action that will be executed when the timeout is reached.

NoteThe {%PID} macro can be used to indicate the PID of command line process being interrupted.

Step 3: Command execution validation (optional)

This option is useful to avoid basic execution errors like File not found because the command line was mistyped. The following panel will pop up:

WIZ_CommandLine_4ExecutionValidation

New Application/Container Icon Wizard — Command Execution Validation Page

Command Exit Status: States if the command line has been properly executed:

Select an execution option (succeeded/failed). This option qualifies the exit code returned at the end of the command line execution.
Enter one or several exit codes separated by commas. When one of the exit codes is found or not depending on the execution option selected, Monitoring Studio triggers an alarm on the ExitStatus parameter to indicate that the execution failed.

Command execution validation: The regular expression entered here will be searched in the output of the command. If it is not found, the value of the ExecutionStatus parameter will be set to 1, indicating that the command failed to execute properly.

Step 4: Monitoring Studio settings

WIZ_CommandLine_5Settings

New Application/Container Icon Wizard — Settings Page

Object display name: Label that will be displayed in the PATROL Console for this command line monitoring object.

Object internal identifier (ID): PATROL internal identifier of this monitored object.

What thresholds do you want to set for the newly created instance? A drop-down list allows you to select the mode of setting alert thresholds:

Use default thresholds: Uses the default thresholds set by Monitoring Studio
Set custom thresholds: Allows you to customize the thresholds for all parameters of the instance
Use default thresholds and customize them: Sets the default Monitoring Studio thresholds on certain parameters (see list of parameters with default thresholds) and then allows you to customize any/all of them. This is mainly intended to help save time if you wish to customize the thresholds of just one of many parameters for the instance, and leave the default settings for the others.
NoteIf you select Use default thresholds and customize them; on clicking Finish, the Set Thresholds panel will appear, certain parameters for the instance may appear with an asterisk symbol - indicating that they already have thresholds. You can then customize (any/all) the thresholds of the parameters as per your specific needs.
Do not set any thresholds for now: No thresholds will be set on any parameter of the instance, and as a result no alerts will be triggered. Monitoring Studio will poll the object and return the output of the polling – but will not raise any alerts until you set thresholds.

Tip Thresholds can be set or modified at anytime by right-clicking on the instance > KM commands > Set Thresholds.

Never-ending Command Execution

Step 1: Entering the command line to execute

WIZ_CommandLine_6NeverEndingCmd1

Never-ending Command Execution — Command Line

Command line to execute: Enter the OS command line or the path to the script that Monitoring Studio will execute.

Execute this command line as Username/Password: Enter a username and password if the command line needs to be run with a user account different from the default PATROL Agent account.

This command needs to be launched only once and runs continuously: A so-called "never-ending" command is a program or script that runs continuously. It is not actually polled but instead executed just once and the returned value of the command is displayed in the ReturnOutput parameter as it runs. In addition, String and Numeric value searches are performed as new output is received.

NoteYou can use the %{TIME:…} and %{LASTTIME:…} macros in the command line that will be executed to display the current time and the last execution time. See Format symbols for more information on how to format the %{TIME:…} and %{LASTTIME:…} macros.

 

Example

The following command line runs the diagnose.sh shell script and parses its output:

/opt/myApp/bin/diag/diagnose.sh
The following command executes a VBS script:
CSCRIPT.EXE //NoLogo C:\MyApplication\bin\diag\diagnose.vbs

The following command dumps the errpt log on IBM AIX and does only take into account the new lines logged since the last polling:

errpt –a –s %{LASTTIME:%m%d%H%M%S}

Step 2: Confirm never-ending command and additional command to execute to stop the never-ending command

If you select the option This command needs to be launched only once and runs continuously in step 1, the following pop-up asks you to confirm your choice:

WIZ_CommandLine_6NeverEndingCmd2

Never-ending Command Execution — Confirmation Message

Once the "never-ending" option is confirmed, the following dialog box confirming that the command line will be executed just once and will run continuously is shown:

WIZ_CommandLine_6NeverEndingCmd3

Never-ending Command Execution — Command Execution

Additional command to execute in such a case: Enter a specific command to execute in order to stop the execution of the previous launched never-ending Command. This command runs when the command analysis is deleted from the PATROL configuration. It is required to properly end the execution of the command.

Abort any previous execution of this command upon a PATROL Agent restart: Select this option if you wish the system to automatically stop the execution of the previous launched never-ending Command upon the next PATROL Agent restart.

Click Next.

Step 3: Monitoring Studio settings

WIZ_CommandLine_5Settings

Never-ending Command Execution — Settings

Object display name: Label displayed in the PATROL Console

Object internal identifier (ID): PATROL internal identifier

What thresholds do you want to set for the newly created instance? A drop-down list allows you to select the mode of setting alert thresholds:

Use default thresholds: Uses the default thresholds set by Monitoring Studio
Set custom thresholds: Allows you to customize the thresholds for all parameters of the instance
Use default thresholds and customize them: Sets the default Monitoring Studio thresholds on certain parameters (see list of parameters with default thresholds) and then allows you to customize any/all of them. This is mainly intended to help save time if you wish to customize the thresholds of just one of many parameters for the instance, and leave the default settings for the others.
NoteIf you select Use default thresholds and customize them; on clicking Finish, the Set Thresholds panel will appear, certain parameters for the instance may appear with an asterisk symbol - indicating that they already have thresholds. You can then customize (any/all) the thresholds of the parameters as per your specific needs.
Do not set any thresholds for now: No thresholds will be set on any parameter of the instance, and as a result no alerts will be triggered. Monitoring Studio will poll the object and return the output of the polling – but will not raise any alerts until you set thresholds.
TipThresholds can be set or modified at anytime by right-clicking on the instance > KM commands > Set Thresholds.

Command line analysis objects are instances of the SW_OSCOMMANDS class.


See Also

Numeric Value Extraction

String Search

SW_OSCOMMANDS