ActiveXperts Network Component VMware Object
The VMware object of the ActiveXperts Network Component allows you to retrieve performance data from a VMware host and its virtual machines. The following operations are provided through the VMware interfaces:
- Connect to a VMware ESXi host
- Retrieve performance values from a VMware ESXi host, including: CPU Usage, Memory Usage, Network Traffic, Disk Usage and Status Info of a Virtual Machine
- Retrieve a list of Virtual Machines hosted by the VMware ESXi server
- Retrieve performance values for each Virtual Machine hosted by the ESXi host, including: CPU Usage, Memory Usage, Network Traffic and Disk Usage
The VMware object is part of the Network Component. Overview of all Network Component objects:
DnsServer & DnsRecord - Ftp & FtpFile - Http - Icmp - IPtoCountry - Msn - Ntp - Radius - Rsh - Scp - SFtp - Ssh - SnmpManager - SnmpTrapManager - SnmpMibBrowser - Tcp - Tftp - TraceRoute - Udp - VMware - Wake-on-LAN - Xen (Citrix)
VMware sample code
VBScript sample: Monitor a VMware ESXi host
' Create VMware and ASConstants instances
Set objVMware = CreateObject( "AxNetwork.VMware" )
Set objConstants = CreateObject( "AxNetwork.ASConstants" )
' Set ESXi host information
objVMware.Server = "myesxi-host"
objVMware.ServerAccount = "root"
objVMware.ServerPassword = "topsecret"
' Initialize
objVMware.Initialize
WScript.Echo "Initialize: " & objVMware.LastError
If( objVMware.LastError <> 0 ) Then
WScript.Quit
End If
' Connect
objVMware.Connect
WScript.Echo "Connect: " & objVMware.LastError
If( objVMware.LastError <> 0 ) Then
objVMware.Shutdown
WScript.Quit
End If
' Iterate over all Counter ID's on the VMware Host
WScript.Echo "Performance counter values on host " & objVMware.Server & " :"
nCounter = objVMware.GetFirstCounterID()
While ( objVMware.LastError = 0 )
strCounter = objVMware.GetCounterDescription( nCounter )
If ( objVMware.IsContextAllowed( nCounter ) ) Then
strContext = "0"
Else
strContext = "1"
End If
WScript.Echo strCounter & ":" & objVMware.GetPerfData("", nCounter, strContext)
nCounter = objVMware.GetNextCounterID()
WEnd
' Disconnect
objVMware.Disconnect
' Shutdown
objVMware.Shutdown
WScript.Echo "Ready."
Visual C# .NET sample: Show performance counters for each ESXi host and all Virtual Machines
namespace VMwareDemo
{
class VMwareDemo
{
[STAThread]
static void Main(string[] args)
{
AxNetwork.VMware objVMware = new AxNetwork.VMware(); // Create instance of COM Object
string strVirtualMachine;
System.Int32 nCounter = 0;
// Set ESXi host information
objVMware.Server = "myesxi-server"
objVMware.ServerAccount = "root";
objVMware.ServerPassword = "topsecret";
// Initialize
objVMware.Initialize();
Console.WriteLine("Initialize: " + objVMware.LastError );
if (objVMware.LastError != 0)
return;
// Connect
objVMware.Connect();
Console.WriteLine("Connect: " + objVMware.LastError );
if (objVMware.LastError != 0)
return;
// Show Counters for all VMware Virtual Machines
strVirtualMachine = objVMware.GetFirstVirtualMachine();
while (objVMware.LastError == 0)
{
// Iterate over all Counter ID's on the Virtual Machine
Console.WriteLine("\r\nCounter values for VM " + strVirtualMachine + ": ");
nCounter = objVMware.GetFirstCounterID();
while (objVMware.LastError == 0)
{
strCounter = objVMware.GetCounterDescription(nCounter);
strContext = objVMware.IsContextAllowed(nCounter) ? "0" : "1";
Console.WriteLine(" " + strCounter + ": " +
objVMware.GetPerfData(strVirtualMachine, nCounter, strContext) + " "
+ objVMware.GetCounterUnits(nCounter));
nCounter = objVMware.GetNextCounterID();
}
strVirtualMachine = objVMware.GetNextVirtualMachine();
}
// Disconnect
objVMware.Disconnect();
// Shutdown
objVMware.Shutdown();
Console.WriteLine("\nReady.");
}
}
}
You can download the full samples here.
