Scripts

Welcome to the Nutanix NEXT community. To get started please read our short welcome post. Thanks!

cancel
Showing results for 
Search instead for 
Did you mean: 

What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Nutanix Employee

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Hi Geoffd,

 

I am currently testing this in V1.7. 

As a workaround, you can use the Rest-API method to gather the necessary info.

 

$server = read-host "Enter the IP/FQDN"
$username = "Username"
$password = "password"
$stats = "avg_io_latency_usecs"
$Header = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+":"+$password ))}
$epoch = Get-Date -Date "01/01/1970" #dont change this line
$startdate = Get-Date '2/26/2017 10:00 AM'
$enddate = get-date '2/26/2017 11:00 AM'
[int64]$start_time = ((New-TimeSpan -Start $epoch -End $startdate).TotalMilliseconds)*1000
[int64]$end_time = ((New-TimeSpan -Start $epoch -End $enddate).TotalMilliseconds)*1000

$url = "https://${server}:9440/PrismGateway/services/rest/v1/cluster/stats/?metrics=$stats&startTimeInUsecs=$start_time&endTimeInUsecs=$end_time&intervalInSecs=60"

$out = Invoke-RestMethod -Uri $url -Headers $Header
$out.statsSpecificResponses | ft
$out.statsSpecificResponses.values

 

Regards,

Sandeep MP

Nutanix Employee

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Hi Geoffd,

 

This issue is fixed in V1.7.5(AOS 4.7.5)

 

Regards,

Sandeep MP

Adventurer

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Thank you this does work!

Adventurer

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Just one more point.  As I was finally getting lists of stats and putting them into CSV format, I found that the IOPS stats I was getting from the cluster and the hosts from the num_iops metric seemed to have no relation to the actual number for the same time period I could see in the Prism console.   I believe the problem is that the actual timeframe is supposed to be UTC internally, is that right?   So the $epoch should be 1/1/1970 0:00 UTC?   I think in my case its defaulting to US Central time, which is 1/1/1970 6:00 UTC.  for example if I run

PS > $epoch = Get-date -date "01/01/1970"

PS > $epoch.ToUniversalTime()

Thursday, January 1, 1970 6:00:00 AM

 

I think this is throwing off my results.  Do you agree?

Adventurer

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

I have tested and confirmed that the start and end datetimes MUST be converted to UTC or else you will get an unexpected time offset

 

$epoch = Get-Date -Date "01/01/1970" #dont change this line
$startdate = (Get-Date '2/26/2017 10:00 AM').ToUniversalTime()
$enddate = (Get-Date '2/26/2017 11:00 AM').ToUniversalTime()
[int64]$start_time = ((New-TimeSpan -Start $epoch -End $startdate).TotalMilliseconds)*1000
[int64]$end_time = ((New-TimeSpan -Start $epoch -End $enddate).TotalMilliseconds)*1000

 

All good now, and rest stats correspond with Console CSV export data

Scout

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

What specifically worked? Did you upgrade to a version of NOS higher than 4.7.5 or did you get the Rest-API workaround working?

 

 

Adventurer

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

I'm constrained not to upgrade atm, so I'm using the rest API.  However I believe the UTC conversion would apply in either case.  Would be Super Helpful if the Get-NTNX*Stats cmdlets did their own internal conversion to usecs from epoch so we could just pass local zone DateTime objects like civilized people.

Trailblazer

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Hey,

 

I tried using the script you provided but I get this error:

 

Invoke-Restmethod error.PNG

 

What did i do wrong?

 

 

Seba

Trailblazer

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Empty

Nutanix Employee

Re: What are valid names for the -metrics parameter in the get-ntnxclusterstat cmdlet

Please share the output for "$PSVersionTable"