cstewart30
Contributor
Contributor

Create an Alarm

I'm trying to add an alarm, to my appliance (Version 6.5 Build 11347054), but it's not working.  I have tried the manual way, but it will not let me do this:

From the vSphere Client select the vCenter server at the top of the hierarchy and go to >> Alarms >> Definitions >> Right click in the empty space and select New Alarm. On the General tab provide an alarm name and description, Select vCenter for alarm type and "Monitor for specific events occurring on this object", check "Enable this alarm". On the Triggers tab click Add three triggers and in the event column enter "vim.event.PermissionAddedEvent", "vim.event.PermissionRemovedEvent", and "vim.event.PermissionUpdatedEvent" for the three triggers and click OK."

I only have drop down options, no where can I add the triggers as specified.  So I went to Google and found a script over at blog.ukotic.net​.  But it does not seem to be working.  I'm getting an error, "The object 'vim.ManagedEntity:{vcenterappliance_name}' has already been deleted or has not been completely created"

connect-viserver....

$alarmMgr = Get-View AlarmManager

# Create AlarmSpec object

$alarm = New-Object VMware.Vim.AlarmSpec

$alarm.Name = "STIG VCWN-06-000048 - Permission Modification"

$alarm.Description = "Track permission changes"

$alarm.Enabled = $TRUE

# Event expression 1 - Permission Added

$expression1 = New-Object VMware.Vim.EventAlarmExpression

$expression1.EventType = "EventEx"

$expression1.EventTypeId = "vim.event.PermissionAddedEvent"

$expression1.ObjectType = "VirtualMachine"

$expression1.status = "Yellow"

# Event expression 2 - Permission Removed

$expression2 = New-Object VMware.Vim.EventAlarmExpression

$expression2.EventType = "EventEx"

$expression2.EventTypeId = "vim.event.PermissionRemovedEvent"

$expression2.ObjectType = "VirtualMachine"

$expression2.status = "Yellow"

# Event expression 3 - Permission Modified

$expression3 = New-Object VMware.Vim.EventAlarmExpression

$expression3.EventType = "EventEx"

$expression3.EventTypeId = "vim.event.PermissionUpdatedEvent"

$expression3.ObjectType = "VirtualMachine"

$expression3.status = "Yellow"

# 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("{appliancename}",$alarm)

0 Kudos
2 Replies
LucD
Leadership
Leadership

The 1st parameter on the CreateAlarm call should be the MoRef to the entity on which you want to create the alarm.

Not the name of the appliance.


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

0 Kudos
john49
Contributor
Contributor

I was able to go to that website, use that script in powercli after I had connected to the vcenter server. Not sure if you were connected or not. 

0 Kudos