Hi All,
We are getting failed and success vMotion event in our vCenter. the failed ones VMs are facing performance issues.
would like to see if any one have created script of vMotion events including failed one , succeeded ones. it need to be scheduled and send as email report in html or csv format.
Thanks in Advance.
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 “XXXXXX
”
Get-MotionDuration
| FT
-AutoSize
Thanks for response Vijay,
this is something already happened vMotion events.
I was looking for something vMotion events both failed and succeeded one , it should send them as scheduled report in html format.