VMware Cloud Community
alanrenouf
VMware Employee
VMware Employee
Jump to solution

CPU/MEM usage of resource pool

Me Again !

Thanks for your help so far, you guys are amazing.

If I am in VC and I click a Resource Pool I am able to see the CPU Usage and Memory usage of all VM's in that resource pool

IE

Production Resource Pool:

CPU Usage: 919 Mhz

Mem Usage: 4770 MB

Do you know how i might do this for a given resource pool name ?

Thanks

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Perhaps. If you go into edit on the statistics levels it shows what is included for each level but not in detail.

I'm afraid you'll have to go the trial-and-error path Smiley Sad


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

View solution in original post

0 Kudos
31 Replies
halr9000
Commander
Commander
Jump to solution

I haven't done much stats stuff yet but play around with this:

get-resourcepool foo | get-stat

Hal Rottenberg

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Niket
Enthusiast
Enthusiast
Jump to solution

Hi,

Below script will provide the required output.

$server = get-viserver -server ) -Stat cpu.usagemhz.average,cpu.usagemhz.maximum -Realtime

You can add the any number of required statistics counter with -stat separated by commas as I did for two counters.

-RealTime parameter provide the output at the interval of 20 second and for historical data you can remove this parameter.

For other flexibility like 5 days back data or restrict the number of output sample please refer the thread http://communities.vmware.com/message/962460

Thanks

Niket

alanrenouf
VMware Employee
VMware Employee
Jump to solution

Thanks, that gets the CPU usage of the resource group but I cant get the mem usage, if i change it for mem.usage.average it comes back as a percentage rather than the amount being used in that resource group.

Is it just me or does that not make sense, giving one type of figure for one counter and another for the same one of a different type ?

Anyway, any ideas how to get the memory please ?

Thanks

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

Try with mem.active.average, that will give you the "Amount of memory that is actively used".

For an overview of all performance counters and their meaning and availability see Appendix A in the Programming Guide VMware Infrastructure SDK 2.5


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

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

I have tried a fair few of these but I dont think the item has stats for these counters.

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

Did you use realtime stats ?

Get-Stat -Entity (Get-ResourcePool -Name <resource-pool-name>) -Stat mem.active.average -Realtime

returns statistics in my environment.

If not, did you check in the VI Client via menu <Administration><VirtualCenter Management Server Configuration><Statistics> if you keep statistics for the interval you requested ?


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

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Yeah tried it and am not getting any results please see below:

PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-Stat -Entity

(Get-ResourcePool -Name "Production") -Stat mem.active.average -Realtime

PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-Stat -Entity

(Get-ResourcePool -Name "Production") -Realtime

MetricId Timestamp Value Unit

-


-


-


-


cpu.usagemhz.average 6/20/2008 9:50:00 AM 7947 MHz

cpu.usagemhz.average 6/20/2008 9:45:00 AM 7810 MHz

cpu.usagemhz.average 6/20/2008 9:40:00 AM 7607 MHz

cpu.usagemhz.average 6/20/2008 9:35:00 AM 7769 MHz

cpu.usagemhz.average 6/20/2008 9:30:00 AM 7650 MHz

cpu.usagemhz.average 6/20/2008 9:25:00 AM 7766 MHz

cpu.usagemhz.average 6/20/2008 9:20:00 AM 7433 MHz

cpu.usagemhz.average 6/20/2008 9:15:00 AM 7832 MHz

cpu.usagemhz.average 6/20/2008 9:10:00 AM 7960 MHz

cpu.usagemhz.average 6/20/2008 9:05:00 AM 8336 MHz

mem.usage.average 6/20/2008 9:50:00 AM 225.8 %

mem.usage.average 6/20/2008 9:45:00 AM 216.65 %

mem.usage.average 6/20/2008 9:40:00 AM 218.06 %

mem.usage.average 6/20/2008 9:35:00 AM 216.45 %

mem.usage.average 6/20/2008 9:30:00 AM 215.55 %

mem.usage.average 6/20/2008 9:25:00 AM 218.68 %

mem.usage.average 6/20/2008 9:20:00 AM 219.87 %

mem.usage.average 6/20/2008 9:15:00 AM 229.59 %

mem.usage.average 6/20/2008 9:10:00 AM 222.4 %

mem.usage.average 6/20/2008 9:05:00 AM 215.85 %

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
0 Kudos
Niket
Enthusiast
Enthusiast
Jump to solution

Same script which you ran.

PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-Stat -Entity (Get-ResourcePool -Name "Production") -Stat mem.active.average -Realtime

giving the right output:

MetricId Timestamp Value Unit

-


-


-


-


mem.active.average 6/20/2008 9:24:20 PM 29300 KB

mem.active.average 6/20/2008 9:24:00 PM 36624 KB

mem.active.average 6/20/2008 9:23:40 PM 36624 KB

mem.active.average 6/20/2008 9:23:20 PM 36624 KB

mem.active.average 6/20/2008 9:23:00 PM 29300 KB

mem.active.average 6/20/2008 9:22:40 PM 21976 KB

mem.active.average 6/20/2008 9:22:20 PM 21976 KB

mem.active.average 6/20/2008 9:22:00 PM 36624 KB

mem.active.average 6/20/2008 9:21:40 PM 36624 KB

mem.active.average 6/20/2008 9:21:20 PM 36624 KB

Try to run the script in new session of VI toolkit.

Thanks

Niket

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

That is strange, I have tried it in a new session through the toolkit and also through PowerGUI, I have even re-booted my pc !

Also tried it against a second Virtual Center server I have, do you think i should try and re-install the toolkit ?

Thanks fro all your help.

Alan

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

Did you try to see those stats via the VI Client ?

I don't think a reinstall will help.

If there was something wrong with the VI Toolkit you shouldn't see any stats.


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

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Yeah checked the VI stat settings and they are still default, anyway arent we doing it realtime. Dont understand why they are missing for resource pools in particular ?

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

If i do it for a VM it works fine, just resource groups...

Get-Stat -Entity (Get-vm -name "AMACHINE") -Stat mem.active.average -Realtime

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

I just experienced something similar a minute ago.

Can you try this

Get-Stat -Entity (Get-ResourcePool -Name <poolname>) -Stat mem.active.average -Realtime | Out-Default


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

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Still no output

Is it a bug in the toolkit ?

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

Don't think it's a bug in the Toolkit, otherwise we would all see it.

Does the Get-ResourcePool on it's own return something ?


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

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Yeah that works fine and I can get the following two stats from it but nothing else....

Get-Stat -Entity (Get-ResourcePool -Name "Production") -Stat cpu.usagemhz.average -MaxSamples 1 -Realtime

Get-Stat -Entity (Get-ResourcePool -Name "Production") -Stat mem.usage.average -MaxSamples 1 -Realtime

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Anyone else have any ideas ? Still not working :_|

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

You have to look at the Entity column in Appendix A in the SDK Programming Guide.

It shows clearly that there are not that many statistics available for resource groups.

For cpu stats for example it shows that for resource groups there is only usagemhz.


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

0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Did you use realtime stats ?

<pre>
Get-Stat -Entity (Get-ResourcePool -Name <resource-pool-name>) -Stat mem.active.average -Realtime
</pre>

returns statistics in my environment.

Just wondered how you get results for the above as this is what I want but do not get results, you said you do though.

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