Hi Luc/All,
could you check the following code .this is to disable vmotion traffic on vmkernel port which is used for mangement traffic.
$cluster=read-host "provide the cluster name"
$esxi_hosts=get-cluster $cluster|get-vmhost
foreach ($esxi in $esxi_hosts)
{
$m=Get-VMHostNetworkAdapter -VMKernel -VMHost $esxi
$vmkernel=$m|Where-Object{$_.managementtrafficenabled -eq $true -and $_.vmotionenabled -eq $true}
$rem_host=$vmkernel.vmhost.name
$rem_host
$vmkernel_rem=$vmkernel.name
$vmkernel_rem
write-host "disabling vmotion traffic on" $vmkernel_rem -ForegroundColor DarkGreen
$vmkernel_rem|set-vmhostnetworkadapter -vmotionenabled $false
}
also why it is not good to use write-host command inside foreach loop.
Thnaks.
I personally would use the pipeline and avoid the temprary variables.
Something like this
$cluster=read-host "provide the cluster name"
$esxi_hosts=Get-Cluster $cluster|Get-VMHost
foreach ($esxi in $esxi_hosts)
{
Get-VMHostNetworkAdapter -VMKernel -VMHost $esxi |
Where-Object{$_.managementtrafficenabled -eq $true -and $_.vmotionenabled -eq $true} | %{
Write-Output "Disabling vMotion traffic on $($_.Name) on $($_.VMHost.Name)"
# $_ | Set-VMHostNetworkAdapter -vmotionenabled $false
}
}
The major complaint about Write-Host is that you can not redirect that output.
See Jeffrey's post Write-Host Considered Harmful
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I personally would use the pipeline and avoid the temprary variables.
Something like this
$cluster=read-host "provide the cluster name"
$esxi_hosts=Get-Cluster $cluster|Get-VMHost
foreach ($esxi in $esxi_hosts)
{
Get-VMHostNetworkAdapter -VMKernel -VMHost $esxi |
Where-Object{$_.managementtrafficenabled -eq $true -and $_.vmotionenabled -eq $true} | %{
Write-Output "Disabling vMotion traffic on $($_.Name) on $($_.VMHost.Name)"
# $_ | Set-VMHostNetworkAdapter -vmotionenabled $false
}
}
The major complaint about Write-Host is that you can not redirect that output.
See Jeffrey's post Write-Host Considered Harmful
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc this worked fine just removed the hash symbol on set command.
However conceptually i was also doing the same thing excpet there were too many variables .so what is wrong .
also how % is different from foreach.
Thnaks for your quick response .appreciate it.
The % sign is just an alias for ForEach-Object.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ThnaksLuc.
I just thought of asking one more thing related to same .
this script is created in order to have only management traffic on vmk0 and disable vmotion traffic .
but if we keep both what negative impact it will have and can it be measured .
Thnaks.
You could measure the effect of both types of network traffic.
With the net.throuhput.usage.vmotion and net.throuput.usage you should be able to determine which percentage goes to vMotion and which percentage goes to management.
And you also compare the values with the theoretical maximum you can have to check if you are using more than is available.
Note that the above metrics require statistics levels 3 and 4 respectively.
For Realtime data (the +/- past hour) both metrics should be available.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I dont find this info in configure max pdf.
However i tried something like below but that does not work
$stat = 'net.throuhput.usage.vmotion','net.throuput.usage'
$entity = Get-vmhost -Name ""
Get-Stat -Entity $entity -Stat $stat -Realtime -MaxSamples 1
also i thought of sharing something very basic to understand network bottleneck if it happens considering below .
below are two phy nicsof 20gbps each and are in active active assigned to standard switch.does it mean total bandwidth will be 40 gbps .
will traffic (combining vmotion and management )will reach 40gbps??
Those net.throughput metrics only exist for Distributed Switches it seems.
I'll have to look into that.
On your other question,
1) for incoming traffic you have no control
2) for outgoing traffic it will depend on how you configured Load Balancing on the switch
Have a look at Networking for VMware Administrators: The vSphere Standard Switch
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference