You can use the HA Application Monitoring SDK to create a stand-alone application monitoring program, or to enhance an existing application or script. The purpose of your application monitoring program determines the API call sequence and the application behavior that you write to handle the response data.
For example, if your application monitoring program is tracking critical applications that are running in a guest OS, your application can intentionally stop sending heartbeat signals if any application-related process fails. The HA monitoring agent interprets the absence of heartbeats as a failure, and resets the virtual machine.
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 one-way 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.
Call each function from your application monitoring program. The vSphere infrastructure (in the virtual machine where the application monitoring program is running) passes the function data up to the ESXi host. The local virtual machine sends all status responses to your application monitoring program, even though they are passed down from the HA monitoring agent.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The single state parameter passed to this call can be either:
■
|
OK – The guest's application agent declared state to be normal and no action is required.
|
■
|
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.
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.