Msvm_HeartbeatComponent class

Represents the state of the heartbeat service, which is responsible for monitoring the state of a virtual machine by reporting a heartbeat at regular intervals.

The following syntax is simplified Managed Object Format (MOF) code, and it includes all of the inherited properties.

Syntax

[Dynamic, Provider("VmmsWmiInstanceAndMethodProvider"), AMENDMENT]
class Msvm_HeartbeatComponent : CIM_LogicalDevice
{
  string   InstanceID;
  string   Caption = "Heartbeat";
  string   Description = "Microsoft Heartbeat Service";
  string   ElementName = "Heartbeat";
  datetime InstallDate;
  string   Name;
  uint16   OperationalStatus[];
  string   StatusDescriptions[];
  string   Status;
  uint16   HealthState = 5;
  uint16   CommunicationStatus;
  uint16   DetailedStatus;
  uint16   OperatingStatus;
  uint16   PrimaryStatus;
  uint16   EnabledState = 2;
  string   OtherEnabledState;
  uint16   RequestedState = 12;
  uint16   EnabledDefault = 7;
  datetime TimeOfLastStateChange;
  uint16   AvailableRequestedStates[];
  uint16   TransitioningToState;
  string   SystemCreationClassName = "Msvm_ComputerSystem";
  string   SystemName;
  string   CreationClassName = "Msvm_HeartbeatComponent";
  string   DeviceID = "Microsoft:VMGUID\GUID";
  boolean  PowerManagementSupported;
  uint16   PowerManagementCapabilities[];
  uint16   Availability;
  uint16   StatusInfo;
  uint32   LastErrorCode;
  string   ErrorDescription;
  boolean  ErrorCleared;
  string   OtherIdentifyingInfo[];
  uint64   PowerOnHours;
  uint64   TotalPowerOnHours;
  string   IdentifyingDescriptions[];
  uint16   AdditionalAvailability[] = 6;
  uint64   MaxQuiesceTime;
};

Members

The Msvm_HeartbeatComponent class has these types of members:

Methods

The Msvm_HeartbeatComponent class has these methods.

Method Description
EnableDevice This method is not supported.
OnlineDevice This method is not supported.
QuiesceDevice This method is not supported.
RequestStateChange Requests a state change.
Reset Resets the virtual device.
RestoreProperties This method is not supported.
SaveProperties This method is not supported.
SetPowerState This method is not supported.

Properties

The Msvm_HeartbeatComponent class has these properties.

AdditionalAvailability

Data type: uint16 array

Access type: Read-only

Any additional availability and status of the device. This property is inherited from CIM_LogicalDevice, and it is always set to 6 (Not Applicable).

Availability

Data type: uint16

Access type: Read-only

The primary availability and status of the device. This property is inherited from CIM_LogicalDevice, but it is not used.

AvailableRequestedStates

Data type: uint16 array

Access type: Read-only

Indicates the possible values for the RequestedState parameter of the RequestStateChange method used to initiate a state change. The values listed will be a subset of the values contained in the RequestedStatesSupported property of the associated instance of CIM_EnabledLogicalElementCapabilities, where the values selected are a function of the current state of the CIM_EnabledLogicalElement. This property can be non-Null if an implementation is able to advertise the set of possible values as a function of the current state. This property will be Null if an implementation is unable to determine the set of possible values as a function of the current state.

This property is inherited from CIM_EnabledLogicalElement.

Enabled (2)

Disabled (3)

Shut Down (4)

Offline (6)

Test (7)

Defer (8)

Quiesce (9)

Reboot (10)

Reset (11)

DMTF Reserved (.. )

Caption

Data type: string

Access type: Read-only

A short description of the object. This property is inherited from the CIM_ManagedElement class and is always set to "Heartbeat".

CommunicationStatus

Data type: uint16

Access type: Read-only

Indicates the ability of the instrumentation to communicate with the underlying managed element. A Null value indicates that this property is not implemented. This property is inherited from CIM_ManagedSystemElement.

CreationClassName

Data type: string

Access type: Read-only

The scoping system's creation class name. This property is inherited from CIM_LogicalDevice, and it is always set to "Msvm_HeartbeatComponent".

Description

Data type: string

Access type: Read-only

A description of the object. This property is inherited from CIM_ManagedElement, and it is always set to "Microsoft Heartbeat Service".

DetailedStatus

Data type: uint16

Access type: Read-only

Complements the PrimaryStatus property with additional status detail. A Null value indicates that this property is not implemented. This property is inherited from CIM_ManagedSystemElement.

DeviceID

Data type: string

Access type: Read-only

An address or other identifying information to uniquely name the logical device. This property is inherited from CIM_LogicalDevice, and it is always set to "Microsoft:VMGUID\GUID" where VMGUID is the Name property of the Msvm_ComputerSystem associated with this device.

