Script Monitor

<< Click to Display Table of Contents >>

Navigation:  ELM Console (MMC) > Monitoring and Management > Agents and Monitors Library > All Monitors >

Script Monitor

The script monitor allows you to execute scripts in the context of the ELM Agent on a scheduled interval.  Default scripting language includes cscript.exe, cmd.exe and powershell.exe.  Additional scripting languages may be used by providing a full path to the executable in the Script Type field.  Because of the nature of this monitor item, results of the script actions are not returned to the ELM console.  It is the responsibility of the scripts author to confirm the script was successful run or to include output to standard Windows event that can then be collected by the ELM Event Collector.

 

 

ScriptMonitor

 

 

Event ID:  

The following event id's and category are available for use within any custom scripts.  

5051 - Ex: Informational

5052 - Ex: Warning

5053 - Ex: Error

Category: 124 (Script Monitor)

 

Usage Examples:  

Connect to a RestAPI, perform an action and then generate an event with the results.

Centralize cloud based log files into syslog msgs and send them to ELM for processing.

 

Sample Script:

 

Powershell: Check a specified directory for the existence of a specific file or file type, output to Windows event.

 

$MyPath = "c:\Dumps\*.dmp"

$FileExists = Test-Path $MyPath

If ($FileExists -eq $True)

{

$file = Get-ChildItem -Path $MyPath -Recurse -Filter "*.dmp" | Sort-Object LastWriteTime -Descending | Select-Object -First 1

Write-Eventlog -Source "ELMAgent" -LogName Application -EventId 5051 -Category 124 -EntryType Informational -Message "Dump File $($file.Name) was found on server %Computer%. Script run by ELM Server Monitor item: %MonitorName%"

}

 

 

 

Note:  If the script monitor has been assigned to an Agent, you may need to adjust the ELM Agent service account username and password to have proper security to execute your script.  When running Powershell scripts, ELM uses an "Exit" command following each run to prevent multiple instances of Powershell starting each time the script is executed.  Best practice would be to include these types of exits in every type of script you choose to run.