Using the HA Application Monitoring SDK
This section provides a short introduction to the HA Application Monitoring SDK. You need information in vSphere HA Application Monitoring to proceed further.
SDK function definitions and simple documentation are in the vmGuestAppMonitorLib.h include file.
Controlling the Application Monitoring Heartbeat
To run HA application monitoring programs, the virtual machine must be running on an ESXi host, and application monitoring must have been enabled when configuring HA.
You can enable heartbeats with the compiled vmware-appmonitor program. Usage is as follows:
vmware-appmonitor { enable | disable | markActive | isEnabled | getAppStatus | postAppState }
enable – Enable application heartbeat so vSphere HA starts listening and monitoring the heartbeat count from this guest virtual machine. The heartbeats should be sent at least once every 30 seconds.
disable – Disable the application heartbeat so vSphere HA stops listening to heartbeats from this guest.
markActive – This starts sending the actual heartbeat every 30 seconds or less.
isEnabled – Indicates whether the heartbeat monitoring was enabled.
getAppStatus – Gets the status of the application, either Green, Red, or Gray.
postAppState – Posts the state of the application. Arguments can be:
appStateOk – Sends an “Application State is OK” signal to the HA agent running on the host.
appStateNeedReset – Sends an “Immediate Reset” signal to the HA agent running on the host.
Library Path or Path Environment
On Linux, set your LD_LIBRARY_PATH environment to the install location of GuestSDK/lib/lib32 or lib64. On Windows, you can set your PATH environment, but it is probably easier to copy vmware-appmonitor to the same folder as the DLL files.
Compiling the Sample Program on Linux
You need a C compiler and the make program.
1
Go to the docs/VMGuestAppMonitor/samples/C directory.
2
Run the make command.
On a 64-bit machine you might want to change lib32 to lib64 in the makefile.
3
Set LD_LIBRARY_PATH as described above.
4
./sample
Compiling Sample Programs on Windows
You need Visual Studio 2008 or later.
1
Go to the docs/VMGuestAppMonitor/samples/visualstudio folder.
2
Open the appmon.vcproj file and build the solution.
3
Click Debug > Start Debugging to run appmon.exe. See below for program usage.
Demonstrating the HA Application Monitoring API
The sample program enables HA application monitoring and sends a heartbeat every 15 seconds. After the program starts running, typing Ctrl+C displays three choices:
d – disable application monitoring and exit the program. This does not cause a reset.
c – continue sending heartbeats.