VMware Cloud Community
vespavbb
Enthusiast
Enthusiast
Jump to solution

Get-EsxCli -VMHost NIC Stats

Hello,

I look for some helpfull Powershell esxcli commands, maybe you can help me

 

- I want to receive the host vmnics crc error and the send and received counter.

$esxhost = "esx01"
$esxcli = Get-EsxCli -VMHost (Get-VMHost $esxhost) -V2

$esxcli.network.nic.stats???

maybe an arry of only connected vmnics with some more  infos like crc error, reveiv and send counter

 

- I want to up and down a certian vmnic over powershell esxcli command

$esxhost = "esx01"
$esxcli = Get-EsxCli -VMHost (Get-VMHost $esxhost) -V2

$esxcli.network.nic.down???

 

thank you

VCP4,VCP5,VCP6,VCP7,VCP8
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

To receive those counters, you could do

$esxName = 'esx01'

$esxcli = Get-EsxCli -VMHost $esxName -V2
$esxcli.network.nic.list.Invoke() |
ForEach-Object -Process {
    $esxcli.network.nic.stats.get.Invoke(@{nicname=$_.Name}) |
    Select @{N='VMHost';E={$esxcli.VMHost.Name}},
        NICName,PacketsReceived,PacketsSent,ReceiveCRCerrors
}

To up/down a specific NIC you can do

$nicName = 'vmnic0'

$esxcli.network.nic.down.Invoke(@{nicname=$nicName})
$esxcli.network.nic.up.Invoke(@{nicname=$nicName})

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

To receive those counters, you could do

$esxName = 'esx01'

$esxcli = Get-EsxCli -VMHost $esxName -V2
$esxcli.network.nic.list.Invoke() |
ForEach-Object -Process {
    $esxcli.network.nic.stats.get.Invoke(@{nicname=$_.Name}) |
    Select @{N='VMHost';E={$esxcli.VMHost.Name}},
        NICName,PacketsReceived,PacketsSent,ReceiveCRCerrors
}

To up/down a specific NIC you can do

$nicName = 'vmnic0'

$esxcli.network.nic.down.Invoke(@{nicname=$nicName})
$esxcli.network.nic.up.Invoke(@{nicname=$nicName})

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
vespavbb
Enthusiast
Enthusiast
Jump to solution

perfect! Thanks Luc

 

new layout looks good here!

VCP4,VCP5,VCP6,VCP7,VCP8
0 Kudos
vespavbb
Enthusiast
Enthusiast
Jump to solution

ah one more thing.

 

How can I reset a certain stat of a certian nic?

thanks luc

VCP4,VCP5,VCP6,VCP7,VCP8
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik, there is no esxcli command to do that.

When you reboot the ESXi node, the counters are reset.

Another method that is used by some is to unload/load the NIC driver with the vmkload_mod command.
Note that this will interrupt your connection!


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference