Alternatively, instead of not sending heartbeat signals, your application monitoring program can set the needReset flag using the VMGuestAppMonitor_PostAppState call. When the HA monitoring agent notices this flag, it will reset the virtual machine.Most of the calls you make using the HA Application Monitoring APIs send information to the virtual infrastructure of the ESXi host, and the host relays the information to the HA monitoring agent. However, the VMGuestAppMonitor_GetAppStatus call is a two-way transaction that lets you request the virtual machine status from the HA monitoring agent.
Publish the application state that the guest OS wants delivered to vSphere HA. The application should monitor its environment and update its state accordingly. Heartbeat counting does not need to be enabled as a pre-condition, so the enable() call is not necessary. Returns 0 (zero) on success.The single state parameter passed to this call can be either:
■ needReset – The guest's application agent has requested an immediate reset. The guest can request this at any time.
■ Green. Virtual machine infrastructure acknowledges that the application is being monitored.
■ Red. Virtual machine infrastructure does not think the application is being monitored. The HA monitoring agent will initialize an asynchronous reset on the virtual machine if the status is Red.
■ Gray. Application should send VMGuestAppMonitor_Enable again, followed by VMGuestAppMonitor_MarkActive, because either application monitoring failed, or the virtual machine was vMotioned to a different location. The HA Application Monitoring SDK includes a code sample called appmon.cpp. The sample is located in the docs/samples directory and defines the entry point for the console application. The appmon.cpp program includes interface code that your application monitoring program can send after receiving results from calls to VMGuestAppMonitor_Enable, VMGuestAppMonitor_MarkActive, and VMGuestAppMonitor_Disable.
1 Include vmGuestAppMonitorLib.h in the declarations for your C program.
2
3 After you have called VMGuestAppMonitor_Enable, call VMGuestAppMonitor_MarkActive every 30 seconds or your virtual machine will be reset.
4 Send VMGuestAppMonitor_IsEnabled to make sure the virtual machine infrastructure received your requests correctly and has begun monitoring.
5 Periodically, call VMGuestAppMonitor_GetAppStatus to make sure the vSphere infrastructure is still receiving the heartbeat calls.The status will be returned as Green, Red, or Gray. See HA Application Monitoring API Calls, for a description of each status value. Heartbeat and Status Signals shows a possible coding flow for the GetAppStatus call.
6 After you call VMGuestAppMonitor_GetAppStatus, call the VMGuestAppMonitor_Free function to free the memory that was used to store the status.
7 Call VMGuestAppMonitor_Disable when you want the agent to stop monitoring.