VMware vSphere

 View Only

 Custom Alarm

Mark Budman's profile image
Mark Budman posted Jan 15, 2025 04:40 PM

Hello,

I would like to create a custom alarm  that sends an email or a sequence of events that generate an email.

Situation:

I have created an affinity rule where VM1 & VM2 should not be hosted on same hypervisor. Currently, DRS is set to partial. So, what happens when VM1 & VM2 appear on the same hypervisor, DRS generates a recommendation to separate the two onto different hypervisors.

I would like an email automatically sent indicating the recommended action  when this situation happens.

The email server and account are properly set.

Does anyone know if it is possible to achieve this objective and how it can be done?

I have tried creating an alarm, but cannot get this scenario (and do not know how) to generate an alarm, so no email is sent.

Thanks in advance.

Andrea Consalvi's profile image
Andrea Consalvi

Hi,

Yes, this is possible, but not directly through vCenter’s built-in alarms. vCenter doesn’t trigger an alarm just for a DRS recommendation it only generates alerts when there’s an actual issue, like a VM placement failure. Since your DRS is set to "Partial," vCenter is simply suggesting an action rather than enforcing it, which is why no alarm is being triggered.

To work around this, you can use PowerCLI to periodically check for DRS recommendations and send an email when vCenter suggests separating VM1 and VM2. The Get-DrsRecommendation command allows you to detect when vCenter recommends a migration based on your affinity rule. You can then configure a scheduled task to run this script at regular intervals and send an email if a recommendation is found.