Contact Info

Crumbtrail

ActiveXperts.com » Network Component » Network Component Objects » Xen

ActiveXperts Network Component Xen Object

The Citrix Xen object of the ActiveXperts Network Component allows you to retrieve performance data from a Citrix Xen host and its virtual machines. The following operations are provided through the Xen interfaces:

The Xen 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 - Xen - Wake-on-LAN - Xen (Citrix)


Xen sample code

VBScript sample: Monitor a Citrix Xen host

' Create Xen and ASConstants instances
Set objXen     	   = CreateObject( "AxNetwork.Xen" )
Set objConstants       = CreateObject( "AxNetwork.ASConstants" )


' Set ESXi host information
objXen.Server = "myesxi-host"
objXen.ServerAccount	= "root"
objXen.ServerPassword = "topsecret"

' Initialize
objXen.Initialize
WScript.Echo "Initialize: " & objXen.LastError
If( objXen.LastError <> 0 ) Then
 WScript.Quit
End If

' Connect
objXen.Connect
WScript.Echo "Connect: " & objXen.LastError 
If( objXen.LastError <> 0 ) Then
  objXen.Shutdown
  WScript.Quit
End If

' Iterate over all Counter ID's on the Xen Host
WScript.Echo "Performance counter values on host " & objXen.Server & " :"
nCounter = objXen.GetFirstCounterID()
While ( objXen.LastError = 0 )
  strCounter = objXen.GetCounterDescription( nCounter )

  If ( objXen.IsContextAllowed( nCounter ) ) Then
    strContext = "0"
  Else
    strContext = "1"
  End If
     
  WScript.Echo strCounter & ":" & objXen.GetPerfData("", nCounter, strContext)
  nCounter = objXen.GetNextCounterID()
WEnd

' Disconnect
objXen.Disconnect 

' Shutdown
objXen.Shutdown

WScript.Echo "Ready."

Visual C# .NET sample: Show performance counters for each Xen host and all Virtual Machines

namespace XenDemo
{
  class XenDemo
  {

    [STAThread]
    static void Main(string[] args)
    {
    AxNetwork.Xen objXen = new AxNetwork.Xen(); // Create instance of COM Object
    string strVirtualMachine;
    System.Int32 nCounter = 0;

    // Set ESXi host information
    objXen.Server = "myesxi-server"
    objXen.ServerAccount = "root";
    objXen.ServerPassword = "topsecret";

    // Initialize
    objXen.Initialize();
    Console.WriteLine("Initialize: " + objXen.LastError );
    if (objXen.LastError != 0) 
    return;

    // Connect
    objXen.Connect();
    Console.WriteLine("Connect: " + objXen.LastError );
    if (objXen.LastError != 0)
    return;


    // Show Counters for all Xen Virtual Machines
    strVirtualMachine = objXen.GetFirstVirtualMachine();
    while (objXen.LastError == 0)
    {
      // Iterate over all Counter ID's on the Virtual Machine
      Console.WriteLine("\r\nCounter values for VM " + strVirtualMachine + ": ");
      nCounter = objXen.GetFirstCounterID();
      while (objXen.LastError == 0)
      {
        strCounter = objXen.GetCounterDescription(nCounter);
        strContext = objXen.IsContextAllowed(nCounter) ? "0" : "1";
        Console.WriteLine("   " + strCounter + ": " + 
        objXen.GetPerfData(strVirtualMachine, nCounter, strContext) + " " 
          + objXen.GetCounterUnits(nCounter));
        nCounter = objXen.GetNextCounterID();
      }
      strVirtualMachine = objXen.GetNextVirtualMachine();
    }

    // Disconnect
    objXen.Disconnect();

    // Shutdown
    objXen.Shutdown();

    Console.WriteLine("\nReady.");
    }
  }
}

You can download the full samples here.