+19
Sverhoevne
在下面尝试
############################ #########################################
函数cluster-report-ntnx {param([parameter(poartion = 0,indodation = $ true)] int] $间隔,[parameter(undoration = $ true)] [string] $ outfile)开始{#add nutanixcmdletspsspsssnapinadd-pssnapin nutanixcmdletspsspssnapin
#prercisites检查$ PSSNAPIN = GET -PSSNAPIN $ PSSNAPINCHECK = $ PSSNAPIN.NAME -CONTAINS“ NUTANIXCMDLETSPSSPSSNAPSNAPIN” $ PSVER = $ psversiontable.psversion.psversion.major -ge 3if(
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 PSObjectAdd-member -inputobject $into -membertype Noteproperty -Name Date $startdateAdd-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)}
}结束{if($ out){$ data |export-csv $ outfilewrite-host“保存在路径中:$ outfile”} else {write-host“无数据可用于导出”} disconnect-ntnxcluster -servers-servers *}}
+8
多谢!
因此,此脚本将所有指标置于一个CSV中,或者我可以选择将哪个指标合并到同一CSV中?
塞巴