Automation

 View Only
  • 1.  Export Alarm Definition Info

    Posted Nov 20, 2023 09:52 AM

    Hi,

    how can I get Targets, Alarm Rules information from Alarm Definition.

    Please help!!

    ganapa2000_0-1700473914084.png

     

    Get-AlarmDefinition -PipelineVariable alarm |
    ForEach-Object -Process {
    Get-AlarmAction -AlarmDefinition $_ -PipelineVariable action |
    ForEach-Object -Process {
    Get-AlarmActionTrigger -AlarmAction $action |
    select @{N='Alarm';E={$alarm.Name}},
    @{N='Description';E={$alarm.Description}},
    @{N='Enabled';E={$alarm.Enabled}},
    @{N='Last Modified';E={$alarm.ExtensionData.Info.LastModifiedTime}},
    @{N='Last Modified By';E={$alarm.ExtensionData.Info.LastModifiedUser}},
    @{N='Entity';E={$alarm.Entity}},
    @{N='Expression';E={
    ($alarm.ExtensionData.Info.Expression.Expression |
    ForEach-Object -Process {"{0} ({1}) - {2} - {3}" -f $_.EventType,
    $_.EventTypeId,
    $_.ObjectType,
    ([VMware.Vim.ManagedEntityStatus]$_.Status.value__)}) -join '|'
    }},
    @{N='Trigger';E={
    "{0}:{1}->{2} (Repeat={3})" -f $action.ActionType,
    $_.StartStatus,
    $_.EndStatus,
    $_.Repeat
    }}
    }
    } | Sort-Object -Property Alarm -Unique | Export-Csv -Path .\POC_2_Alarms_Export_$($mydate).csv -NoTypeInformation -UseCulture



  • 2.  RE: Export Alarm Definition Info

    Posted Nov 20, 2023 12:10 PM

    That script assumes that the Alarm trigger is an event, the screenshot you post is from an Alarm that is triggered by a metric.

    Having a script that shows all possible trigger types and the details will be rather complex.