VMware Cloud Community
DyJohnnY
Enthusiast
Enthusiast

Disable all vsphere alarms - faster

Hi,.

I've got this script (works in powercli 4.1.1) that disables and enables all of my alarms.

Inoticed sometimes they get "stuck" and you can't do anything to make some of the go away.

$enabled_alarms = Get-AlarmDefinition -Enabled:$true
$enabled_alarms | Set-AlarmDefinition -Enabled:$false
$enabled_alarms | Set-AlarmDefinition -Enabled:$true

This is pretty straight forward but it takes 2 minutes to run this on a single vcenter.

Is there a faster way to do this?

Also would it be possible that I just reset just the triggered alarms not all of them?

Thanks,

ionut

IonutN
Reply
0 Kudos
5 Replies
aevrov
VMware Employee
VMware Employee

Hi DyJohnnY,

What I understand is that you want to "acknowledge" all the triggerred alarms. Here's how you can do it:

Connect-VIServer ....

$serviceInstance = Get-View -Id ServiceInstance
$inventoryRoot = Get-View -Id $serviceInstance.Content.RootFolder -Property "TriggeredAlarmState"

$alarmManager = Get-View -Id AlarmManager

$inventoryRoot.TriggeredAlarmState | % {
    if( -not $_.Acknowledged ) {
        $alarmManager.AcknowledgeAlarm($_.Alarm, $_.Entity)
    }
}

Regards,

- Angel

DyJohnnY
Enthusiast
Enthusiast

Thanks for the input, i got how you can filter triggered alarms.

however I am not interested in acknowledging them. I have had situations where I cannot reset alarms, they remain in vCenter, long after the condition is no longer present.

In that case I need to disable them and enable them back (it is like a workaround for making them dissappear)

Thanks

ionut

IonutN
Reply
0 Kudos
avlieshout
VMware Employee
VMware Employee

You should use the reset the alarm to green option

Must be possible with powercli also.

Arnim van Lieshout Blogging: http://www.van-lieshout.com Twitter: http://www.twitter.com/avlieshout If you find this information useful, please award points for "correct" or "helpful".
Reply
0 Kudos
cleffingwell
VMware Employee
VMware Employee

Is there a script to run that will disable individual alarms by name?  I have a customer that wants to run a script that will disable certain VM-related alarms in their VC's.

Thanks,

Clint

Reply
0 Kudos
LucD
Leadership
Leadership

This uses the SDK method to disable/enable alarms, but I'm not sure it is faster.

$alarmMgr = Get-View AlarmManager 
$alarmMgr
.GetAlarm($null) | %{     $alarm = Get-View $_
    if($alarm.Info.Enabled){         $spec = $Alarm.Info         $spec.Enabled = $false
        $alarm.ReconfigureAlarm($spec)         $spec.Enabled = $true
       
$alarm.ReconfigureAlarm($spec)     } }

The reset to green function is available in the Community Extensions

But watch out these extensions have a problem with PowerCLI 4.1 and higher due to the changed typenames.


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

Reply
0 Kudos