What does "Enable heartbeat monitoring for the virtual machine" do ?

 

Hi,

 

I've been asked this a couple of times, and thought it might be interesting to blog..

 

If you have a R2 Hyper-V Host cluster, the Virtual Machine Resource has a property on the Settings page named "Heartbeat Setting" with an associated check box "Enable heartbeat monitoring for the virtual machine".

 

 

By default, this checking is not active. Let's see what it does and if you would have the requirement to enable it.

 

When you have a Virtual Machine with Integration Services installed, by default the Heartbeat Service is installed inside the Virtual Machine, and regularly notifies the Hyper-V host that it is alive.

If you'd enable "Enable heartbeat monitoring for the virtual machine", the cluster will reset the virtual machine should the heartbeat not arrive in a given timeframe (1minute).

 

That might be desirable, but can lead to a unwanted side effect:

 

When you shut down or restart the Virtual machine, the heartbeat service is stopped and does not send notifications to the Hyper-V Host anymore. So the Virtual Machine might be reset once during reboot.

 

As a workaround, configure a 2nd boot selection to have a boot selection menu, and a delay of 60 seconds. This will ensure that the reset is taken at a time, when it does not harm.

 

Cheers

Robert

 

For those of you interested in scripting, the Msvm_HeartbeatComponentSettings class holds two values, Latency and Interval, but the maximum accepted values are 6000 and 60000 ms.

 

# Invoke MSVM ManagmentService Class

$MgmtSvc = gwmi -namespace root\virtualization MSVM_VirtualSystemManagementService

 

 

$Server="."

$VMName = "YourVMName"

 

# Get the virtual machine object

$query = "Select * From Msvm_ComputerSystem Where ElementName='" + $VMName + "'"

$VM = gwmi -namespace root\virtualization -query $query -computername $Server

 

#Get the Heartbeat Component

$HeartbeatComponent = gwmi -query "associators of {$VM} where ResultClass = Msvm_HeartbeatComponent" -namespace root\virtualization

 

#Get the Settings collection from the Heartbeat Component

$HeartbeatSetting = gwmi -query "associators of {$HeartbeatComponent} where ResultClass = Msvm_HeartbeatComponentSettingData" -namespace root\virtualization

 

$HeartbeatSetting.Latency = 6000

$HeartbeatSetting.Interval = 60*1000

 

#Write the Setting

$MgmtSvc.ModifyVirtualSystemResources($VM.__path,$HeartbeatSetting.GetText(1))