VMware Cloud Community
CRad14
Hot Shot
Hot Shot
Jump to solution

Get-Stat for the last week is null

For some reason, my get-stat is coming up null for the last week and I am not sure what is going on. vCenter and Hosts were just patched and rebooted as well.

Realtime is fine

get-stat -stat mem.usage.average -entity $vm -realtime

pastedImage_0.png

Just the normal command is fine.......but it only displays stuff from last month and before.....which I thought was odd

get-stat -stat mem.usage.average -entity $vm

pastedImage_1.png

But when I try to do last 7 days it is null

get-stat -stat mem.usage.average -entity $vm  -start (get-date).adddays(-7) -finish (get-date) |GM

pastedImage_2.png

I use this same script several other places and it all works fine, I am just trying to figure out what might this different.

Thanks

Conrad www.vnoob.com | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! 🙂
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I assume in that case you are using a SQL Server DB in that case?

If yes, you can use the SQL Enterprise Manager to check the status of the scheduled jobs marked with 'Stats Rollup'
I suspect something might be wrong with at least one of those jobs.

As an alternative, you can use a function from the PowerCLI Reference book.

function Get-AggregationJob {

<#

.SYNOPSIS Returns the SQL jobs that perform vCenter statistical data aggregation

.DESCRIPTION The function takes all SQL jobs in the “Stats Rollup” category and returns key data for each of the jobs

.NOTES

   Source: Automating vSphere Administration

   Authors: Luc Dekens, Jonathan Medd, Brian Graf, Alan Renouf, Glenn Sizemore, Andrew Sullivan

.PARAMETER SqlServer Name of the SQL server where the vSphere database is hosted

.EXAMPLE Get-AggregationJob ‘serverA’

#>

    param( [parameter(mandatory = $true,

             HelpMessage = 'Enter the name of the vCenter SQL server')]

           [string]$SqlServer

         )

   

    $SMO = ‘Microsoft.SqlServer.SMO’

    [System.Reflection.Assembly]::LoadWithPartialName($SMO) | Out-Null

    $SMOSrv = ‘Microsoft.SqlServer.Management.Smo.Server’

    $sqlSRv = New-Object ($SMOSrv) $sqlServer

   

    $sqlSrv.JobServer.Jobs | Where-Object {$.Category -eq 'Stats Rollup'} | Foreach-Object {

         $object = [ordered]@{

              Name = $.Name

              Description = $.Description

              LastRun = $.LastRunDate

              NextRun = $.NextRunDate

              LastRunResult = $.LastRunOutcome

              'Schedule(s)' = $.JobSchedules | %{$.Name}

         }

         New-Object PSObject -Property $object

    }

}


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Looks like the aggregation jobs on the vCenter might be failing.
Are you running a VCSA or vCenter on a Windows server?


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

0 Kudos
CRad14
Hot Shot
Hot Shot
Jump to solution

LucD   It is a windows vCenter

I haven't found anything googling how to fix potential aggregation jobs.. Thoughts?

Conrad www.vnoob.com | @vNoob | If I or anyone else is helpful to you make sure you mark their posts as such! 🙂
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I assume in that case you are using a SQL Server DB in that case?

If yes, you can use the SQL Enterprise Manager to check the status of the scheduled jobs marked with 'Stats Rollup'
I suspect something might be wrong with at least one of those jobs.

As an alternative, you can use a function from the PowerCLI Reference book.

function Get-AggregationJob {

<#

.SYNOPSIS Returns the SQL jobs that perform vCenter statistical data aggregation

.DESCRIPTION The function takes all SQL jobs in the “Stats Rollup” category and returns key data for each of the jobs

.NOTES

   Source: Automating vSphere Administration

   Authors: Luc Dekens, Jonathan Medd, Brian Graf, Alan Renouf, Glenn Sizemore, Andrew Sullivan

.PARAMETER SqlServer Name of the SQL server where the vSphere database is hosted

.EXAMPLE Get-AggregationJob ‘serverA’

#>

    param( [parameter(mandatory = $true,

             HelpMessage = 'Enter the name of the vCenter SQL server')]

           [string]$SqlServer

         )

   

    $SMO = ‘Microsoft.SqlServer.SMO’

    [System.Reflection.Assembly]::LoadWithPartialName($SMO) | Out-Null

    $SMOSrv = ‘Microsoft.SqlServer.Management.Smo.Server’

    $sqlSRv = New-Object ($SMOSrv) $sqlServer

   

    $sqlSrv.JobServer.Jobs | Where-Object {$.Category -eq 'Stats Rollup'} | Foreach-Object {

         $object = [ordered]@{

              Name = $.Name

              Description = $.Description

              LastRun = $.LastRunDate

              NextRun = $.NextRunDate

              LastRunResult = $.LastRunOutcome

              'Schedule(s)' = $.JobSchedules | %{$.Name}

         }

         New-Object PSObject -Property $object

    }

}


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

0 Kudos