vmware / vmware/pyvmomi

I created an alarm for vim.event.VmRemovedEvent, but not triggered

Open
#465 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question sample request
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

I created an alarm monitor the virtual machine is removed.Alarm is created successfully, but can not be triggered. And in the same way to create an alert to monitor the virtual machine is created,it will be triggered.How can I through the alarm to monitor the virtual machine to be deleted?
my code like this:
` service_instance = get_service_instance()
content = service_instance.content
folder = content.rootFolder
expression = vim.alarm.EventAlarmExpression(eventType=eventType, eventTypeId='vim.event.{0}'.format(str(eventType._wsdlName)), objectType=vim.VirtualMachine, status='yellow')

action = vim.alarm.AlarmTriggeringAction(
            action=vim.action.RunScriptAction(script='/bin/sh /opt/alarm.sh'),
            transitionSpecs=[vim.alarm.AlarmTriggeringAction.TransitionSpec(startState='green',finalState='yellow',repeats=False)],
            green2yellow=True, yellow2red=False, red2yellow=False, yellow2green=False)

setting = vim.alarm.AlarmSetting(toleranceRange=0, reportingFrequency=0)

spec = vim.alarm.AlarmSpec(name='alarm_to_smc_{0}'.format(name),
                            description='create alarms by python api: {0}'.format(name),
                            enabled = True, actionFrequency = 0,
                            expression = expression,
                            action = action,
                            setting = setting)

this_alarm = service_instance.content.alarmManager.CreateAlarm(entity=folder, spec=spec)

`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the vim.alarm.EventAlarmExpression setup and the CreateAlarm call shown in the report, then compare the eventType, eventTypeId, and objectType values with the corresponding alert configuration. Reproduce a virtual-machine removal event and inspect whether the created alarm changes state and invokes the configured action; done means the removal event reliably triggers the alarm.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.