VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

Export Alarm Definition Info

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

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos