Prism

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: 

Analysis tab data export question

SOLVED Go to solution
Trailblazer

Re: Analysis tab data export question

@sandeepmp

 

Thanks alot for this! 

 

I will test tis asap and post the results here.

 

Thanks again!

 

Seba

Nutanix Employee

Re: Analysis tab data export question

@sverhoevne

 

Did the script help?

 

 

Trailblazer

Re: Analysis tab data export question

@sandeepmp

 

I will test it this week.

Trailblazer

Re: Analysis tab data export question

Hey @sandeepmp

 

I have some issues with the script..

Is there some way I can contact you for this? 

 

Regards

 

Seba

Nutanix Employee

Re: Analysis tab data export question

@sverhoevne

Currently I am on vacation and will back on 3rd May.

You can contact me on below.

Email : sandeep.mp@nutanix.con
Trailblazer

Re: Analysis tab data export question

Hey Sandeep,

 

Is it possible to extract multiple metrics into 1 csv file?

 

 

Seba

Highlighted
Nutanix Employee

Re: Analysis tab data export question

@sverhoevne

 

I am currently modifying the script and will update the same shortly.

Nutanix Employee

Re: Analysis tab data export question

@sverhoevne

 

Try below

 

############################################################
##
## Function: Cluster-Report-NTNX
## Author: Sandeep MP
## Description: Gather Cluster stats and exports to mentioned path
## Language: PowerShell
##
############################################################

function Cluster-Report-NTNX{
<#
.NAME
Cluster-Report-NTNX
.SYNOPSIS
Gather Cluster stats and exports to mentioned path
.DESCRIPTION
Gather Cluster stats and exports to mentioned path
.NOTES
Authors: sandeep.mp@nutanix.com

Logs: C:\Users\<USERNAME>\AppData\Local\Temp\NutanixCmdlets\logs
.LINK
www.nutanix.com
.EXAMPLE
Cluster-Report-NTNX -Server Server_ip -UserName username -Password password -Startdate '07/10/2017 10:00' -Enddate '07/10/2017 11:00' -Interval 60 -OutFile c:\result5.csv

.SYNTAX
Cluster-Report-NTNX [-Server] <string> -UserName <string> -Password <string> -Startdate <datetime> -Enddate <datetime> -Interval <int> -OutFile <string> [<CommonParameters>]

#>
param(
[Parameter(Position=0,Mandatory=$True)][String]$Server,
[Parameter(Mandatory=$True)][String]$UserName,
[Parameter(Mandatory=$True)][String]$Password,
[Parameter(Mandatory=$True)][DateTime]$Startdate,
[Parameter(Mandatory=$True)][DateTime]$Enddate,
[Parameter(Mandatory=$True)][Int]$Interval,
[Parameter(Mandatory=$True)][String]$OutFile
)
Begin{
#Add NutanixCMDletsPSSnapin
Add-PSSnapin NutanixCMDletsPSSnapin

#Prerequisites Check

$pssnapin = Get-PSSnapin
$pssnapincheck = $pssnapin.name -contains "NutanixCMDletsPSSnapin"
$psver = $PSVersionTable.PSVersion.Major -ge 3
if(($pssnapincheck -eq $false) -or ($psver -eq $false))
{

if($pssnapincheck -eq $false)
{
write-host "Nutanix CMDlets not installed"
}
if($psver -eq $false)
{
write-host "Powershell version should be 3.0 or above"
}
break
}

$pwd = ConvertTo-SecureString $password -AsPlainText -Force
$data = @()
$epoch = Get-Date -Date "01/01/1970"
[int64]$start_time = ((New-TimeSpan -Start $epoch -End $startdate).TotalMilliseconds)*1000
[int64]$end_time = ((New-TimeSpan -Start $epoch -End $enddate).TotalMilliseconds)*1000
}
process{
Disconnect-NTNXCluster -Servers *
$clusterout = Connect-NTNXCluster -Server $server -UserName $UserName -Password $pwd -AcceptInvalidSSLCerts -ForcedConnection


$hypervisor_cpu_usage_ppm =""
$hypervisor_memory_usage_ppm =""
$hypervisor_avg_io_latency_usecs = ""
$hypervisor_io_bandwidth_kBps =""
$hypervisor_num_iops =""
$storage_usage_bytes =""


$hypervisor_cpu_usage_ppm = (Get-NTNXClusterStat -Metrics "hypervisor_cpu_usage_ppm" -StartTimeInUsecs $start_time -EndTimeInUsecs $end_time -IntervalInSecs $Interval).values
$hypervisor_memory_usage_ppm = (Get-NTNXClusterStat -Metrics "hypervisor_memory_usage_ppm" -StartTimeInUsecs $start_time -EndTimeInUsecs $end_time -IntervalInSecs $Interval).values
$hypervisor_avg_io_latency_usecs = (Get-NTNXClusterStat -Metrics "hypervisor_avg_io_latency_usecs" -StartTimeInUsecs $start_time -EndTimeInUsecs $end_time -IntervalInSecs $Interval).values
$hypervisor_io_bandwidth_kBps = (Get-NTNXClusterStat -Metrics "hypervisor_io_bandwidth_kBps" -StartTimeInUsecs $start_time -EndTimeInUsecs $end_time -IntervalInSecs $Interval).values
$hypervisor_num_iops = (Get-NTNXClusterStat -Metrics "hypervisor_num_iops" -StartTimeInUsecs $start_time -EndTimeInUsecs $end_time -IntervalInSecs $Interval).values
$storage_usage_bytes = (Get-NTNXClusterStat -Metrics "storage.usage_bytes" -StartTimeInUsecs $start_time -EndTimeInUsecs $end_time -IntervalInSecs $Interval).values

for($i =0;$i -lt $hypervisor_cpu_usage_ppm.count;$i++)
{
$into = new-object PSObject
Add-member -inputobject $into -membertype Noteproperty -Name Date $startdate
Add-member -inputobject $into -membertype Noteproperty -Name hypervisor_cpu_usage_ppm $hypervisor_cpu_usage_ppm[$i]
Add-member -inputobject $into -membertype Noteproperty -Name hypervisor_memory_usage_ppm $hypervisor_memory_usage_ppm[$i]
Add-member -inputobject $into -membertype Noteproperty -Name hypervisor_avg_io_latency_usecs $hypervisor_avg_io_latency_usecs[$i]
Add-member -inputobject $into -membertype Noteproperty -Name hypervisor_io_bandwidth_kBps $hypervisor_io_bandwidth_kBps[$i]
Add-member -inputobject $into -membertype Noteproperty -Name hypervisor_num_iops $hypervisor_num_iops[$i]
Add-member -inputobject $into -membertype Noteproperty -Name storage_usage_bytes $storage_usage_bytes[$i]

$data +=$into

$Startdate = $startdate.AddSeconds($Interval)
}


}
End{
if($out)
{
$data | export-csv $OutFile
Write-Host "Report saved in path : $OutFile"
}Else
{
Write-Host "No data available for export"
}
Disconnect-NTNXCluster -Servers *
}
}

Trailblazer

Re: Analysis tab data export question

Thanks alot!

 

So this script puts all metrics into one csv or am I able to choose which metric to combine into the same CSV?

 

 

Seba

Nutanix Employee

Re: Analysis tab data export question

@sverhoevne

 

This script pulls all into one CSV