VMware Cloud Community
harkamal
Expert
Expert

Reset alarm to green

I created alarm for a host, and it rings as expected.

However, even after acknowledging the alarm, the red warning pointer on the host is still appearing. I have to manually click "Reset alarm to green" to make it go away.

Could not find an equivalent method in Alarm Manager to "Reset alarm to green"... can someone guide where is this API ?

Please also see the snapshot for more clarity

Reply
0 Kudos
11 Replies
LucD
Leadership
Leadership

The acknowledge alarm action will make sure that the alarm doesn't fire again until the status went to back to a green or gray state.

See the AcknowledgeAlarm method.

This is available to avoid that the same actions are fired over and over again.

To reset the status you will have to use the ReconfigureAlarm method.

The following script shows how to do this for a rather simple event alarm (I used the "VM being cloned event" for testing).


$vm = Get-VM <Guest-with-triggered-alarm> | Get-View

foreach($daState in $vm.DeclaredAlarmState){
	if($daState.OverallStatus -eq "red"){
		$alarm = Get-View $daState.Alarm
		continue
	}
}

$spec = [http://VMware.Vim.AlarmSpec|http://VMware.Vim.AlarmSpec]$alarm.Info
$alarm.ReconfigureAlarm($spec)

This seems to do the trick but I suspect it will require further testing.

Some features to be added:

*) it won't handle situations where there is more than event on an entity

*) it doesn't allow to specify which alarm should be reset

*) it doesn't handle the same alarm being triggered for multiple entities

*) ....

I feel a blog entry coming up Smiley Wink


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

Reply
0 Kudos
harkamal
Expert
Expert

Problem: It resets ALL alarms on all managed objects Smiley Sad what to do ?

# Which object alarm kicked in ( use env:VMWARE_ALARM_ID)
$alMOR = New-Object Vmware.Vim.ManagedObjectReference
$alMOR.type = "Alarm"
$alMOR.value = "alarm-33"


$alarm = Get-View $alMOR


# Alarm target host (use env: VMWARE_ALARM_EVENT_HOST)
$alarmHost = Get-VMHost serverxyz | Get-View 


# Acknowledge Alarm --works OK
$am.AcknowledgeAlarm($alarm.MoRef, $alarmHost.MoRef)


# Reset Alarm to Green -- resets ALL Alarms -- does NOT solves the purpose
$alarm.ReconfigureAlarm($alarm.Info)

Reply
0 Kudos
harkamal
Expert
Expert

anyone...pls help

Reply
0 Kudos
admin
Immortal
Immortal

What vCenter build do you use? I don't get the option that you have, was this feature added in a patch? Or is there something special you have to do to get this option? Was that alarm a custom alarm or a default alarm? Little features like this that sneak in are often not controllable via the API, unfortunately.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

Reply
0 Kudos
LucD
Leadership
Leadership

The method, used by the vSphere Client, is called SetAlarmStatus and is currently undocumented.

See The Onyx alternative ?


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

Reply
0 Kudos
admin
Immortal
Immortal

Are you able to call that method in PowerCLI? Usually methods like this can't be called, e.g. EnableAdmin / DisableAdmin, without using the "scheduled task trick".

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

Reply
0 Kudos
LucD
Leadership
Leadership

I tried using the CreateScheduledTask method with the MethodAction but it doesn't seem to work.

Keep getting an error on the 1st argument where I try to pass a MoRef to the AlarmManager.


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

Reply
0 Kudos
LucD
Leadership
Leadership

Attached what I got so far, but it doesn't work.

Also tried with CreateObjectScheduledTask but that gives the same problem.

There are a few entries on VMTN about a similar problem with the CreateScheduledTask method, but no solution.


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

Reply
0 Kudos
harkamal
Expert
Expert

I tried calling SetAlarmStatus, but it does'nt work. As far as I know, VMWare said 'what you can do with viClient --you can also code in PowerCLI".

Can this be achieved ?

 
$alMOR = New-Object Vmware.Vim.ManagedObjectReference
$alMOR.type = "Alarm"
$alMOR.value = "alarm-37"
$alarm = Get-View $alMOR
$alarm


Info           : VMware.Vim.AlarmInfo
Value          : {}
AvailableField : {}
MoRef          : VMware.Vim.ManagedObjectReference
Client         : VMware.Vim.VimClient


$alarmHost = Get-VMHost myHostName | Get-View
$am.AcknowledgeAlarm($alarm.MoRef, $alarmHost.MoRef)
$am.SetAlarmStatus($alarm.MoRef, $alarmHost.MoRef,"green")
<span style="color: #ff0000">Method invocation failed because [http://VMware.Vim.AlarmManager|http://VMware.Vim.AlarmManager] doesn't contain a method named 'SetAlarmStatus'.
At line:1 char:19
+ $am.SetAlarmStatus( <<<< $alarm.MoRef, $alarmHost.MoRef,"green")</span>

Reply
0 Kudos
harkamal
Expert
Expert

no luck with scheduledTask creation as well :_|

Reply
0 Kudos
jkb5054
Contributor
Contributor

Hi again LucD Smiley Happy

Back story: The alarms were turned off for some clusters and the usage (of datastores) went over the thresholds. We now have alarm states at Green whent hey should really be at yellow or red. We need to identify those datastores and reset the alarms. (thresholds =85% warning, 90% alert)

Can we, via powerCLI find those Datastores, and then reset their alarms to the proper state/status? (alarms are defiend on the whole vcenter)

Any help would be appriciated.

-JkB

Reply
0 Kudos