+19
Sverhoevne
在下面尝试
########################################### Function: Cluster-Report-NTNX## Author: Sandeep MP## Description: Gather Cluster stats and exports to mentioned path## Language: PowerShell##############################################################
函数cluster-report-ntnx {param([parameter(poartion = 0,insundation = $ true)])[string] $ password,[parameter(mundatory = $ true)] [dateTime] $ startdate,[parameter(andoration = $ true)] [dateTime] $ enddate,[parameter(andortation = $ true)] [int] [int]$ Interval,[parameter(andiral = $ true)] [string] $ outfile)开始{#add nutanixcmdletspsspsssnapindd-pssnapin nutanixcmdletspsspssnapsnapin
#prerequisites检查$ PSSNAPIN = GET -PSSNAPIN $ PSSNAPINCHECK = $ PSSNAPIN.NAME -CONTAINS“ NUTANIXCMDLETSPSSPSSNAPSNAPIN” $ PSVER = $ psversiontable.psversion.psversion.major.major -ge 3if(错误的)){
if($ pssnapincheck -eq $ false){write-host“未安装的nutanix cmdlet”} if($ psver -eq $ false){write-host'powerShell版本应为3.0或更高版本或更高版本“} break”} break} $ pwd = convertto-contsctto----securestring $ password -asplaintext -force $ data = @()$ epoch = get -date -date“ 01/01/1970” [int64] $ start_time =(((new -timespan -start $ epoch -epoch -e epoch -end $ start $ startdate).totalmilliseconds))*1000 [int64] $ end_time =(((new -timespan -start $ epoch -end $ enddate).totalmilliseconds)*1000} process {disconnect -ntnxcluster -server-servers -server -servers -servers -servers -servers*$ clusterout = connect -ntnxcluster = connect -ntnxcluster -sererver $ 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_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 $ storege_usage_bytes =(get -ntnxclusterstat -metrics“ storege.usage_bytes” -starttimeInusecs $ start_time_time -endtimeinusecs $ end_time-time-time -time -intervalinsecs $ interval).values).values
for($ i = 0; $ i -lt $ hypervisor_cpu_usage_ppm.count; $ i ++){$ in = new -object psobject psobject adddd-member -inputObject $ in -memberType noteproperty in -memberType noteproperty -name -name date $ startDateadd -member -intdateDdatd-minputobject $ in -mbemberty in -memembertype noteproperty 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 += $进入
$ startdate = $ startdate.addseconds($ interval)}
}结束{if($ out){$ data |export-csv $ outfilewrite-host“保存在路径:$ outfile”} else {write-host“无数据可用数据”} disconnect-ntnxcluster -servers-servers *}}
+8
多谢!
因此,此脚本将所有指标置于一个CSV中,或者我可以选择将哪个指标合并到同一CSV中?
塞巴