PowerCLI

 View Only
  • 1.  VMware vSphere PowerCLI alternative

    Posted Nov 15, 2011 10:00 AM

    Hi All,

    I had to develop an application that gets ESXi Server performance metrics like CPU usage, memory, network, disk read/write, etc.

    I know a solution for this using VMware vSphere PowerCLI (vmware.vim.dll), the problem is every user have to download and install PowerCLI in order to use my application.

    Is there any alternative solution solution for this? so that I can re-write my application wihtout using PowerCLI?

    Thanks,

    Kishore

    ZENQA

    sample code when we use Power CLI

    VimClient

    client = new VimClient();

    client.Login("https://10.10.1.1/sdk", @"test\admin", "password");

    NameValueCollection filter = new NameValueCollection();

    IList<EntityViewBase> esxList =  client.FindEntityViews(typeof(HostSystem), null, null, null);

    foreach (HostSystem host in esxList)

    {

    string hostname =  host.Name.ToString();

    string version =  host.Summary.Config.Product.FullName.ToString();

    MessageBox.Show(hostname);

    MessageBox.Show(version);

    }



  • 2.  RE: VMware vSphere PowerCLI alternative

    Posted Nov 15, 2011 12:10 PM

    You could use c# with the SDK.

    or

    You could setup a server with a share that runs your script(s) on a schedule and dumps the output in html format to the shre for the users to access

    or

    You could setup IIS/Apache and serve the output of your scripts via a webpage (maybe use accessing the page as a trigger for the script to run if the last run was more than 10min ago)

    I realise that the last two are not desktop apps but they are possible alternatives.

    Regards,

    Ryan



  • 3.  RE: VMware vSphere PowerCLI alternative

    Posted Nov 15, 2011 12:13 PM

    HI Ryan,

    thanks for the Quick response.

    could you provide me some sample code or usefull links for "You could use c# with the SDK."

    Thanks,

    Kishore



  • 4.  RE: VMware vSphere PowerCLI alternative

    Posted Nov 15, 2011 12:16 PM

    I can't give sample code as I haven't delved into the depths of the SDK with c#.

    But I would start here:

    http://www.vmware.com/support/developer/vsphere_mgmt_sdk/index.html

    There are samples in the download as well as the documentation.

    Hope that helps.


    Ryan



  • 5.  RE: VMware vSphere PowerCLI alternative

    Posted Nov 15, 2011 12:18 PM

    Thanks Ryan. I will review the samples.

    Thanks again for your help.



  • 6.  RE: VMware vSphere PowerCLI alternative

    Posted Nov 15, 2011 05:13 PM

    There are indeed samples in the Web Services.

    This StackOverflow post has some good pointers how to use this with C# from Visual Studio 2010 and in vSphere 5.

    For you performance data assignment you can have a look at my Datastore usage statistics post.

    You could use the Get-Stat2 function as a prototype for using the QueryPerf method.