ElementName

Data type: string

Access type: Read-only

A display name for the object. This property is inherited from CIM_ManagedElement, and it is always set to "Heartbeat".

EnabledDefault

Data type: uint16

Access type: Read-only

This property is inherited from CIM_EnabledLogicalElement, and it is always set to 7 (No Default).

EnabledState

Data type: uint16

Access type: Read-only

The enabled and disabled states of an element. This property is inherited from CIM_EnabledLogicalElement and will be one of the following values.

Value Meaning
Enabled
2
The element is running.
Disabled
3
The element is turned off.

ErrorCleared

Data type: boolean

Access type: Read-only

Indicates whether the error reported in LastErrorCode is now cleared. This property is inherited from CIM_LogicalDevice but is not used.

ErrorDescription

Data type: string

Access type: Read-only

A string that provides more information about the error recorded in LastErrorCode and information about any corrective actions that can be taken. This property is inherited from CIM_LogicalDevice but is not used.

HealthState

Data type: uint16

Access type: Read-only

The current health of the element. This property is inherited from CIM_ManagedSystemElement, and it is always set to 5 (OK).

IdentifyingDescriptions

Data type: string array

Access type: Read-only

An array of free-form strings that provide explanations and details behind the entries in the OtherIdentifyingInfo property array. This property is inherited from CIM_LogicalDevice, but it is not used.

InstallDate

Data type: datetime

Access type: Read-only

The date and time that the integration service was installed into the virtual machine. This property is inherited from CIM_ManagedSystemElement.

InstanceID

Data type: string

Access type: Read-only

Qualifiers: Key

Uniquely identifies an instance of this class. This property is inherited from CIM_ManagedElement.

LastErrorCode

Data type: uint32

Access type: Read-only

The last error code reported by the logical device. This property is inherited from CIM_LogicalDevice, but it is not used.

MaxQuiesceTime

Data type: uint64

Access type: Read-only

This property has been deprecated. This property is inherited from CIM_LogicalDevice, but it is not used.

Name

Data type: string

Access type: Read-only

The label by which the object is known. This property is inherited from CIM_ManagedSystemElement.

OperatingStatus

Data type: uint16

Access type: Read-only

Provides current status information for the operational condition of the element and can be used for providing more detail with respect to the value of the EnabledState property. A Null value indicates that this property is not implemented. This property is inherited from CIM_ManagedSystemElement.

OperationalStatus

Data type: uint16 array

Access type: Read-only

Qualifiers: Override ("OperationalStatus"), ArrayType ("Indexed")

The current status of the element. This property is inherited from CIM_ManagedSystemElement.

The following are the possible values for the OperationalStatus[0] property value.

OK (2)

The service is operating normally. The OperationalStatus[1] and StatusDescriptions[1] property values may contain more information.

Degraded (3)

The service is operating normally, but the guest service negotiated a compatible communications protocol version. The OperationalStatus[1] and StatusDescriptions[1] property values may contain more information.

Non-Recoverable Error (7)

The guest does not support a compatible protocol version. The OperationalStatus[1] and StatusDescriptions[1] property values may contain more information.

No Contact (12)

The guest service is not installed or has not yet been contacted.

Lost Communication (13)

The guest service is no longer responding normally.

Paused (15)

The virtual machine is paused.

The OperationalStatus[1] property value indicates the coalesced application state values. This will be one of the following values.

Note

The state for an application is set on the virtual machine by using the SetApplicationState method.

OK (2)

The applications running inside the virtual machine are operating normally.

Protocol Mismatch (32775)

The guest and the host components are running different protocol versions.

Application Critical State (32782)

One or more of the applications inside the virtual machine are in a critical state.

Communication Timed Out (32783)

Timed out waiting for a response from the guest component.

Communication Failed (32784)

Failed to communicate with the guest component.

OtherEnabledState

Data type: string

Access type: Read-only

A string that describes the enabled or disabled state of the element when the EnabledState property is set to 1 (Other). This property must be set to Null when the EnabledState property is any value other than 1. This property is inherited from CIM_EnabledLogicalElement, and it is always set to Null.

OtherIdentifyingInfo

Data type: string array

Access type: Read-only

Any additional data, beyond device ID information, that could be used to identify a logical device. This property is inherited from CIM_LogicalDevice and is always set to Null.

PowerManagementCapabilities

Data type: uint16 array

Access type: Read-only

The power management capabilities of the device. This property is inherited from CIM_LogicalDevice, but it is not used.

PowerManagementSupported

Data type: boolean

Access type: Read-only

Indicates whether the device can be power managed. This property is inherited from CIM_LogicalDevice, but it is not used.

PowerOnHours

Data type: uint64

Access type: Read-only

The number of consecutive hours that this device has been powered on since its last power cycle. This property is inherited from CIM_LogicalDevice but is not used.

PrimaryStatus

Data type: uint16

Access type: Read-only

Provides high level status information. This property should be used in conjunction with the DetailedStatus property to provide high level and detailed health status information for the element and its subcomponents. A Null value indicates that this property is not implemented. This property is inherited from CIM_ManagedSystemElement.

RequestedState

Data type: uint16

Access type: Read-only

The last requested or desired state for the element. This property is inherited from CIM_EnabledLogicalElement, and it is always set to 12 (Not Applicable).

Status

Data type: string

Access type: Read-only

The current status of the object. This property is inherited from CIM_ManagedSystemElement but is not used.

StatusDescriptions

Data type: string array

Access type: Read-only

Strings that describe the various OperationalStatus array values. This property is inherited from CIM_ManagedSystemElement.

StatusInfo

Data type: uint16

Access type: Read-only

The current state of the logical device. This property is inherited from CIM_LogicalDevice, but it is not used.

SystemCreationClassName

Data type: string

Access type: Read-only

The scoping system's creation class name. This property is inherited from CIM_LogicalDevice, and it is always set to "Msvm_ComputerSystem".

SystemName

Data type: string

Access type: Read-only

The scoping system's name. This property is inherited from CIM_LogicalDevice and is the name of the Msvm_ComputerSystem that is associated with this heartbeat service.

TimeOfLastStateChange

Data type: datetime

Access type: Read-only

The date or time when the enabled state of the element last changed. This property is inherited from CIM_EnabledLogicalElement, and it is always set to Null.

TotalPowerOnHours

Data type: uint64

Access type: Read-only

The total number of hours that this device has been powered. This property is inherited from CIM_LogicalDevice, but it is not used.

TransitioningToState

Data type: uint16

Access type: Read-only

Indicates the target state to which the instance is transitioning. This property is inherited from CIM_EnabledLogicalElement, but it is not used.

Remarks

Access to the Msvm_HeartbeatComponent class might be restricted by UAC Filtering. For more information, see User Account Control and WMI.

Examples

The following C# sample obtains the application health status of a virtual machine. The referenced utilities can be found in Common utilities for the virtualization samples (V2).

Important

To function correctly, the following code must be run with Administrator privileges.

private UInt16 OperationalStatusOk = 2;
private UInt16 OperationalStatusApplicationCriticalState = 32782;

/// <summary>
/// Gets the applications status in the VM.
/// </summary>
/// <param name="hostMachine">The hostname of the machine on which
/// the VM is running.</param>
/// <param name="vmName">The VM name.</param>
public
void
GetAppHealthStatus(
    string hostMachine,
    string vmName
    )
{
    ManagementScope scope = new ManagementScope(
        @"\\" + hostMachine + @"\root\virtualization\v2", null);

    ManagementObject heartBeatComponent = null;

    // Get the VM object and its heart beat component.
    using (ManagementObject vm = WmiUtilities.GetVirtualMachine(vmName, scope))
    using (ManagementObjectCollection heartBeatCollection =
        vm.GetRelated("Msvm_HeartbeatComponent", "Msvm_SystemDevice",
            null, null, null, null, false, null))
    {
        foreach (ManagementObject element in heartBeatCollection)
        {
            heartBeatComponent = element;
            break;
        }
    }

    if (heartBeatComponent == null)
    {
        Console.WriteLine("The VM is not running.");
        return;
    }

    using (heartBeatComponent)
    {
        UInt16[] operationalStatus = (UInt16[])heartBeatComponent["OperationalStatus"];
        UInt16 vmStatus = operationalStatus[0];

        if (vmStatus != OperationalStatusOk)
        {
            Console.WriteLine("The VM heartbeat status is not OK");
            return;
        }

        if (operationalStatus.Length != 2)
        {
            Console.WriteLine("The required Integration Components are not running " +
                "or not installed.");
            return;
        }

        UInt16 appStatus = operationalStatus[1];
        if (appStatus == OperationalStatusOk)
        {
            Console.WriteLine("The VM applications health status: OK");
        }
        else if (appStatus == OperationalStatusApplicationCriticalState)
        {
            Console.WriteLine("The VM applications health status: Critical");
        }
        else
        {
            throw new ManagementException("Unknown application health status");
        }
    }
}

Requirements

Requirement Value
Minimum supported client
Windows 8 [desktop apps only]
Minimum supported server
Windows Server 2012 [desktop apps only]
Namespace
Root\Virtualization\V2
MOF
WindowsVirtualization.V2.mof
DLL
Vmms.exe

See also

CIM_LogicalDevice

CIM_LogicalDevice

Msvm_HeartbeatComponent