Using the HA Application Monitoring SDK
This section is provided as a short introduction to the HA Application Monitoring SDK. You will need the information in vSphere HA Application Monitoring before proceeding 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’s host must be running ESX/ESXi 4.1 or later, and application monitoring must have been enabled when configuring HA.
You can enable heartbeats with the precompiled vmware-appmonitor program. Usage is as follows:
vmware-appmonitor { enable | disable | markActive | isEnabled | getAppStatus }
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 stos listening to heartbeats from this guest.
markActive – This starts senting the actual heartbeat every 30 seconds or less.
isEnabled – Indicates whether the heartbeating was enabled.
getAppStatus – Gets the status of the application, either Green, Red, or Gray.
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 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 application monitoring and sends heartbeats every 15 seconds. Once the program is running, typing Ctrl+C displays three choices:
s – stop sending heartbeats and exit the program. This should cause a reset of the virtual machine.
d – disable application monitoring and exit the program. This does not cause a reset.
c – continue sending heartbeats.