Automated Actions: How To Pass Trigger-Related Parameters
    • Dark
      Light
    • PDF

    Automated Actions: How To Pass Trigger-Related Parameters

    • Dark
      Light
    • PDF

    Article summary

    An advanced feature of triggers is the capability to pass trigger-related parameters to follow-up actions. For example, you can pass crossed threshold values, trigger names, or stress levels to emails or scripts. From version 9.0.5, you can configure trigger actions with PowerShell cmdlets.

    Prerequisites

    • Version 8.6.5 or higher

    How To Use

    To pass trigger-related information to a script action, you need to use the $CUTriggerObject variable. See below an overview of available properties, the trigger types for which you can use each property, and the parameter name you need to use for each use case.

    Note

    Not all properties are supported by every trigger type. To determine which properties are available for a specific trigger, refer to the Trigger Type column.

    PropertyDescriptionTrigger TypeParameter Name
    TriggerNameThe name of the trigger, as specified by the user in the Trigger Settings screenAll$CUTriggerObject.TriggerName
    ReportedByThe entity that reported the incidentAll$CUTriggerObject.ReportedBy
    TimestampThe time at which the incident occurred (in the triggering Monitor's timezone)All$CUTriggerObject.Timestamp
    UTCTimestampThe time at which the incident occurred (UTC)All$CUTriggerObject.UTCTimestamp
    TimezoneThe triggering Monitor's timezoneAll$CUTriggerObject.Timezone
    ColumnThe name of the columnAdvanced, Scheduled, Stress Level$CUTriggerObject.Columns[index].Column
    ColumnSeverityLevelSeverity LevelAdvanced, Scheduled, Stress Level$CUTriggerObject.Columns[index].ColumnSeverityLevel
    ColumnTimestampFor Advanced triggers, the time at which the column was changed; for Stress triggers, the time at which the stress on the column began. The time given is for the triggering Monitor's timezone.Advanced, Scheduled, Stress Level$CUTriggerObject.Columns[index].ColumnTimestamp
    ColumnUTCTimestampFor Advanced triggers, the time at which the column was changed; for Stress triggers, the time at which the stress on the column began. The time given is UTC.Advanced, Scheduled, Stress Level$CUTriggerObject.Columns[index].ColumnUTCTimestamp
    ColumnCrossedThresholdFor Advanced triggers, the threshold that was set for the column; for Stress triggers, the stress threshold that was set for the triggerAdvanced, Scheduled, Stress Level$CUTriggerObject.Columns[index].ColumnCrossedThreshold
    ColumnValueBeforeFor Advanced triggers, the column's value before it was changedAdvanced, Scheduled$CUTriggerObject.Columns[index].ColumnValueBefore
    ColumnValueAfterFor Advanced triggers, the column's value after it was changedAdvanced, Scheduled$CUTriggerObject.Columns[index].ColumnValueAfter
    EventSourceSource field of the eventAdvanced, Scheduled$CUTriggerObject.Event.EventSource
    EventTypeLevel field of the event in the EventLogWindows Event$CUTriggerObject.Event.EventType
    EventIDEvent IDWindows Event$CUTriggerObject.Event.EventID
    EventFullMsgEvent contentWindows Event$CUTriggerObject.Event.EventFullMsg
    ValueBeforeSession state before it changedAdvanced, Scheduled$CUTriggerObject.Session.ValueBefore
    ValueAfterSession state before it changedAdvanced, Scheduled$CUTriggerObject.Session.ValueAfter

    Simple Use Case

    The following use case creates a trigger that fires when the free space on disk is lower than 50 GB. This triggers an Automated Action (trigger that runs a script as a follow-up action) that passes information about the trigger to the script.

    1. Create a script with the following content shown below. What this script does is to write a CUTriggerObjectValue.txt in C:\tmp.
    $OutputFile = "C:\tmp\CUTriggerObjectValues.txt"
    Clear-Content $OutputFile
    
    Add-Content -Path $OutputFile -Value "The CUTriggerObject values:`n"
    Add-Content -Path $OutputFile -Value "TriggerName: $($CUTriggerObject.TriggerName)"
    Add-Content -Path $OutputFile -Value "ReportedBy: $($CUTriggerObject.ReportedBy)"
    Add-Content -Path $OutputFile -Value "Timestamp: $($CUTriggerObject.Timestamp)"
    Add-Content -Path $OutputFile -Value "UTCTimestamp: $($CUTriggerObject.UTCTimestamp)"
    Add-Content -Path $OutputFile -Value "Timezone: $($CUTriggerObject.Timezone)"
    
    if ($null -ne $CUTriggerObject.Columns) {
        for ($i = 0; $i -lt $CUTriggerObject.Columns.Count; $i++) {
            Add-Content -Path $OutputFile -Value "Columns.Column: $($CUTriggerObject.Columns[$i].Column)"
            Add-Content -Path $OutputFile -Value "Columns.ColumnSeverityLevel: $($CUTriggerObject.Columns[$i].ColumnSeverityLevel)"
            Add-Content -Path $OutputFile -Value "Columns.ColumnTimestamp: $($CUTriggerObject.Columns[$i].ColumnTimestamp)"
            Add-Content -Path $OutputFile -Value "Columns.ColumnUTCTimestamp: $($CUTriggerObject.Columns[$i].ColumnUTCTimestamp)"
            Add-Content -Path $OutputFile -Value "Columns.ColumnCrossedThreshold: $($CUTriggerObject.Columns[$i].ColumnCrossedThreshold)"
            Add-Content -Path $OutputFile -Value "Columns.ColumnValueBefore: $($CUTriggerObject.Columns[$i].ColumnValueBefore)"
            Add-Content -Path $OutputFile -Value "Columns.ColumnValueAfter: $($CUTriggerObject.Columns[$i].ColumnValueAfter)"
        }
    } else {
        Add-Content -Path $OutputFile -Value "No columns were passed.`n"
    }
    

    image.png

    1. Create an Advanced Trigger and create a To this state: condition and add the condition as shown in the screenshot below
      image.png

    2. In our case, the disk space on the system drive of the machine "MONITOR" falls below the trigger condition of "50 GB and below. This immediately triggers the script to run.
      image.png

    3. Upon examining the text file, we can confirm that the trigger successfully populated the values in it:
      image.png

    Refer to this example for how the object $CUTriggerObject can be used in triggers.


    Was this article helpful?