Perfect! Thanks LucD!
After 12 hours I had to kill the process. The Powershell process was running at 50% with 250mb consumed the whole time. Modified the script with a foreach statement to break it up into VM size bites. Takes about a minute per VM to run on this customer's vCenter.
Takes much longer to run but this script also reduced my csv file by 5 times of the size rather than collecting each metric by MetricID into a csv file.
170 VMs * 1 mins per = 2.8 hours to run
About 2.xMB of Mem per VM in Powershell.exe = 360-400MB Memory required for Powershell
# VM Performance metrics in a single line per interval
I had similar experiences; when running Get-Stat in "bigger" environments it tends to consume a lot of memory and potentialy hang at some point.
That's most probably caused by the way the Get-Stat cmdlet is implemented, the vSphere PerformanceManager works and/or the way PowerShell uses the stack and garbage cleaning.
There are a number of measures you can take:
The solution you picked takes of course the longest time to run, but probably uses the least amount of memory on the client.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
i'm having a similar problem which following this discussion, i still do not get it to work.
when i run get-stattype for VM's ,I get the list of available metrics, but without "mem.active.average".
I have raised statistics level to 2 and still No 'mem.active..' metric.
i can get this for a specific VM using VC performance charts but it is not very usefull.
please advise.
Thanks, Avi
Which intervals did you specify ?
Try like this and see if it returns the metric(s) for any of the intervals
Get-StatType -Entity $vm -Interval "Past Day" | where {$_ -match "mem.active"}
Get-StatType -Entity $vm -Interval "Past Week" | where {$_ -match "mem.active"}
Get-StatType -Entity $vm -Interval "Past Month" | where {$_ -match "mem.active"}
Get-StatType -Entity $vm -Interval "Past Year" | where {$_ -match "mem.active"}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
thanks for your prompt reply.
I now get the metric for "Past Day" interval . i guess it need time to build for "Past Week" ( also in level 2).
Now this command Works :
PS C:\Windows\system32> Get-Stat -Entity (Get-VM my-vm) -Stat mem.active.average -IntervalMins 5 -MaxSamples 3 | where{$_.instance -eq ""}
MetricId Timestamp Value Unit Instance
-------- --------- ----- ---- --------
mem.active.average 24/01/2013 13:45:00 0 KB
mem.active.average 24/01/2013 13:40:00 748226 KB
mem.active.average 24/01/2013 13:35:00 351286 KB
But, when i"m trying to use the start/finish , i get the mistake,
$today = (Get-Date -Hour 10 -Minute 30 -Second 0)
$now = (Get-Date -Hour 13 -Minute 30 -Second 0)
Get-Stat -Entity (Get-VM my-vm) -Stat mem.active.average -Start $today -Finish $now | where{$_.Instance -eq ""}
Get-Stat : 24/01/2013 13:53:14 Get-Stat Object reference not set to an instance of an object.
At line:3 char:9
+ Get-Stat <<<< -Entity (Get-VM my-vm) -Stat mem.active.average -Start $today -Finish $now | where{$_.Instance -eq ""}
+ CategoryInfo : NotSpecified: (:) [Get-Stat], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetViStats
please advise.
thanks, Avi
Yes, it will take time to see the metric appear in all intervals.
Your lines of code seem to work for me. It looks as if the problem is that 'Get-VM my-vm' doesn't return anything.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Get-vm is the same on both lines , the only thing changed in the Time Limit/Frame.
if i want to get the data using max samples and interval for a whole day , how would you suggest to do it , (or any other way )
Thanks,
Could it be that the VM was not running at the time specified in $start ?
Do you see statistics for that time in the vSphere client ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
VM is running, there are 2 adjacent powercli lines, one is working the other is Not, as I written , the only different is the Interval/Start/Finish.
Yes, i am monitoring VC performance couters of that VM at the same time.
Thanks, Avi
The only times I have seen that error with the Get-Stat cmdlet , is when there was no statistical data available at the time specified by the $Start variable.
Can you try changing the value in the $Start variable I see if that makes a difference ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Problem Solved.
I guess it's kind of a bug in the powercli version that I used.
I have upgraded to verison 5.1 (latest) and things started to role.
Thanks for all your support.
i must say you're doing a Holy job in hte community (without offending anyone ...)
Avi
Thanks, glad your problem got solved
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
Is there a way to get this report in a graph like the pic above? I would like to present the report in graph format instead of numbers.
You can let Excel produce the graph, have a look at Export-Xlsx, the sequel, and ordered data.
And there are other ways, have a look at my Dutch VMUG: The Statistics Reporting Session
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
Both links are not working.
There was an error in the links. Still getting used to this new Jive version :smileyshocked:
Should be working now, can you try again ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Links working now.