With PowerCLI, you can create vCenter Server alarm actions and triggers.

Prerequisites

Verify that you are connected to a vCenter Server system.

Procedure

  1. Create an alarm action email for the renamed alarm definition.
    Get-AlarmDefinition -Name AlarmDefinitionNew | New-AlarmAction -Email -To '[email protected]' -CC @('[email protected]', '[email protected]') -Body 'Email text' -Subject 'Email subject'
  2. Create an snmp alarm action.
    Get-AlarmDefinition -Name AlarmDefinitionNew | New-AlarmAction -Snmp
  3. Create a script alarm action.
    Get-AlarmDefinition -Name AlarmDefinitionNew | New-AlarmAction -Script -ScriptPath 'c:\test.ps1'
  4. Create a metric-based alarm trigger.
    $metric = Get-Metric -MetricGroup CPU -Name Usage | Where-Object {$_.Key -eq 2}
    $metricTrigger = New-AlarmTrigger -Metric $metric -Red 9000 -RedIntervalSeconds 3000 -EntityType  "VirtualMachine" -MetricAlarmOperator Above
    
  5. Create a state-based alarm trigger.
    $stateTrigger = New-AlarmTrigger -StatePath "runtime.powerState" -Value "poweredOff" -EntityStatus Red -EntityType "VirtualMachine" -StateAlarmOperator Equal