Could someone help me get the ring buffer values from all the ESXi hosts for all the vmnics? I'm trying to get the hostname, vmnic name and its corresponding rx buffer values (both current and preset).
foreach ($ESXi in $Hosts) {
$esxcli = Get-EsxCli -VMHost $ESXi -V2
foreach ($vmnic in $EsxCli.network.nic.list.Invoke()) {
ForEach-Object -Process {
$EsxCli.network.nic.ring.current.get.Invoke(@{nicname = $vmnic.Name})
$EsxCli.network.nic.ring.preset.get.Invoke(@{nicname = $vmnic.Name})
}
}
}
Although the above code gives me the values, it still produces errors.
Most of the time this error indicates in this case that the retrieval of the value is not supported by the NIC.
You will have to check the log to make sure.
If you run it like this, that error won't stop your script
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
Select @{N='VMHost';E={$esx.Name}},
@{N='vmnic';E={$_.Name}},
@{N='Current';E={$esxcli.network.nic.ring.current.get.Invoke(@{nicname = $_.Name}).RX}},
@{N='Preset';E={$esxcli.network.nic.ring.preset.get.Invoke(@{nicname = $_.Name}).RX}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Most of the time this error indicates in this case that the retrieval of the value is not supported by the NIC.
You will have to check the log to make sure.
If you run it like this, that error won't stop your script
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
Select @{N='VMHost';E={$esx.Name}},
@{N='vmnic';E={$_.Name}},
@{N='Current';E={$esxcli.network.nic.ring.current.get.Invoke(@{nicname = $_.Name}).RX}},
@{N='Preset';E={$esxcli.network.nic.ring.preset.get.Invoke(@{nicname = $_.Name}).RX}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
HI Luc,
Thank you so mutch for your script. It was very helpfull for me.
Is there any option to modify it to "set" ring buffer only for host in specific cluster?
When i try something like this
$esxes = Get-VMhost |where {$_.Name -like 'hosts in first cluster*'}
ForEach ($esx in $esxes) {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
$esxcli.network.nic.ring.current.set(@{nicname = $_.Name} -r 8192)
}
the command $esxcli.network.nic.ring.current.set(@{nicname = $_.Name} -r "8192") is underlined as error.
I made this command based on your "get script" and this information:
$esxcli.network.nic.ring.current.set | nicname rx rxjumbo rxmini tx |
When you use the V2 switch, you have to use the Invoke method.
See PowerCLI 6.3 R1: Get-ESXCLI Why the V2?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you Luc,
but even though i use invoke as you stated, " $esxcli.network.nic.ring.current.set.Invoke(@{nicname = $_.Name} -r 8192) "
still got red underlined for it.
Did i make a typo in the command or what is wrong with it.
Could you please guide me about this?
Did you actually read that post I pointed to?
All the parameters need to be in a hash table, something like this for example
$esxcli.network.nic.ring.current.set.Invoke(@{nicname = $_.Name;rx=8192})
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
HI Luc,
thank you for your quick replay.
i read this article but i'm new in powershell/powercli so this is not easy for me to understand.
Could you please tell me where my logic failed?
$esxes = Get-VMhost |where {$_.Name -like 'esxhosts'}
ForEach ($esx in $esxes) {
$esxcli = Get-EsxCli -VMHost $esx -V2
$nics = ($esxcli.network.nic.list.Invoke()).Name
ForEach ($nic in $nics) {
$esxcli.network.nic.ring.current.set.Invoke(@{nicname = $nic;rx=8192})
}
}
i got output like below:
$nics = ($esxcli.network.nic.list.Invoke()).Name
ForEach ($nic in $nics) {
$esxcli.network.nic.ring.current.set.Invoke(@{nicname = $nic;rx=8192})
}
Message: EsxCLI.CLIFault.summary;
InnerText: Unable to complete Sysinfo operation. Please see the VMkernel log file for more details.: Sysinfo error: Bad parameterSee VMkernel log for details.EsxCLI.CLIFault.summary
At line:4 char:13
+ $esxcli.network.nic.ring.current.set.Invoke(@{nicname = $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], MethodFault
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.MethodFault
Message: EsxCLI.CLIFault.summary;
InnerText: Unable to complete Sysinfo operation. Please see the VMkernel log file for more details.: Sysinfo error: Bad parameterSee VMkernel log for details.EsxCLI.CLIFault.summary
At line:4 char:13
+ $esxcli.network.nic.ring.current.set.Invoke(@{nicname = $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], MethodFault
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.MethodFault
The maximum RX value is 4096.
See also KB2039495
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I understood it, but i'm refering to this VMware Knowledge Base
and according to VMware support we need to increase ring buffer to 8192 on all our affected hosts.
That is why i tried to do it via script.
Where do you see VMware saying it must be 8192 in that KB?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
We have in Vmware support opened case and they recommended to set this value in our environment.
Can you change the value to 8192 with the esxcli command on the ESXi console?
If not, perhaps ask support on how to do it.
If that works, there might be a bug in the Get-EsxCli cmdlet.t
Are they talking about a VMXNet3 adapter?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you Luc for your suggestion.
When i tried to set this value from ESX console i received error as well, but it pointed me out, that i must set TX value as well.
this is working fine now.
$esxes = Get-VMhost |where {$_.Name -like 'ESXiHosts*'}
ForEach ($esx in $esxes) {
$esxcli = Get-EsxCli -VMHost $esx -V2
$nics = ($esxcli.network.nic.list.Invoke()).Name
ForEach ($nic in $nics) {
$esxcli.network.nic.ring.current.set.Invoke(@{nicname=$nic;rx='8192';tx='8192'})
}
}
Are they talking about a VMXNet3 adapter? -- no, they stated this value for physical uplinks from ESXi hosts.
Good to hear you got it solved.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you run this script to change the ring buffer size without putting the hosts in the maintenance mode in your environment?
Thanks for share,
I added some strings to get both RX and TX.
Get-VMhost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
Select @{N='VMHost';E={$esx.Name}},
@{N='vmnic';E={$_.Name}},
@{N='RingSizeRX';E={$esxcli.network.nic.ring.current.get.Invoke(@{nicname = $_.Name}).RX}},
@{N='RingSizeTX';E={$esxcli.network.nic.ring.current.get.Invoke(@{nicname = $_.Name}).TX}}
}
@LucD
Is it also possible to only get specific vmnic results. With above script, I get all vmnics for all hosts. For example I only need to see RX TX of vmnic6 and vmnic8 in my vcenter. How can I do it?
Also is it possible run set script to change ring buffer sizes without putting hosts in maintenance mode and/or reboot hosts?
You could use a Where-clause
Get-VMhost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() |
Where-Object {$_.Name -match "^vmnic6$|^vmnic8$"} |
Select @{N='VMHost';E={$esx.Name}},
@{N='vmnic';E={$_.Name}},
@{N='RingSizeRX';E={$esxcli.network.nic.ring.current.get.Invoke(@{nicname = $_.Name}).RX}},
@{N='RingSizeTX';E={$esxcli.network.nic.ring.current.get.Invoke(@{nicname = $_.Name}).TX}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you this worked.