I have read LucD's excellent blogpost (Alarm expressions - Part 2 : Event alarms - LucD notes ) on how to create alarms and peetz addition to that (https://www.v-front.de/2013/06/creating-vcenter-alarms-with-powercli.html) while I was doing research for a project of mine.
The idea is to separate customer alarms with different folders in vCenter for both hosts and datastores, and create a set of alarms that are the same for each customer but with different recepients. However, I noticed that there was an option I couldn't really find out on my own, and that was advanced conditions for triggers, see this image below:
So, for creating "regular" alarms these settings seems to do it:
# Create AlarmSpec object $alarm = New-Object VMware.Vim.AlarmSpec $alarm.Name = "$targetcustomer" $alarm.Description = "Host storage status" $alarm.Enabled = $TRUE # Event expression 1 - Host storage status # will change state to "Red" $expression1 = New-Object VMware.Vim.EventAlarmExpression $expression1.EventType = "EventEx" $expression1.eventTypeId = "Hardware health changed" $expression1.objectType = "HostSystem" $expression1.status = "red" # Attribute comparison for expression 1 $comparison1 = New-Object VMware.Vim.EventAlarmExpressionComparison $comparison1.AttributeName = "Host Connection State" $comparison1.Operator = "isEqualTo" $comparison1.red = "Disconnected" #$comparison1.RedInterval = 300 $comparison1.yellow = "None" #$comparison1.yellowinterval = 300 $comparison1.Value = "1" $expression1.Comparisons += $comparison1 # Add event expressions to alarm $alarm.expression = New-Object VMware.Vim.OrAlarmExpression $alarm.expression.expression += $expression1 $alarm.expression.expression += $expression2 #$alarm.expression.expression += $expression3 # Create alarm in vCenter root $alarmMgr.CreateAlarm("Folder-group-d1",$alarm)
But I have a hard time figuring out how to add these extra trigger conditions.. Any help would be appreciated, this is kind of new ground for me