Hello
My employer has ESXi 5.0 and ESXi 5.1 hosts that run one or more VMs. Some of the VMs are running a very CPU heavy application. The task is to gather real-time data (data points 20 or less seconds apart) of the CPU usage from the Host and all VMs so that it can be stored in a SQL database (my task ends here) and analyzed on the fly. Basically this is an optimization task, the CPU heavy applications will run more or less threads to fully use the host's resources without making other VMs lack what they need.
What would be the best (or the easiest) way to do this?
Could I use the Get-Stat from PowerCLI to save a single data point (I believe this data updates every 20 seconds) of host/VMs CPU usage to a SQL database and how would I do this? (This post made me wonder: http://communities.vmware.com/message/1784833#1784833)
Can the CPU usage data, that is gathered by vSphere (and accessed using Get-Stat, I believe), be streamed to a SQL database, how to access this data, the database it's stored or how to direct part of it to a specific file?
Currently I'm trying to do this using esxtop, I can limit the data to CPU only by making a config file in interactive mode, I can limit the data to the host and VMs by exporting, editing and importing the entities file and run batch mode with these files to save the result (one data point) to a file. I also have a simple script in awk that reads this file and makes a new one that is ready for the SQL database.
I think that this method can give me more data points, but it requires that I manually edit the entity file and the script for each Host/VMs combination.
Thank you for reading. Please post suggestions.
Regards
Genoan
Do CPU performance stats in windows have any bearing on what is really happening?, they never used to, has this changed in 5.
If there is no contention i.e. the host system is not overloaded then all machines are getting access to the maximum amount of reources so there is no need to optimise.
If there is contention add more resource or limit the amount of resources based on shares so the more importatnt machines get more resources proprtionally.
Your optimisations might end up "fighting" against vmware.
Not a solution to your problem, just a few ideas
Hello
Thank you for your suggestions, all ideas are welcome ![]()
The optimization part won't be done by me, I'm tasked with gathering the data, but I will suggest that it might not work as intended.
I've done some reading and currently have this PoweCLI script:
$Hosts = @("xx.xx.xx.1","xx.xx.xx.2")Connect-viserver -Server $Hosts -user xxx -password "xxx"$alldata = @()$metrics = "cpu.usage.average"foreach ($Server in $Hosts){$stats = Get-Stat -Entity $Server -Realtime -Stat $metrics -MaxSamples 1$stats | Group-Object -Property Entity | %{$hoststat = "" | Select HostName, VMName, CPUAvg$hoststat.HostName = $_.name$cpu = $_.Group | where {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property value -Average$hoststat.CPUAvg = [int]$cpu.Average$hostname = $hoststat.HostName$alldata += $hoststat}$vms = Get-Vm -Server $Server | where {$_.PowerState -eq "PoweredOn"}$stats = Get-Stat -Entity $vms -Realtime -Stat $metrics -MaxSamples 1$stats | Group-Object -Property Entity | %{$vmstat = "" | Select HostName, VmName, CPUAvg$vmstat.VmName = $_.name$cpu = $_.Group | where {$_.MetricId -eq "cpu.usage.average"} | Measure-Object -Property value -Average$vmstat.CPUAvg = [int]$cpu.Average$vmstat.HostName = $hostname$alldata += $vmstat}}$alldata | Export-Csv "c:\tmp\Data.csv" -noTypeInformationDisconnect-viserver *
First, a stupid question:
is the data I'm gathering the current CPU load/usage or should I be checking a different stat?
This script does exactly what I need, but is slow, it takes 90 seconds to gather info from 9 hosts with 60 VMs total.
I'm looking for a way to make it faster, ideally keeping the output format unchanged, example:
"HostName","VmName or blank if Host","Value"
"Host1",,"10"
"Host1","Vm1","9"
"Host2",,"15"
"Host2","Vm1","9"
"Host2","Vm2","5"
I've found this thread:
http://communities.vmware.com/thread/341055
and I will try to rewrite the script accordingly, probably during the weekend.
Regards
Genoan
