Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 178257

Problem with get-stat command and scripting

$
0
0

Hi,

I'm currently trying to write a simple script that could get resource pool statistics, but having problems with it.

I am using vSphere 4.0, vCenter Server 4.0, ESX 4.0(update 4), PowerCLI 5.1 release2

 

 

I wanted to get the statistics that belonged to Cluster1 so I put the following variable.

 

$rp1 = Get-ResourcePool -Location Cluster1

 

next, I wanted to get the cpu statistics of the resource pools so I put the following variable.

 

$metrics_rp = "cpu.usagemhz.average","cpu.usagemhz.maximum"

 

next. I put the get-stat cmdlet into the following variable

 

$rpstats = Get-Stat -Entity ($rp1) -Stat $metrics_rp -Start $midnight.adddays(-1).addminutes(-1) -Finish $midnight.addminutes(-1) | Select-Object timestamp,value,unit,metricid,entity

 

finally, I would get the statistics and convert it into a csv file

 

$rpstats | Export-Csv C:\stats\rp_stats.csv

 

 

Now the problem is when I try to run this, the script takes a very long time to complete.

or when I try to do this for multiple clusters, it takes forever or it does not even complete.

(for multiple cluster i would just add more variables e.g. $rp2 = Get-ResourcePool -Location Cluster2)

 

It seems that it takes time when I make the get-stat command into a variable.

I have 2 two clusters hanging on my vCenter server and about 15 resource pools on each cluster.

I would appreciate it if someone could tell me a better way to this or if I'm doing this wrong.

 

Thanks in advance.


Viewing all articles
Browse latest Browse all 178257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>