jasonrobinson
Enthusiast
Enthusiast

VM Perf Data

Jump to solution

Ok guys I got a tough one here. I need to pull perf data on about 75 vms. The data needs to include cpu and memory utilization for the past week. I dont need any pretty charts however I need it to be available in a CSV. Does anyone know how to do this or has anything like this already been written? Thanks in advance for any help with this.

Jason @jrob24
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Note that the script Alan pointed to gives only 1 value for the complete period.

If you want to see the values for each interval you could use a script similar to this

$allVMs = @()
$VMs = Get-VM

foreach($vm in $VMs){
	$statcpu = Get-Stat -Entity ($vm) `
	   -start (get-date).AddDays(-7) `
	   -Finish (Get-Date) `
	   -MaxSamples 10000 `
	   -stat cpu.usage.average
	$statmem = Get-Stat -Entity ($vm) `
	   -start (get-date).AddDays(-7) `
	   -Finish (Get-Date) `
	   -MaxSamples 10000 `
	   -stat mem.usage.average

	for($i = 0; $i -lt $statcpu.Count; $i++){
		$vmstat = "" | Select VMName, Timestamp, MemAvg, CPUAvg
		$vmstat.VMName = $vm.name
		$vmstat.Timestamp = $statcpu[$i].Timestamp
		$vmstat.CPUAvg = $statcpu[$i].Value
		$vmstat.MemAvg = $statmem[$i].Value

		$allVMs += $vmstat
	}
}

$allVMs | Export-Csv "c:\Vm-Stat.csv" -noTypeInformation

Note that the script assumes that all metrics return values for each interval!

If that is not the case then the script needs some additional lines to compare the timestamps of both arrays.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
alanrenouf
VMware Employee
VMware Employee

Have you seen this previous example where LucD shows how to get this info for a cluster ?

Should be able to adjust this: http://communities.vmware.com/message/1001725#1001725

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

http://virtu-al.net

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
LucD
Leadership
Leadership

Note that the script Alan pointed to gives only 1 value for the complete period.

If you want to see the values for each interval you could use a script similar to this

$allVMs = @()
$VMs = Get-VM

foreach($vm in $VMs){
	$statcpu = Get-Stat -Entity ($vm) `
	   -start (get-date).AddDays(-7) `
	   -Finish (Get-Date) `
	   -MaxSamples 10000 `
	   -stat cpu.usage.average
	$statmem = Get-Stat -Entity ($vm) `
	   -start (get-date).AddDays(-7) `
	   -Finish (Get-Date) `
	   -MaxSamples 10000 `
	   -stat mem.usage.average

	for($i = 0; $i -lt $statcpu.Count; $i++){
		$vmstat = "" | Select VMName, Timestamp, MemAvg, CPUAvg
		$vmstat.VMName = $vm.name
		$vmstat.Timestamp = $statcpu[$i].Timestamp
		$vmstat.CPUAvg = $statcpu[$i].Value
		$vmstat.MemAvg = $statmem[$i].Value

		$allVMs += $vmstat
	}
}

$allVMs | Export-Csv "c:\Vm-Stat.csv" -noTypeInformation

Note that the script assumes that all metrics return values for each interval!

If that is not the case then the script needs some additional lines to compare the timestamps of both arrays.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos