sureshadmin2011
Enthusiast
Enthusiast

Get-stat each esx physcial CPU usage

Jump to solution

Hi,

I have esxi server with 32 processor (logical, HT enabled) and how do I get per processor usage average using powercli (same as displayed in vcenter CPU realtime usage stats)

1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Yes, something like this for example

Get-VMHost |

Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 |

where{$_.Instance -ne ''} |

Select @{N='ESXi';E={$_.Entity.Name}},Timestamp,@{N='Instance';E={[int]$_.Instance}},Value |

Sort-Object -Property ESXi,Instance


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

View solution in original post

6 Replies
LucD
Leadership
Leadership

Try like this

Get-VMHost |

Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 -Instance '' |

Select @{N='ESXi';E={$_.Entity.Name}},Value


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

0 Kudos
sureshadmin2011
Enthusiast
Enthusiast

Thanks for replying Luc.

This script gives only one value per ESXi, I believe its average of all processor usage.

But my requirement was CPU usage "per processor" in my ESXi at the time I run the script. Basically i'm trying to get something like PCPU USED% in ESXTOP where it shows up all 32 processor usage individually in a line and a average atlast. This can also been seen in vcenter when we select a ESXi host and then performance CPU in realtime. We can see all the processor named as 0,1,2.... and we can see the average for every processor.

0 Kudos
LucD
Leadership
Leadership

Yes, that is correct, the above lines give the average per ESXi.

If you want to see values for all cores, you could do

Get-VMHost |

Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 |

where{$_.Instance -ne ''} |

Select @{N='ESXi';E={$_.Entity.Name}},Timestamp,Instance,Value

Since you mentioned esxtop and PCPU, you might also want to have a look at Get-EsxTop – Another Look


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

sureshadmin2011
Enthusiast
Enthusiast

Thanks Luc, its this one I was looking for.

Just one question how to "numeric" sort the field Instance? When I use sort-object on instance it sorts like 0,1,11,12... Instead I need 0,1,2,3,4....

Should we declare "instance" as [int] ?

0 Kudos
LucD
Leadership
Leadership

Yes, something like this for example

Get-VMHost |

Get-Stat -Realtime -Stat 'cpu.usage.average' -MaxSamples 1 |

where{$_.Instance -ne ''} |

Select @{N='ESXi';E={$_.Entity.Name}},Timestamp,@{N='Instance';E={[int]$_.Instance}},Value |

Sort-Object -Property ESXi,Instance


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

View solution in original post

sureshadmin2011
Enthusiast
Enthusiast

Thanks Luc, works good.

0 Kudos