VMware Cloud Community
vmk2014
Expert
Expert
Jump to solution

When was the last time ESXi 5.5 Host re-booted and total no of times re-booted in last 1 month.

Hi Team,

      We have more than 100 ESXi host in our environment and we need to find out when was the last time ESXi Host re-booted and  no of times re-booted in last 1 month.Please help me to get the power cli script. Any help will be much appreciated.Thanks

Thanks

vmware tech

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ok, so the ESXi nodes were hard booted (as if you pushed the power button).

That is probably why the task for a scheduled reboot doesn't turn up.

Do you see the ESXi nodes with the following script ?

It shows the events where the connection to a host was lost.

$start = (Get-Date).AddDays(-7)

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |

where{$_ -is [VMware.Vim.HostConnectionLostEvent]} |

Select CreatedTime,@{N='VMHost';E={$_.Host.Name}}


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$start = (Get-Date).AddMonths(-1)

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |

  Where-Object {$_ -is [VMware.Vim.ExtendedEvent] -and $_.EventTypeId -match '^com.vmware.vcIntegrity.RebootHostComplete'} |

Group-Object -Property {$_.Host.Name} |

Select @{N='ESXi';E={$_.Name}},

  @{N='NumberOfReboot';E={$_.group.Count}},

  @{N='Last Reboot';E={$_.Group | Sort-Object -Property CreatedTime -Descending |

      Select -First 1 -ExpandProperty CreatedTime}}


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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

Thanks LucD !!. But when I execute the script the console doesn't show any output.

Thanks

vmware tech

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try this variation

$start = (Get-Date).AddMonths(-1)

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |

  Where-Object {$_ -is [VMware.Vim.TaskEvent] -and $_.Info.Name -eq 'RebootHost_Task'} |

Group-Object -Property {$_.Host.Name} |

Select @{N='ESXi';E={$_.Name}},

  @{N='NumberOfReboot';E={$_.group.Count}},

  @{N='Last Reboot';E={$_.Group | Sort-Object -Property CreatedTime -Descending |

      Select -First 1 -ExpandProperty CreatedTime}}


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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

    No luck still no output. PFA. Thanks

vmware tech

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Do you see any entries under Task and Events when an ESXi host is rebooted ?

What does the Event and/or Task say ?


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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

   There was Storage issues during the weekend and all the Host (6) in a cluster, we re-booted forcibly from DRAC but i don't find in VC task and events. Any clue ?

Thanks

VMware tech

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, so the ESXi nodes were hard booted (as if you pushed the power button).

That is probably why the task for a scheduled reboot doesn't turn up.

Do you see the ESXi nodes with the following script ?

It shows the events where the connection to a host was lost.

$start = (Get-Date).AddDays(-7)

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start $start |

where{$_ -is [VMware.Vim.HostConnectionLostEvent]} |

Select CreatedTime,@{N='VMHost';E={$_.Host.Name}}


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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

   I can see the script

CreatedTime                             VMHost

-----------                             ------

3/9/2015 5:50:01 PM                     VM1.48.ka.corp..com

3/9/2015 4:43:01 PM                     VM21.ka.corp..com

3/9/2015 3:52:00 PM                    VM3.ka.corp.com

Thanks

vmware tech

0 Kudos
vmk2014
Expert
Expert
Jump to solution

LuCD,

  Does this mean these Host are forcibly re-booted ?

Thanks

VMware Tech

0 Kudos