Automation

 View Only
  • 1.  which nic is my vm using ?

    Posted Mar 10, 2011 09:34 AM

    hi - is there a way to get a list of vm's  and to identify the pNIC that the vm traffic is going through.  I am using 'route based on originating port id' for the load balancing method and am interested to see how many vm's are using each of the active physical uplinks on the vswitch

    thanks



  • 2.  RE: which nic is my vm using ?

    Posted Mar 10, 2011 12:27 PM

    Hi,

    if you are using vsphere4 try to use "esxtop" and press "n" to view network-device relations, I can currently not verify - only ESX 3.x around me at the customers' playgrounds and my lab is out of reach. To get a list with correlated NICs is some scripting work then, but maybe there is a PowerCLI-way, too?

    Source: http://blogs.vmware.com/networking/2009/04/which-nic-is-my-vm-using-load-balancing-visibility-with-vsphere.html

    Regards

    Michael



  • 3.  RE: which nic is my vm using ?

    Posted Mar 11, 2011 07:43 AM

    HI michael thanks for the info -  i was aware of the esxtop method too in vsphere - not sur eits the same in VI3.  I have been looking for the information using powershell but have been unable to find out how to get it - does anybody in the community know ? Im not sure whether i should be looking at the VM, Host or Network values in order to find it



  • 4.  RE: which nic is my vm using ?

    Posted Mar 11, 2011 08:14 AM

    LucD might have some info on this, which may inspire you... http://www.lucd.info/2010/12/03/hitchhikers-guide-to-get-esxtop-part-1/

    /Rubeck



  • 5.  RE: which nic is my vm using ?

    Posted Mar 11, 2011 05:10 PM

    hi rubeck - thats great - i used the information and have tried to put a script together to go through each VM in a cluster and report HostName, VMName and Uplink.  WHen running however i get the correct number of VM's and Uplink information, but my Hostnames are all the same (VMLON014) - should be a mic of VMLON013 and VMLON014. Something wrong with the nesting i think - could anyone advise me how to reformat - script attached



  • 6.  RE: which nic is my vm using ?
    Best Answer

    Posted Mar 11, 2011 07:29 PM

    Your foreach loops were not correct.

    Try it perhaps like this

    #Define some variables 
    $vcServer
    = "xxxxx"
    $cluster = "DEV_Cluster"
    $esxcred
    = import-pscredential -Path D:\VMwebsite\Vmware\password\ESX.enc.xml $vccred = import-pscredential -Path D:\VMwebsite\Vmware\password\VCentre.enc.xml $filelocation = "C:\Myscripts\Scripts\VMUplinks.csv" $Report = @() #Connect to vCenter
    Connect-VIServer $vcServer -Credential $vccred | Out-Null
    #
    Connect to ESX hosts in cluster
    foreach ($esx in Get-Cluster $cluster | Get-VMHost) {     Connect-VIServer $esx -Credential $esxCred   
    #Retrieve the esxcli instances and loop through them
        foreach($esxcli in (Get-EsxTop -CounterName netport)) {         $NetworkInfo = "" | select-Object HostName , VMName , Uplink
           
    $NetworkInfo.HostName = $esx.Name         $NetworkInfo.VMName = $esxcli.ClientName         $NetworkInfo.Uplink = $esxcli.TeamUplink         $Report += $NetworkInfo
        } #Disconnect from ESX host
        Disconnect-VIServer $esx.name -Confirm:$false
    } $Report | Export-CSV $filelocation
    #
    Disconnect from vCenter
    Disconnect-VIServer $vcServer -Confirm:$false | Out-Null


  • 7.  RE: which nic is my vm using ?

    Posted Mar 16, 2011 10:19 AM

    excellent - thanks everybody for the assistance