Automation

 View Only
Expand all | Collapse all

Catch failed vmotions

  • 1.  Catch failed vmotions

    Posted Oct 08, 2015 10:50 PM

    I would like to catch failed vmotions - typical err is, "

    The vMotion migrations failed because the ESX hosts were not able to connect over the vMotion network. "

    How shall i modify below ? thanks

    Function Get-MotionDuration {

        $events = Get-VIEvent -Start (Get-Date).AddDays(-7)

        $relocates = $events |

            where {$_.GetType().Name -eq "TaskEvent" -and $_.Info.DescriptionId -eq "VirtualMachine.migrate" -or $_.Info.DescriptionId -eq "VirtualMachine.relocate"}

        foreach($task in $relocates){

            $tEvents = $events | where {$_.ChainId -eq $task.ChainId} |

                Sort-Object -Property CreatedTime

            if($tEvents.Count){

                New-Object PSObject -Property @{

                    Name = $tEvents[0].Vm.Name

                    Type = &{if($tEvents[0].Host.Name -eq $tEvents[-1].Host.Name){"svMotion"}else{"vMotion"}}

                    StartTime = $tEvents[0].CreatedTime

                    EndTime = $tEvents[-1].CreatedTime

                    Duration = New-TimeSpan -Start $tEvents[0].CreatedTime -End $tEvents[-1].CreatedTime

                SourceHost = $tEvents[0].Host.Name

                DestinationHost = $tEvents[-1].Host.Name

                }

            }

        }

    }

    Connect-VIServer MyViServer –User Administrator –Password “Pa$$w0rd”

    Get-MotionDuration | FT -AutoSize



  • 2.  RE: Catch failed vmotions

    Posted Oct 08, 2015 11:28 PM

    Hi

    Is it working without script?

    Venkat



  • 3.  RE: Catch failed vmotions

    Posted Oct 09, 2015 07:26 AM

    Sorry what u mean here ?