Overview
Health test scripts are used by JetPatch Agent Manager to periodically monitor the health of managed agents on endpoints.
Each script runs on the endpoint, checks a specific condition (such as whether a service is running), and returns a status code and message to JetPatch Agent Manager.
Use the information in this article to create your own health test scripts.
A sample PowerShell script is included in the Attachments section.
Supported Languages
| OS | Supported Languages |
| Linux | Any script language. The script should identify the language using a standard Shebang line. |
| Windows | PowerShell (.ps1), Batch (.bat), or Visual Basic (.vbs). |
Script Outputs
The script should pass the following outputs:
Status - Exit Codes
| Exit Code | Meaning |
| 0 | OK. |
| 1 | The monitoring script has detected a problem, to be logged. |
| 2 | The monitoring script failed to complete. |
Detailed Message
A detailed message printed to standard output.
Variables Passed to the Script
JetPatch Agent Manager passes the following variables to the script:
| Variable | Description |
| TEMPDIR | A temporary directory for writing; will be automatically emptied after the script is completed. |
| Agent-Specific Parameters | All fields that appear in the Managed Agent Settings tab of the management package. For a list of the actual parameter names, please contact JetPatch support. |
Attachments
Check_if_service_is_running.txt
A sample PowerShell script for checking if a service is running:
|
# Check if service name is running $ServicesToRun = Get-WmiObject Win32_Service -ComputerName . | Where-Object {($_.name -like "*service name*") -and ($_.state -like "*running*")} | Select-Object Name $ExitCode = 0 $ServicesAfterRun = New-Object System.Collections.ArrayList $NumOfServices = $ServicesToRun.count if ( $NumOfServices -eq 1 ) { Write-Output "Service is running:" foreach ($service in $ServicesToRun) { Write-Output $service.Name } Exit 0 } else { $ExitCode = 1 Write-Output "Service is not running:" foreach ($service in $ServicesToRun) { Write-Output $service.Name } } exit $ExitCode |
Comments
0 comments
Please sign in to leave a comment.