kphipps
Contributor
Contributor

Disable Alarm Definition per VM

Running vCenter 7.01 and I'm trying to disable the alarm "Virtual machine memory usage' for a few VMs that run 100% all the time (appliances).  When I click on the VM and go to Configure, Alarm Definitions I'm able to disable one at a time.  (Cool new feature in 7!!!) but I can't figure out how to script it for a few VMs.  Can anyone help?  May not be possible yet.

Here is an example of my script

get-vm <name*> | Get-AlarmDefinition -Name 'Virtual machine memory usage' | Set-AlarmDefinition -Enabled:$false

If I run this it disables the alarm at the vCenter level for all the VMs.

Suggestions?

Thanks!

0 Kudos
2 Replies
LucD
Leadership
Leadership

Unfortunately that feature is not yet covered by a PowerCLI cmdlet.

But you can always use the API DisableAlarm method directly.

$vmName = 'MyVM'
$alarmName = 'Virtual machine memory usage'

$vm = Get-VM -Name $vmName
$alarm = Get-AlarmDefinition -Name $alarmName

$alarmMgr = Get-View AlarmManager

$alarmMgr.DisableAlarm($alarm.ExtensionData.MoRef,$vm.ExtensionData.MoRef)

To enable an alarm on a specific VM, you just call the EnableAlarm method.

$alarmMgr.EnableAlarm($alarm.ExtensionData.MoRef,$vm.ExtensionData.MoRef)

 


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

kphipps
Contributor
Contributor

Thanks Luc!!  I really need to dig deeper in API calls so I can get better at it.

Thanks again!

0 Kudos