ESXi 5.5 主机具有多个 HostDateTimeSystem 条目

ESXi 5.5 主机具有多个 HostDateTimeSystem 条目

我最近一直在尝试审核我的一些主机上的时间偏差。使用 PowerCLI,我发现了一些引用 ConfigManager.DateTimeSystem 来获取 ESXi 主机日期时间的脚本。但是,一些主机似乎有 2 个时间条目/2 个 HostDateTimeSystem 属性。有时它们相同,有时它们不同。

主机都是ESXi 5.5。

使用:Get-View -ViewType HostSystem -Property Name,ConfigManager.DateTimeSystem | 排序名称 | 选择名称,@{Name="Current VMHostTime";Expression={(Get-View $_.ConfigManager.DateTimeSystem)}}

Current VMHost Time

7/9/2014 3:55:20 PM

{7/9/2014 3:40:57 PM, 7/9/2014 3:55:20 PM}   <------  Two entries at different times

7/9/2014 3:55:20 PM

7/9/2014 3:55:20 PM

7/9/2014 3:55:20 PM

7/9/2014 3:55:20 PM

{7/9/2014 3:55:20 PM, 7/9/2014 3:42:07 PM}

7/9/2014 3:55:20 PM

7/9/2014 3:55:20 PM

7/9/2014 3:43:16 PM

7/9/2014 3:40:39 PM

7/9/2014 3:41:26 PM

{7/9/2014 3:42:07 PM, 7/9/2014 3:55:20 PM}

7/9/2014 3:43:29 PM

7/9/2014 3:42:37 PM

7/9/2014 3:41:43 PM

7/9/2014 3:42:43 PM

7/9/2014 3:41:25 PM

{7/9/2014 3:40:58 PM, 7/9/2014 3:55:21 PM}

删除实际的日期格式后,我看到以下内容:

当前 VMHost 时间

VMware.Vim.HostDateTimeSystem

{VMware.Vim.HostDateTimeSystem, VMware.Vim.HostDateTimeSystem}   <--- Two entries for the host time???

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

{VMware.Vim.HostDateTimeSystem, VMware.Vim.HostDateTimeSystem}

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

{VMware.Vim.HostDateTimeSystem, VMware.Vim.HostDateTimeSystem}

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

VMware.Vim.HostDateTimeSystem

{VMware.Vim.HostDateTimeSystem, VMware.Vim.HostDateTimeSystem}

有人知道为什么/如何有这么多主持人有 2 个时间条目吗?是否可以纠正这个问题,以便我们可以确定主持人设置为单个确定时间?

答案1

我找不到显示多个日期的 ESXi 主机。您能发布整个脚本吗?

下面是一个 PowerCLI 脚本,用于显示工作站、vcenter 和 ESXi 主机之间的时间偏差。我很好奇地想看看带有多个时间戳的主机的输出:

Clear-Host
$ErrorActionPreference = "Continue"
$DebugPreference = "SilentlyContinue"
$VerbosePreference = "SilentlyContinue"

@"
## get_TIMEDRIFT.ps1 ##########################################################
Usage:        powershell -ExecutionPolicy Bypass -File ./get_TIMEDRIFT.ps1

Version:      1.0 (20140915)

Purpose:      Quickly Display time-drift between Workstation, vCenter, and ESXi
              hosts.  For the purpose of finding ESXi hosts which can cause
              issues if VMs are set to sync time through VMware Tools.
              vCAC/IAAS servers will not work propertly if not in sync with SSO

Requirements: Windows Powershell and running on machine with VI Tools/powercli

History:      09/15/2014  -  Created

###############################################################################
"@

## Virtual Center Server to test for time-drift against.
$VCServer = "VCEN.TEST.LOCAL"

## If running PS1 script from Powershell instead of PowerCLI, load vcen snap-in
$SIval = Get-PSSnapin -Name VMware.VimAutomation.Core `
                      -ErrorAction SilentlyContinue
if (($SIval) -eq $null) { Add-PSSnapin VMware.VimAutomation.Core }

## Logon to vCenter Server, will prompt for name/password if not saved.
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore `
                          -Scope Session `
                          -Confirm:$false
$VC = Connect-VIServer $VCServer
Write-Output "Connected to '$($VC.Name):$($VC.port)' as '$($VC.User)'"

## Get vCenter and LocalSystem timestamps and drift
    # get LocalSystem time
    $_localtime = Get-Date
    $_localtimeUTC = $_localtime.ToUniversalTime()
    # get vCenter time
    $_vctime = $VC.ExtensionData.ServerClock
    $_vctimeUTC = $_vctime.ToUniversalTime() 
    # determine time drift between LocalSystem and vCenter
    $_localdrift = ($_localtimeUTC - $_vctimeUTC).duration()


## Loop through ESX hosts writing output for each
$vmhosts = Get-VMHost
foreach($esx in $vmhosts){
    $esxview = Get-View -viewtype "HostSystem" -Filter @{"Name" = $esx.Name}
    $esxdatetimesystem = $esxview.configmanager.datetimesystem
    $_remote = Get-View -Id $esxdatetimesystem
    $_remotetime = $_remote.QueryDateTime()
    $_remotetimeUTC = $_remotetime.ToUniversalTime()
    $_vctime = $VC.ExtensionData.ServerClock
    $_vctimeUTC = $_vctime.ToUniversalTime()
    $_remotedrift = ($_remotetimeUTC - $_vctimeUTC).duration()
    Write-Output "  $esx Time drift from vCenter in minutes:: '$($_remotedrift.Totalminutes)'"
    }

## Ouput timestamps for Local Workstation, and vCenter Server
Write-Output "  vCenter Server UTC:: $_vctime"
Write-Output "  Workstation (Actual | UTC):: $_localtime | $_localtimeUTC"
Write-Output "  Local workstation Time drift from vCenter in minutes:: '$($_localdrift.Totalminutes)'"

## Disconnect user from vCenter Server
Write-Output "Disconnecting '$($VC.User)' from '$($VC.Name):$($VC.port)'"
Disconnect-VIServer $VC -Confirm:$false

以下为示例输出:

Connected to 'VCEN.TEST.LOCAL:443' as 'TEST\FMLast'
  192.168.15.149 Time drift from vCenter in minutes:: '10280.9866862833'
  192.168.15.159 Time drift from vCenter in minutes:: '10281.0125832833'
  192.168.15.167 Time drift from vCenter in minutes:: '10281.0392954333'
  192.168.15.168 Time drift from vCenter in minutes:: '10281.0690222667'
  192.168.15.26 Time drift from vCenter in minutes:: '10281.0986537667'
  192.168.15.24 Time drift from vCenter in minutes:: '10281.1276888833'
  192.168.15.25 Time drift from vCenter in minutes:: '10281.1569679333'
  192.168.15.22 Time drift from vCenter in minutes:: '10281.1863135333'
  192.168.15.27 Time drift from vCenter in minutes:: '10281.2183166667'
  192.168.15.23 Time drift from vCenter in minutes:: '10281.246763'
  vCenter Server UTC:: 09/08/2014 16:38:04
  Workstation (Actual | UTC):: 09/15/2014 15:59:01 | 09/15/2014 19:59:01
  Local workstation Time drift from vCenter in minutes:: '10280.9408839317'
Disconnecting 'TEST\FMLast' from 'VCEN.TEST.LOCAL:443'

相关内容