<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article How to monitor VM is normally running or facing a problem. in VIX API Documents</title>
    <link>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/ta-p/2786822</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question how a remote program can monitor VM is normally running or not on VMware.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My environment is VMware ESX 4.0 and VIX API 1.7.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;############################################################################&lt;/P&gt;&lt;P&gt;BOOL writeReadPropertiesToVM(VixHandle vmHandle, BOOL* vmOK)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; BOOL status = FALSE;&lt;/P&gt;&lt;P&gt; VixError err = VIX_OK;&lt;/P&gt;&lt;P&gt; VixHandle jobHandle = VIX_INVALID_HANDLE;&lt;/P&gt;&lt;P&gt; char *readValue = NULL;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; jobHandle = VixVM_WriteVariable(vmHandle,&lt;/P&gt;&lt;P&gt;    VIX_VM_GUEST_VARIABLE,&lt;/P&gt;&lt;P&gt;                                                      "myTestVariable",&lt;/P&gt;&lt;P&gt;                                                      "newValue",&lt;/P&gt;&lt;P&gt;                                                      0, // options&lt;/P&gt;&lt;P&gt;                                                     NULL, // callbackProc&lt;/P&gt;&lt;P&gt;                                                     NULL); // clientData);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);&lt;/P&gt;&lt;P&gt; if (VIX_OK != err)&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;     // Handle the error...&lt;/P&gt;&lt;P&gt;     const char* errorString = Vix_GetErrorText(err, NULL);&lt;/P&gt;&lt;P&gt;     printf("VixVM_WriteVariable, status = 0x0%x(%s).\n", err, errorString);&lt;/P&gt;&lt;P&gt;      goto abort;&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt; printf("VixVM_WriteVariable succeeded.n");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; jobHandle = VixVM_ReadVariable(vmHandle,&lt;/P&gt;&lt;P&gt;       VIX_VM_GUEST_VARIABLE,&lt;/P&gt;&lt;P&gt;                                                        "myTestVariable",&lt;/P&gt;&lt;P&gt;                                                        0, // options&lt;/P&gt;&lt;P&gt;                                                        NULL, // callbackProc&lt;/P&gt;&lt;P&gt;                                                        NULL); // clientData);&lt;/P&gt;&lt;P&gt; err = VixJob_Wait(jobHandle, &lt;/P&gt;&lt;P&gt;                                      VIX_PROPERTY_JOB_RESULT_VM_VARIABLE_STRING,&lt;/P&gt;&lt;P&gt;                                      &amp;amp;readValue,&lt;/P&gt;&lt;P&gt;                                      VIX_PROPERTY_NONE);&lt;/P&gt;&lt;P&gt; if (VIX_OK != err)&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;      // Handle the error...&lt;/P&gt;&lt;P&gt;      const char* errorString = Vix_GetErrorText(err, NULL);&lt;/P&gt;&lt;P&gt;      printf("VixVM_ReadVariable, status = 0x0%x(%s).\n", err, errorString);&lt;/P&gt;&lt;P&gt;      goto abort;&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt; printf("VixVM_ReadVariable succeeded.\n");&lt;/P&gt;&lt;P&gt; *vmOK = TRUE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; status = TRUE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;abort:&lt;/P&gt;&lt;P&gt; Vix_FreeBuffer(readValue);&lt;/P&gt;&lt;P&gt; Vix_ReleaseHandle(jobHandle);&lt;/P&gt;&lt;P&gt; return status;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shigemi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Nov 2009 01:10:26 GMT</pubDate>
    <dc:creator>Shigemi</dc:creator>
    <dc:date>2009-11-16T01:10:26Z</dc:date>
    <item>
      <title>How to monitor VM is normally running or facing a problem.</title>
      <link>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/ta-p/2786822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question how a remote program can monitor VM is normally running or not on VMware.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My environment is VMware ESX 4.0 and VIX API 1.7.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;############################################################################&lt;/P&gt;&lt;P&gt;BOOL writeReadPropertiesToVM(VixHandle vmHandle, BOOL* vmOK)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt; BOOL status = FALSE;&lt;/P&gt;&lt;P&gt; VixError err = VIX_OK;&lt;/P&gt;&lt;P&gt; VixHandle jobHandle = VIX_INVALID_HANDLE;&lt;/P&gt;&lt;P&gt; char *readValue = NULL;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; jobHandle = VixVM_WriteVariable(vmHandle,&lt;/P&gt;&lt;P&gt;    VIX_VM_GUEST_VARIABLE,&lt;/P&gt;&lt;P&gt;                                                      "myTestVariable",&lt;/P&gt;&lt;P&gt;                                                      "newValue",&lt;/P&gt;&lt;P&gt;                                                      0, // options&lt;/P&gt;&lt;P&gt;                                                     NULL, // callbackProc&lt;/P&gt;&lt;P&gt;                                                     NULL); // clientData);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);&lt;/P&gt;&lt;P&gt; if (VIX_OK != err)&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;     // Handle the error...&lt;/P&gt;&lt;P&gt;     const char* errorString = Vix_GetErrorText(err, NULL);&lt;/P&gt;&lt;P&gt;     printf("VixVM_WriteVariable, status = 0x0%x(%s).\n", err, errorString);&lt;/P&gt;&lt;P&gt;      goto abort;&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt; printf("VixVM_WriteVariable succeeded.n");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; jobHandle = VixVM_ReadVariable(vmHandle,&lt;/P&gt;&lt;P&gt;       VIX_VM_GUEST_VARIABLE,&lt;/P&gt;&lt;P&gt;                                                        "myTestVariable",&lt;/P&gt;&lt;P&gt;                                                        0, // options&lt;/P&gt;&lt;P&gt;                                                        NULL, // callbackProc&lt;/P&gt;&lt;P&gt;                                                        NULL); // clientData);&lt;/P&gt;&lt;P&gt; err = VixJob_Wait(jobHandle, &lt;/P&gt;&lt;P&gt;                                      VIX_PROPERTY_JOB_RESULT_VM_VARIABLE_STRING,&lt;/P&gt;&lt;P&gt;                                      &amp;amp;readValue,&lt;/P&gt;&lt;P&gt;                                      VIX_PROPERTY_NONE);&lt;/P&gt;&lt;P&gt; if (VIX_OK != err)&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;      // Handle the error...&lt;/P&gt;&lt;P&gt;      const char* errorString = Vix_GetErrorText(err, NULL);&lt;/P&gt;&lt;P&gt;      printf("VixVM_ReadVariable, status = 0x0%x(%s).\n", err, errorString);&lt;/P&gt;&lt;P&gt;      goto abort;&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt; printf("VixVM_ReadVariable succeeded.\n");&lt;/P&gt;&lt;P&gt; *vmOK = TRUE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; status = TRUE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;abort:&lt;/P&gt;&lt;P&gt; Vix_FreeBuffer(readValue);&lt;/P&gt;&lt;P&gt; Vix_ReleaseHandle(jobHandle);&lt;/P&gt;&lt;P&gt; return status;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shigemi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Nov 2009 01:10:26 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/ta-p/2786822</guid>
      <dc:creator>Shigemi</dc:creator>
      <dc:date>2009-11-16T01:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to monitor VM is normally running or facing a problem.</title>
      <link>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/tac-p/2786823#M6</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll need to use vi sdk and not vix.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Nov 2009 16:11:04 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/tac-p/2786823#M6</guid>
      <dc:creator>fixitchris</dc:creator>
      <dc:date>2009-11-19T16:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to monitor VM is normally running or facing a problem.</title>
      <link>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/tac-p/2786824#M7</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Nov 2009 02:09:11 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VIX-API-Documents/How-to-monitor-VM-is-normally-running-or-facing-a-problem/tac-p/2786824#M7</guid>
      <dc:creator>Shigemi</dc:creator>
      <dc:date>2009-11-20T02:09:11Z</dc:date>
    </item>
  </channel>
</rss>

