Properly Setting the Exit Codes When Configuring the Command Line Monitor
KB1255 - Jul 10, 2019
Type: Best practice
Description: How to properly set the exit codes when configuring the Command Line Monitor with Monitoring Studio.
Additional Keywords: Monitoring Studio X, Command Line, Exit Code
When configuring a Command Line Monitor in Monitoring Studio, you can indicate if the command is successful or failed when a specific exit code is found. Before configuring the Command Line Monitor, it is therefore important to:
- Decide which command you would like to run
- List the possible exit codes for this command
- Select the exit codes that should be associated to a successful/failed command execution.
In our example, we will run a curl command for which we know that these exit codes may occur:
- CURLE_OK (0)
- CURLE_UNSUPPORTED_PROTOCOL (1)
- CURLE_FAILED_INIT (2)
- CURLE_URL_MALFORMAT (3)
- CURLE_NOT_BUILT_IN (4)
- CURLE_COULDNT_RESOLVE_PROXY (5)
- CURLE_COULDNT_RESOLVE_HOST (6)
- CURLE_COULDNT_CONNECT (7)
Imagine that we want to perform a health check of a specific URL and alert when it cannot be reached (the curl command then returns the exit code 7).
Before configuring the Command Line Monitor, we first:
- Define the Host to be monitored
- Create our Template
Apply our Template to our specific Host.For more information, refer to the Hosts and Templates documentation.
Then, we edit our Template to add a Command Line Monitor:
In the Command Line field, we enter the command to be run. In our example:
We then indicate the credentials to be used to run the command and whether it will be run on the Monitored Host or on the Agent system. In our example, it is on the Monitored Host.
In the Execution Validation section, we indicate the conditions to validate the command. In our example, the Failed Exit Code is 7.If we would have wanted Content-Parsing Monitors (String Search, Numeric Value Extraction, Value Map, etc) to be processed when the exit code is 7, we should then have selected Successful Exit Codes: instead Failed Exit Codes:.
Finally, we click Create.