VMware Cloud Community
cjm4820
Contributor
Contributor
Jump to solution

Automate Alarm definition - triggers

I would like to update an Alarm definition - Triggers - Trigger Type condition values using powercli. Is it possible with powercli?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ok, that one is a bit special since there is no Action defined.

But with the API it is possible like this

$alarmName = 'Datastore disk usage'

$yellowPercent = 85

$redPercent = 90

$alarmMgr = Get-View AlarmManager

$alarm = Get-View -id ($alarmMgr.GetAlarm($null)) | where {$_.Info.Name -eq $alarmName}

$spec = $alarm.Info

$spec.Expression.Expression[0].Yellow = $yellowPercent * 100

$spec.Expression.Expression[0].Red = $redPercent * 100

$alarm.ReconfigureAlarm($spec)


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Have a look at the Remove-AlarmAction, Remove-AlarmActionTrigger, New-AlarmAction and New-AlarmActionTrigger cmdlets.

Anything particular you want to do ?


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

Reply
0 Kudos
cjm4820
Contributor
Contributor
Jump to solution

Thanks. I am trying to change Alarm Trigger Type condition through Powercli.

For example, I need to update the condition for "Datastore Disk Usage%" Trigger type in Alarm Definition "Datastore usage on disk".

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, that one is a bit special since there is no Action defined.

But with the API it is possible like this

$alarmName = 'Datastore disk usage'

$yellowPercent = 85

$redPercent = 90

$alarmMgr = Get-View AlarmManager

$alarm = Get-View -id ($alarmMgr.GetAlarm($null)) | where {$_.Info.Name -eq $alarmName}

$spec = $alarm.Info

$spec.Expression.Expression[0].Yellow = $yellowPercent * 100

$spec.Expression.Expression[0].Red = $redPercent * 100

$alarm.ReconfigureAlarm($spec)


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

Reply
0 Kudos