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

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

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

Comments

You'll need to use vi sdk and not vix.

Thank you for your suggestion. Now I just started to study VI SDK. But I think VI SDK may not be suitable for me because my program is c++ based.

Version history
Revision #:
1 of 1
Last update:
‎11-15-2009 05:10 PM
Updated by: