来自 Get-Stats 的统计对象与“-Start”参数不匹配:PowerCLI

Stats object from Get-Stats does not match the "-Start" parameter: PowerCLI

我正在编写一个脚本来提取 VM 内存膨胀和准备好汇总统计信息。我想以 5 分钟的间隔提取 24 小时的统计数据。我运行的命令是:

$datetime = Get-Date       #Get the datetime it currently is
$date = $datetime.Date     #Get just the date, starting at midnight
$interval = 5
$statType = "mem.vmmemctl.average", "cpu.ready.summation"

$vmStats = get-stat -Entity $vm -start $date.AddDays(-1) -Finish $date -MaxSamples 10000 -stat $statType -IntervalMins $interval

但是,此结果给出了一组统计数据,这些数据可以追溯到 $date(今天的午夜),但只能追溯到 一天中的当前时间, 昨天.

例如,如果 get-date returns 03/14/2018 10:43:42 AM,并且 $date 设置为 03/14/2018 12:00:00 AM,那么当开始日期为 $date.AddDays(-1) 使用的是 2018-03-13 10:30:00.000.

我不知道发生了什么。我尝试将 $date$date.AddDays(-1) 都转换为 [date][datetime],并且我还尝试将午夜值硬编码为开始日期和结束日期。最早的统计数据是基于执行 Get-Stat 的一天中的时间这一事实似乎没有任何改变。

使用 30 分钟或 2 小时间隔时不会发生这种情况。这个问题似乎只发生在 5 分钟的统计数据间隔内。我究竟做错了什么?这是 Get-Stat 的正常行为吗?

您想要的 5 分钟粒度仅适用于过去 24 小时。早于该时间的统计数据将汇总到您观察的 30 分钟间隔内(并最终进一步汇总)。

Archived stats

"are aggregations (rollups) of the real-time stats. They are aggregated at different sampling intervals and stored in the database. We follow the MRTG standard.

Past day: past day stats take the real-time stats and roll them up so that there is 1 data point for every 5 minutes. Thus, there are 12 data points per hour and 288 per day.

Past week: past week stats take the past day stats and roll them up so that there is 1 data point for every 30 minutes. Thus, there are 48 data points per day and 336 per week.

Past month: past month stats take the past week stats and roll them up so there is 1 data point per 2 hours. Thus, there are 12 data points per day and 360 per month (30-day month). Past year: past year stats take the past month stats and roll them up so there is 1 data point per day. Thus, there are 365 data points per year."