PowerCLI: Enable Beacon Probing or Link Status Only on a vSwitch


In some cases you need to troubleshoot your network infrastructure from your vSphere hosts all the way back into your core network. In this case you can enable beacon probing and watch your log files for issues. But before I continue to show how to enable beacon probing I want to share some information about what beacon probing is and when is it recommended to be used :

Beacon Probing is a network failover detection mechanism that sends out and listens for beacon probes on all NICs in the team and uses this information, in addition to link status, to determine link failure.

This detects failures, such as cable pulls and physical switch power failures, but not configuration errors, such as a physical switch port being blocked by spanning tree or misconfigured to the wrong VLAN or cable pulls on the other side of a physical switch that are not detected by link status alone.
Beacon probing is most useful to detect failures in the closest switch to the ESX hosts, where the failure does not cause a link-down event for the host.

You can use beaconing with 2 NICs, but this only detects failures on the immediate uplink. If you really want to detect upstream failures, use beaconing with 3 or more NICs.
When there are only two NICs in service and one of them loses connectivity it is unclear which NIC needs to be taken out of service as both no longer receive beacons. Using at least 3 NICs in such a team allows for N – 2 failures where N is the number of NICs in the team before getting into an ambiguous situation.

Source:KB1005577

More information about beacon probing can be found here: http://blogs.vmware.com/networking/ and in part 4 of the great vSwitch debate: http://kensvirtualreality.wordpress.com/2009/04/10/the-great-vswitch-debate-part-4/

You can enable beacon probing on all your vSphere hosts on every vSwitch and every portgroup via the following for foreach loop:

foreach($esx in (Get-VMHost)){ 
    Get-VirtualSwitch -VMHost (Get-VMHost $esx) | %{Get-NicTeamingPolicy -VirtualSwitch $_ | ` 
    Set-NicteamingPolicy -NetworkFailoverDetectionPolicy BeaconProbing}  
}

if you want to enable beacon probing on one vSphere host and on a specific vSwitch you can use the following function:

Function Enable-BeaconProbing{
param(
    [parameter(Mandatory = $true)]
    [string[]]$vmHost,
    [parameter(Mandatory = $true)]
    [string[]]$vSwitch
)

Get-NicTeamingPolicy -VirtualSwitch (Get-VirtualSwitch -VMHost (Get-VMHost $vmHost) -Name "$vSwitch") | `
Set-NicteamingPolicy -NetworkFailoverDetectionPolicy BeaconProbing
}

Enable-BeaconProbing esx1.ict-freak.local vSwitch0

the following output will be generated:

image

To disable beacon probing on all your vSphere hosts you can run the following foreach loop:

foreach($esx in (Get-VMHost)){ 
    Get-VirtualSwitch -VMHost (Get-VMHost $esx) | %{Get-NicTeamingPolicy -VirtualSwitch $_ | ` 
    Set-NicteamingPolicy -NetworkFailoverDetectionPolicy LinkStatus}  
}

or the following function:

Function enable-LinkStatus{
param(
    [parameter(Mandatory = $true)]
    [string[]]$vmHost,
    [parameter(Mandatory = $true)]
    [string[]]$vSwitch
)

Get-NicTeamingPolicy -VirtualSwitch (Get-VirtualSwitch -VMHost (Get-VMHost $vmHost) -Name "$vSwitch") | `
Set-NicteamingPolicy -NetworkFailoverDetectionPolicy LinkStatus
}

Enable-LinkStatus esx1.ict-freak.local vSwitch0

output:

image

If you only want to find vSphere hosts whit beacon probing disabled, you can run the following script written by Luc Dekens (@LucD22):

############################################################################# 
# 
# Check if Beacon Probing is enabled 
# Source: http://poshcode.org/?show=1314 (@LucD22) 
# 
############################################################################# 

$esxhosts = get-view -ViewType hostsystem 

foreach($esx in $esxhosts){ 
$net = Get-View $esx.configmanager.networksystem 
$vSwitches = @(%{$net.NetworkConfig.vSwitch | select Name}) 
$esxhosts = $esx.name 

    foreach($vSwitch in $vSwitches){ 
        $vSwitch = $vSwitch.Name 
        # Check if vSwitch has Beacon Probing selected 
        $esx.Config.Network.Vswitch | where {$_.Name -eq $vSwitch} | %{ 
            if(-not $_.Spec.Policy.NicTeaming.FailureCriteria.CheckBeacon){ 
                "$esxhosts : Beacon Probing should be enabled on the vSwitch $vSwitch first" | Out-Host 
            } 
        } 
    } 
}

 

Source:

Link:

VMware KB http://kb.vmware.com/
VMware http://blogs.vmware.com/networking/
Poshcode http://poshcode.org/?show=1314
About these ads

One Response to PowerCLI: Enable Beacon Probing or Link Status Only on a vSwitch

  1. It would be cool if this was doing it on distributed switches. I only see this being done on virtual switches. Even so, its a nice article on how to automate it. Thanks for sharing!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,211 other followers

%d bloggers like this: