VMware {code} Community
Shigemi
Contributor
Contributor

How to monitor VM is normally running or facing a problem.

First of all, I wrote my question as document by mistake, so I submit again here.

I have a question how a remote program can monitor VM is normally running or not on VMware.

My environment is VMware ESX 4.0 and VIX API 1.7.

My C++ program can successfully access VMware from remote workstation, monitor power state of VM, power on or shutdown VM. And I want to monitor VM health state in order to confirm VM is normally running, that is power state of VM is running and also VM is not in hang condition.

In case of Hyper-V of Microsoft, VM object, Msvm_ComputerSystem, has HealthState and OperationStatus properties. So it is possible to monitor VM is normally running by periodically monitoring those properties, I think.

In case of VMware, VM object has not such a property. So if anyone has an idea to know health state of VM, please let me know.

I have an idea to confirm VM health by periodically writing and reading variable to VM as follows, but I don't know this is effective or not.

############################################################################

BOOL writeReadPropertiesToVM(VixHandle vmHandle, BOOL* vmOK)

{

BOOL status = FALSE;

VixError err = VIX_OK;

VixHandle jobHandle = VIX_INVALID_HANDLE;

char *readValue = NULL;

jobHandle = VixVM_WriteVariable(vmHandle,

VIX_VM_GUEST_VARIABLE,

"myTestVariable",

"newValue",

0, // options

NULL, // callbackProc

NULL); // clientData);

err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);

if (VIX_OK != err)

{

// Handle the error...

const char* errorString = Vix_GetErrorText(err, NULL);

printf("VixVM_WriteVariable, status = 0x0%x(%s).\n", err, errorString);

goto abort;

}

printf("VixVM_WriteVariable succeeded.n");

jobHandle = VixVM_ReadVariable(vmHandle,

VIX_VM_GUEST_VARIABLE,

"myTestVariable",

0, // options

NULL, // callbackProc

NULL); // clientData);

err = VixJob_Wait(jobHandle,

VIX_PROPERTY_JOB_RESULT_VM_VARIABLE_STRING,

&readValue,

VIX_PROPERTY_NONE);

if (VIX_OK != err)

{

// Handle the error...

const char* errorString = Vix_GetErrorText(err, NULL);

printf("VixVM_ReadVariable, status = 0x0%x(%s).\n", err, errorString);

goto abort;

}

printf("VixVM_ReadVariable succeeded.\n");

*vmOK = TRUE;

status = TRUE;

abort:

Vix_FreeBuffer(readValue);

Vix_ReleaseHandle(jobHandle);

return status;

}

Thanks and regards,

Shigemi

Reply
0 Kudos
2 Replies
admin
Immortal
Immortal

Currently this functionality is not available in the VIX API.

However, if you use the vSphere API, the 'guestHeartbeatStatus' property is available on the VirtualMachine managed object type.

Shigemi
Contributor
Contributor

Mattrich,

I will study vSphere API, but I'm expecting VIX API will support heartbeat capability in future.

Thank your for your reply.

Reply
0 Kudos